38 lines
979 B
TypeScript
38 lines
979 B
TypeScript
import {
|
|
ApplicationCommandOptionType,
|
|
type CommandInteraction,
|
|
type TextChannel,
|
|
} from "discord.js";
|
|
import { Discord, Slash, SlashOption } from "discordx";
|
|
import db from "../db";
|
|
import { uptimeTable } from "../db/schema";
|
|
|
|
@Discord()
|
|
export class UptimeCmd {
|
|
@Slash({ name: "uptime-setup", description: "set up uptime cmd" })
|
|
async uptimeCmd(
|
|
@SlashOption({
|
|
name: "channel",
|
|
description: "channel to send in",
|
|
required: true,
|
|
type: ApplicationCommandOptionType.Channel,
|
|
})
|
|
channel: TextChannel,
|
|
inter: CommandInteraction,
|
|
) {
|
|
if (inter.user.id != inter.guild?.ownerId) {
|
|
return await inter.reply("you cannot run this command :p");
|
|
}
|
|
|
|
const msg = await channel.send(
|
|
`bot is up, last ping: <t:${Math.floor(Date.now() / 1000)}:f> | if the ping was more than 1 minute ago, cosmic needs to check the bot lol :3`,
|
|
);
|
|
|
|
await db.insert(uptimeTable).values({
|
|
guild: inter.guildId!,
|
|
channel: channel.id,
|
|
message: msg.id,
|
|
});
|
|
}
|
|
}
|