-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
35 lines (29 loc) · 1.06 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { createBot, startBot } from "https://deno.land/x/discordeno@13.0.0-rc18/mod.ts";
import { enableCachePlugin, enableCacheSweepers } from "https://deno.land/x/discordeno_cache_plugin@0.0.18/mod.ts";
export const Main = async () => {
const baseBot = createBot({
token: Deno.env.get("DISCORD_TOKEN") || '',
intents: ["Guilds", "GuildMessages"],
botId: Deno.env.get("BOT_ID") || '',
events: {
ready() {
console.log("Successfully connected to gateway");
},
messageCreate: async (bot, message) => {
const containsBotId = message.mentionedUserIds.find((bigId) => Number(bigId) === Number(bot.id))
if(message.isBot || !containsBotId) return;
await bot.helpers.sendMessage(message.channelId, { content: "Hello World!" });
},
},
});
const bot = enableCachePlugin(baseBot);
enableCacheSweepers(bot);
await startBot(bot);
let retries = 0;
//prevent timeout
setInterval(async () => {
await startBot(bot);
retries++;
console.log(`Retries: ${retries}`)
}, 5 * 60 * 1000)
}