Update minimal template (#2314)

* Outdate template

* don't use `.env.example`

* deno fmt

Co-authored-by: meister03 <meisterpi@gmail.com>
Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
Co-authored-by: LTS20050703 <lts20050703@gmail.com>
This commit is contained in:
meister03
2022-08-23 10:30:19 -04:00
committed by GitHub
co-authored by meister03 LTS20050703 LTS20050703
parent 34d7a47f24
commit 0fb4e1f398
6 changed files with 76 additions and 65 deletions
-1
View File
@@ -1,6 +1,5 @@
import { dotEnvConfig } from "./deps.ts";
dotEnvConfig({ export: true });
export const BOT_TOKEN = Deno.env.get("BOT_TOKEN") || "";
export const BOT_ID = BigInt(atob(BOT_TOKEN.split(".")[0]));
+2 -2
View File
@@ -1,4 +1,4 @@
export * from "https://deno.land/x/discordeno@13.0.0-rc31/mod.ts";
export * from "https://deno.land/x/discordeno@13.0.0-rc31/plugins/mod.ts";
export * from "https://deno.land/x/discordeno@13.0.0-rc45/mod.ts";
export * from "https://deno.land/x/discordeno@13.0.0-rc45/plugins/mod.ts";
export { config as dotEnvConfig } from "https://deno.land/x/dotenv@v3.1.0/mod.ts";
export * from "https://deno.land/std@0.117.0/fmt/colors.ts";
+23 -11
View File
@@ -1,4 +1,12 @@
import { ActivityTypes, createBot, enableCachePlugin, enableCacheSweepers, fastFileLoader, startBot } from "./deps.ts";
import {
ActivityTypes,
createBot,
enableCachePlugin,
enableCacheSweepers,
fastFileLoader,
GatewayIntents,
startBot,
} from "./deps.ts";
import { BOT_ID, BOT_TOKEN } from "./configs.ts";
import { logger } from "./src/utils/logger.ts";
import { events } from "./src/events/mod.ts";
@@ -19,22 +27,26 @@ export const bot = enableCachePlugin(
createBot({
token: BOT_TOKEN,
botId: BOT_ID,
intents: [],
intents: GatewayIntents.Guilds,
events,
}),
);
// @ts-nocheck: no-updated-depencdencies
enableCacheSweepers(bot);
bot.gateway.presence = {
status: "online",
activities: [
{
name: "Discordeno is Best Lib",
type: ActivityTypes.Game,
createdAt: Date.now(),
},
],
bot.gateway.manager.createShardOptions.makePresence = (shardId: number) => {
return {
shardId: shardId,
status: "online",
activities: [
{
name: "Discordeno is Best Lib",
type: ActivityTypes.Game,
createdAt: Date.now(),
},
],
};
};
await startBot(bot);
+4 -4
View File
@@ -51,7 +51,7 @@ export async function updateCommands(
if (globalCommands.length && (scope === "Global" || scope === undefined)) {
log.info(
"Updating Global Commands, this takes up to 1 hour to take effect...",
"Updating Global Commands, changes should apply in short...",
);
await bot.helpers.upsertApplicationCommands(globalCommands).catch(
log.error,
@@ -59,7 +59,7 @@ export async function updateCommands(
}
if (perGuildCommands.length && (scope === "Guild" || scope === undefined)) {
await bot.guilds.forEach(async (guild) => {
await bot.guilds.forEach(async (guild: Guild) => {
await upsertApplicationCommands(bot, perGuildCommands, guild.id);
});
}
@@ -99,8 +99,8 @@ export async function getGuildFromId(
}
await getGuild(bot, guildId).then((guild) => {
bot.guilds.set(guildId, guild);
returnValue = guild;
if (guild) bot.guilds.set(guildId, guild);
if (guild) returnValue = guild;
});
}