diff --git a/env.d.ts b/env.d.ts index 6da2bf8..844dc1a 100644 --- a/env.d.ts +++ b/env.d.ts @@ -7,5 +7,8 @@ module "bun" { BAD_ROLE: string; BOT_ROLE: string; BOT_CHANNEL: string; + OWNER: string; + SCYTHE_CHANNEL: string; + UPTIME_MESSAGE: string; } } \ No newline at end of file diff --git a/src/commands/uptime.ts b/src/commands/uptime.ts new file mode 100644 index 0000000..251f9d0 --- /dev/null +++ b/src/commands/uptime.ts @@ -0,0 +1,15 @@ +import type { CommandInteraction, TextChannel } from "discord.js"; +import { Discord, Slash } from "discordx"; + +@Discord() +export class Uptime { + @Slash({name: "uptime-setup", description: "set up uptime cmd"}) + async uptime(inter: CommandInteraction) { + if(inter.user.id != Bun.env.OWNER) { + await inter.reply("you cannot run this command :p"); + return + } + const channel = inter.client.channels.cache.get(Bun.env.SCYTHE_CHANNEL) as TextChannel; + await channel.send(`bot is up, last ping: | if the ping was more than 1 minute ago, cosmic needs to check the bot lol :3`) + } +} \ No newline at end of file diff --git a/src/utils/uptime-loop.ts b/src/utils/uptime-loop.ts new file mode 100644 index 0000000..2cbf7f2 --- /dev/null +++ b/src/utils/uptime-loop.ts @@ -0,0 +1,12 @@ +import type { Client } from "discordx"; +import { sleep } from "./underage" +import type { TextChannel } from "discord.js"; + +export const uptimeLoop = async (client: Client) => { + while(true) { + await sleep(30 * 1000); + const channel = client.channels.cache.get(Bun.env.SCYTHE_CHANNEL) as TextChannel; + const msg = await channel.messages.fetch(Bun.env.UPTIME_MESSAGE); + await msg.edit(`bot is up, last ping: | if the ping was more than 1 minute ago, cosmic needs to check the bot lol :3`) + } +} \ No newline at end of file