From 6111524ce192ce63655d9e2d2e003b5e17309df1 Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Wed, 18 Oct 2023 16:37:34 -0700 Subject: [PATCH] status command (ripped from submission bot) --- src/commands/bot/status.ts | 67 ++++++++++++++++++++++++++++++++++ src/commands/images/animate.ts | 4 +- 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/commands/bot/status.ts diff --git a/src/commands/bot/status.ts b/src/commands/bot/status.ts new file mode 100644 index 000000000..0dbdb6ae6 --- /dev/null +++ b/src/commands/bot/status.ts @@ -0,0 +1,67 @@ +import { + ActivityType, + SlashCommandBuilder, + PermissionFlagsBits, + PresenceStatusData, +} from "discord.js"; +import { EmbedBuilder, ChatInputCommandInteraction } from "@client"; +import { SlashCommand } from "@interfaces"; + +export const command: SlashCommand = { + data: new SlashCommandBuilder() + .setName("status") + .setDescription("Changes the bot's status.") + .addStringOption((option) => + option + .setName("activity") + .setDescription("What activity the bot is doing (e.g. playing, streaming)") + .addChoices( + ...Object.values(ActivityType) + .filter((x) => typeof x == "string") + .map((i: string) => { + return { name: i, value: i }; + }), + ) + .setRequired(true), + ) + .addStringOption((option) => + option + .setName("presence") + .setDescription("What presence the bot should have") + .addChoices( + { name: "Online", value: "online" }, + { name: "Idle", value: "idle" }, + { name: "Do not Disturb", value: "dnd" }, + ) + .setRequired(true), + ) + .addStringOption((option) => + option + .setName("message") + .setDescription("Message to show after the bot activity") + .setRequired(true), + ) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + async execute(interaction: ChatInputCommandInteraction) { + if (!interaction.hasPermission("dev")) return; + + const activity = interaction.options.getString("activity", true); + const presence = interaction.options.getString("presence", true); + const message = interaction.options.getString("message", true); + + interaction.client.user.setPresence({ + activities: [ + { + name: message, + type: ActivityType[activity], + }, + ], + status: presence as PresenceStatusData, + }); + + await interaction.reply({ + embeds: [new EmbedBuilder().setTitle("Bot status successfully changed!")], + ephemeral: true, + }); + }, +}; diff --git a/src/commands/images/animate.ts b/src/commands/images/animate.ts index ffaeba86a..07eba6ed2 100644 --- a/src/commands/images/animate.ts +++ b/src/commands/images/animate.ts @@ -61,9 +61,7 @@ export const command: SlashCommand = { embeds: [ new EmbedBuilder() .setTitle(interaction.strings().command.animate.invalid_text.title) - .setDescription( - interaction.strings().command.animate.invalid_text.description, - ) + .setDescription(interaction.strings().command.animate.invalid_text.description) .setColor(colors.red), ], ephemeral: true,