Init WIP Bot

This commit is contained in:
Logan Cusano
2022-12-11 06:09:25 -05:00
parent f1f4cb7750
commit 4e1b82c557
43 changed files with 6766 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { readFileSync } from 'fs';
export function getConfig() {
return JSON.parse(readFileSync("./config/botConfig.json"));
}
export function getTOKEN() {
const parsedJSON = getConfig();
return parsedJSON.TOKEN;
}
export function getGuildID() {
const parsedJSON = getConfig();
parsedJSON.GuildID = BigInt(parsedJSON.GuildID);
//console.log("Guild ID: ", parsedJSON.GuildID);
return parsedJSON.GuildID;
}
export function getApplicationID() {
const parsedJSON = getConfig();
parsedJSON.ApplicationID = BigInt(parsedJSON.ApplicationID);
//console.log("Application ID: ", parsedJSON.ApplicationID);
return parsedJSON.ApplicationID;
}
export function getDeviceID(){
const parsedJSON = getConfig();
//console.log("Device ID: ", parseInt(parsedJSON.DeviceID));
return parseInt(parsedJSON.DeviceID);
}
export function getDeviceName(){
const parsedJSON = getConfig();
//console.log("Device Name: ", parseInt(parsedJSON.DeviceName));
return parsedJSON.DeviceName;
}

View File

@@ -0,0 +1,5 @@
export function replyToInteraction(interaction, message){
interaction.reply({ content: message, fetchReply: true })
.then((message) => console.log(`Reply sent with content ${message.content}`))
.catch(console.error);
}

View File

@@ -0,0 +1,45 @@
import {SlashCommandBuilder} from "@discordjs/builders";
import {REST} from "@discordjs/rest";
import {getApplicationID, getGuildID, getTOKEN} from "./configHandler.js";
import { Routes, ChannelType } from "discord.js";
const pingCommand = new SlashCommandBuilder()
.setName("ping")
.setDescription("Confirm the bot is online")
.toJSON();
const joinCommand = new SlashCommandBuilder()
.setName('join')
.setDescription('Joins a voice channel')
.addChannelOption((option) => option
.setName('voicechannel')
.setDescription('The Channel to voiceController')
.setRequired(false)
.addChannelTypes(ChannelType.GuildVoice))
.toJSON();
const leaveCommand = new SlashCommandBuilder()
.setName("leave")
.setDescription("Leave current voice channel")
.toJSON();
export default async function registerCommands(callback){
const commands = [
pingCommand,
joinCommand,
leaveCommand
];
try {
const rest = new REST({ version: '10' }).setToken(getTOKEN());
const clientID = getApplicationID();
const guildID = getGuildID();
await rest.put(Routes.applicationGuildCommands(clientID, guildID), {
body: commands,
});
callback();
} catch (err) {
console.log(err);
}
}