-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate to drizzle, add starter svelte stuff; optimize bot client
Signed-off-by: Espi Marisa <[email protected]>
- Loading branch information
1 parent
62aaa42
commit 8db1462
Showing
50 changed files
with
624 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
{ | ||
"COMMAND_TEST_NAME": "test", | ||
"COMMAND_TEST_DESCRIPTION": "This is a test in English.", | ||
"COMMAND_PING_NAME": "Ping", | ||
"COMMAND_PING_DESCRIPTION": "Checks the current status and latency.", | ||
"COMMAND_PING_PINGING": "⏳ Pinging...", | ||
"COMMAND_PING_PONG": "🏓 Pong!", | ||
"COMMAND_PING_LATENCY": "This message took {{latency}}ms to send. All seems OK!", | ||
|
||
"COMMAND_TESTING_NAME": "testing", | ||
"COMMAND_TESTING_DESCRIPTION": "This is testing something in English." | ||
"COMMAND_ABOUT_NAME": "About", | ||
"COMMAND_ABOUT_DESCRIPTION": "Returns information and statistics about the bot.", | ||
|
||
"COMMAND_ABOUT_TITLE": "✨ About {{username}}", | ||
"COMMAND_ABOUT_DETAILS": "{{username}}, made with 💖 by [Espi Marisa](https://espi.me).", | ||
"COMMAND_ABOUT_CACHED_GUILDS": "Cached Guilds", | ||
"COMMAND_ABOUT_CACHED_USERS": "Cached Users", | ||
"COMMAND_ABOUT_UPTIME": "Uptime", | ||
"COMMAND_ABOUT_HIBIKI_VERSION": "Hibiki Version", | ||
"COMMAND_ABOUT_DISCORDJS_VERSION": "Discord.js Version", | ||
"COMMAND_ABOUT_BUN_VERSION": "Bun Version", | ||
|
||
"DAYS": "{{days}} dasy", | ||
"HOURS": "{{amount}} hours", | ||
"MINUTES": "{{minutes}} minutes", | ||
"SECONDS": "{{amount}} seconds" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { HibikiCommand } from "$classes/Command.ts"; | ||
import { fetchTotalCachedUsers, fetchTotalCachedGuilds } from "$classes/Sharder.ts"; | ||
import { HibikiColors } from "$shared/constants.ts"; | ||
import env from "$shared/env.ts"; | ||
import { t } from "$shared/i18n.ts"; | ||
import { version, type ChatInputCommandInteraction } from "discord.js"; | ||
|
||
export class HibikiPingCommand extends HibikiCommand { | ||
public async runWithInteraction(interaction: ChatInputCommandInteraction, locale: string) { | ||
// Gets the amount of cached guilds and users | ||
const totalCachedGuilds = await fetchTotalCachedGuilds(this.bot.shard); | ||
const totalCachedUsers = await fetchTotalCachedUsers(this.bot.shard); | ||
|
||
await interaction.followUp({ | ||
embeds: [ | ||
{ | ||
title: t("COMMAND_ABOUT_TITLE", { username: this.bot.user?.username, lng: locale }), | ||
description: t("COMMAND_ABOUT_DETAILS", { username: this.bot.user?.username, lng: locale }), | ||
color: HibikiColors.GENERAL, | ||
fields: [ | ||
{ | ||
name: t("COMMAND_ABOUT_CACHED_GUILDS", { lng: locale }), | ||
value: `${totalCachedGuilds}`, | ||
inline: true, | ||
}, | ||
{ | ||
name: t("COMMAND_ABOUT_CACHED_USERS", { lng: locale }), | ||
value: `${totalCachedUsers}`, | ||
inline: true, | ||
}, | ||
{ | ||
// TODO: Localize | ||
name: t("COMMAND_ABOUT_UPTIME", { lng: locale }), | ||
value: `${Math.floor(process.uptime())} seconds`, | ||
inline: true, | ||
}, | ||
{ | ||
name: t("COMMAND_ABOUT_HIBIKI_VERSION", { lng: locale }), | ||
value: env.npm_package_version, | ||
inline: true, | ||
}, | ||
{ | ||
name: t("COMMAND_ABOUT_DISCORDJS_VERSION", { lng: locale }), | ||
value: version, | ||
inline: true, | ||
}, | ||
{ | ||
name: t("COMMAND_ABOUT_BUN_VERSION", { lng: locale }), | ||
value: Bun.version, | ||
inline: true, | ||
}, | ||
], | ||
thumbnail: { | ||
url: this.bot.user?.displayAvatarURL() ?? "", | ||
}, | ||
}, | ||
], | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { ChatInputCommandInteraction } from "discord.js"; | ||
import { HibikiCommand } from "$classes/Command.ts"; | ||
import { HibikiColors } from "$shared/constants.ts"; | ||
import { t } from "$shared/i18n.ts"; | ||
|
||
export class HibikiPingCommand extends HibikiCommand { | ||
public async runWithInteraction(interaction: ChatInputCommandInteraction, locale: string) { | ||
const initialInteraction = await interaction.followUp({ | ||
fetchReply: true, | ||
embeds: [ | ||
{ | ||
title: t("COMMAND_PING_PINGING", { lng: locale }), | ||
color: HibikiColors.GENERAL, | ||
}, | ||
], | ||
}); | ||
|
||
await interaction.editReply({ | ||
embeds: [ | ||
{ | ||
title: t("COMMAND_PING_PONG", { lng: locale }), | ||
description: t("COMMAND_PING_LATENCY", { | ||
lng: locale, | ||
latency: initialInteraction.createdTimestamp - interaction.createdTimestamp, | ||
}), | ||
color: HibikiColors.GENERAL, | ||
}, | ||
], | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import { HibikiClient } from "./classes/Client.ts"; | ||
import { GatewayIntentBits } from "discord.js"; | ||
import { GatewayIntentBits, Options } from "discord.js"; | ||
|
||
export const subscribedIntents = [ | ||
const subscribedIntents = [ | ||
// Required for guild, channel, and role objects | ||
GatewayIntentBits.Guilds, | ||
|
||
// Required for incoming messages | ||
GatewayIntentBits.GuildMessages, | ||
|
||
// PRIVILEGED: Required for getting guild member data | ||
GatewayIntentBits.GuildMembers, | ||
] satisfies GatewayIntentBits[]; | ||
|
||
// Creates a new Hibiki client | ||
new HibikiClient({ | ||
// Cache sweeping options | ||
sweepers: { | ||
...Options.DefaultSweeperSettings, | ||
}, | ||
|
||
// Cache options | ||
makeCache: Options.cacheWithLimits({ | ||
...Options.DefaultMakeCacheSettings, | ||
ReactionManager: 0, | ||
GuildMemberManager: { | ||
maxSize: 200, | ||
keepOverLimit: (member) => member.id === member.client.user.id, | ||
}, | ||
}), | ||
|
||
// Intents | ||
intents: subscribedIntents, | ||
}).init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import env from "$shared/env.ts"; | ||
import { defineConfig, type Config } from "drizzle-kit"; | ||
|
||
export default defineConfig({ | ||
out: "./drizzle", | ||
schema: "./src/schema/*", | ||
driver: "pg", | ||
dbCredentials: { | ||
host: env.POSTGRES_HOST, | ||
port: env.POSTGRES_PORT, | ||
user: env.POSTGRES_USER, | ||
password: env.POSTGRES_PASSWORD, | ||
database: env.POSTGRES_DB, | ||
}, | ||
verbose: true, | ||
strict: true, | ||
}) satisfies Config; |
Oops, something went wrong.