Added status command to discord bot
This commit is contained in:
@@ -4,6 +4,7 @@ import { getTOKEN, getGuildID, getApplicationID } from './utilities/configHandle
|
|||||||
import ping from './commands/ping.js';
|
import ping from './commands/ping.js';
|
||||||
import join from './commands/join.js';
|
import join from './commands/join.js';
|
||||||
import leave from './commands/leave.js';
|
import leave from './commands/leave.js';
|
||||||
|
import status from './commands/status.js';
|
||||||
// Debug
|
// Debug
|
||||||
import ModuleDebugBuilder from "./utilities/moduleDebugBuilder.js";
|
import ModuleDebugBuilder from "./utilities/moduleDebugBuilder.js";
|
||||||
const log = new ModuleDebugBuilder("bot", "app");
|
const log = new ModuleDebugBuilder("bot", "app");
|
||||||
@@ -47,6 +48,9 @@ client.on('interactionCreate', (interaction) => {
|
|||||||
case "leave":
|
case "leave":
|
||||||
leave(interaction);
|
leave(interaction);
|
||||||
break;
|
break;
|
||||||
|
case "status":
|
||||||
|
status({ interaction: interaction });
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
interaction.reply({ content: 'Command not found, try one that exists', fetchReply: true })
|
interaction.reply({ content: 'Command not found, try one that exists', fetchReply: true })
|
||||||
.then((message) => log.DEBUG(`Reply sent with content ${message.content}`))
|
.then((message) => log.DEBUG(`Reply sent with content ${message.content}`))
|
||||||
|
|||||||
28
Client/discord-bot/commands/status.js
Normal file
28
Client/discord-bot/commands/status.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// Debug
|
||||||
|
import ModuleDebugBuilder from "../utilities/moduleDebugBuilder.js";
|
||||||
|
const log = new ModuleDebugBuilder("bot", "status");
|
||||||
|
// Modules
|
||||||
|
import {getVoiceConnection} from "@discordjs/voice";
|
||||||
|
// Utilities
|
||||||
|
import { replyToInteraction } from '../utilities/messageHandler.js';
|
||||||
|
|
||||||
|
|
||||||
|
export default async function status({interaction= undefined, guildID= undefined}) {
|
||||||
|
//if (!interaction && !guildID) // Need error of sorts
|
||||||
|
if (interaction){
|
||||||
|
guildID = interaction.guild.id;
|
||||||
|
}
|
||||||
|
const voiceConnection = getVoiceConnection(guildID);
|
||||||
|
|
||||||
|
log.DEBUG("guildID: ", guildID)
|
||||||
|
log.DEBUG("Voice Connection: ", voiceConnection)
|
||||||
|
|
||||||
|
// get the status and return it accordingly (message reply / module)
|
||||||
|
|
||||||
|
if (interaction) {
|
||||||
|
return replyToInteraction(interaction, "Pong! I have Aids and now you do too!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,11 +26,17 @@ const leaveCommand = new SlashCommandBuilder()
|
|||||||
.setDescription("Leave current voice channel")
|
.setDescription("Leave current voice channel")
|
||||||
.toJSON();
|
.toJSON();
|
||||||
|
|
||||||
|
const statusCommand = new SlashCommandBuilder()
|
||||||
|
.setName("status")
|
||||||
|
.setDescription("Returns if the bot is connected to a channel or not")
|
||||||
|
.toJSON();
|
||||||
|
|
||||||
export default async function registerCommands(callback){
|
export default async function registerCommands(callback){
|
||||||
const commands = [
|
const commands = [
|
||||||
pingCommand,
|
pingCommand,
|
||||||
joinCommand,
|
joinCommand,
|
||||||
leaveCommand
|
leaveCommand,
|
||||||
|
statusCommand
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user