Enable dev team dot commands

This commit is contained in:
Skylar Grant 2023-06-03 15:40:12 -04:00
parent 105fb2827f
commit a28957b956
8 changed files with 119 additions and 48 deletions

View File

@ -5,5 +5,10 @@
"treeHeight": 0, "treeHeight": 0,
"validCommands": [], "validCommands": [],
"rankMessageId": "", "rankMessageId": "",
"rankings": [] "rankings": [],
"devTeamIds": [
"481933290912350209",
"269249959973355520"
],
"ownerId": "481933290912350209"
} }

View File

@ -4,7 +4,15 @@ module.exports = {
name: "", name: "",
description: "", description: "",
usage: "", usage: "",
execute(message, commandData) { permission: "devTeam", // "devTeam" or "owner"
// Code here... async execute(message, commandData) {
if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
try {
// Code Here
} catch (err) {
console.error(err);
await message.reply(fn.builders.errorEmbed("There was an error running the command."));
}
}
} }
} }

View File

@ -4,7 +4,11 @@ module.exports = {
name: "message", name: "message",
description: "Send a message to a server owner or server", description: "Send a message to a server owner or server",
usage: ".message <serverID> <content>", usage: ".message <serverID> <content>",
permission: "owner",
async execute(message, commandData) { async execute(message, commandData) {
if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
try {
// Code Here
args = commandData.args.split(" "); args = commandData.args.split(" ");
if (message.client.guildInfos.has(args[0])) { if (message.client.guildInfos.has(args[0])) {
let guildInfo = message.client.guildInfos.get(args[0]); let guildInfo = message.client.guildInfos.get(args[0]);
@ -36,5 +40,10 @@ module.exports = {
} else { } else {
throw "Guild doesn't exist in database!"; throw "Guild doesn't exist in database!";
} }
} catch (err) {
console.error(err);
await message.reply(fn.builders.errorEmbed("There was an error running the command."));
}
}
} }
} }

View File

@ -4,8 +4,15 @@ module.exports = {
name: "ping", name: "ping",
description: "pong", description: "pong",
usage: "ping pong", usage: "ping pong",
permission: "devTeam",
async execute(message, commandData) { async execute(message, commandData) {
// Code here... if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
try {
await message.reply("Pong!"); await message.reply("Pong!");
} catch (err) {
console.error(err);
await message.reply(fn.builders.errorEmbed("There was an error running the command."));
}
}
} }
} }

View File

@ -4,14 +4,19 @@ module.exports = {
name: "servers", name: "servers",
description: "Get a list of servers the bot is in", description: "Get a list of servers the bot is in",
usage: ".servers", usage: ".servers",
permission: "owner",
async execute(message, commandData) { async execute(message, commandData) {
if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
try {
let servers = []; let servers = [];
const count = JSON.stringify(message.client.guilds.cache.size); const count = JSON.stringify(message.client.guilds.cache.size);
servers.push("I'm currently in " + count + " servers."); servers.push("I'm currently in " + count + " servers.");
const guilds = await message.client.guilds.cache; const guilds = await message.client.guilds.cache;
// await guilds.each(g => {
// servers.push(g.name + "," + g.ownerId);
// });
await message.reply(servers.join("\n")); await message.reply(servers.join("\n"));
} catch (err) {
console.error(err);
await message.reply(fn.builders.errorEmbed("There was an error running the command."));
}
}
} }
} }

24
dot-commands/setupview.js Normal file
View File

@ -0,0 +1,24 @@
const fn = require('../modules/functions.js');
module.exports = {
name: "setupview",
description: "",
usage: "",
permission: "devTeam",
async execute(message, commandData) {
// Code here...
if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
try {
if (message.client.guildInfos.has(message.guildId)) {
let guildInfo = message.client.guildInfos.get(message.guildId);
await message.reply(fn.builders.embed(guildInfo.generateSetupInfo()));
} else {
await message.reply(fn.builders.errorEmbed("Guild doesn't exist in database!"));
}
} catch (err) {
console.error(err);
await message.reply(fn.builders.errorEmbed("There was an error running the command."));
}
}
}
}

View File

@ -111,7 +111,7 @@ client.on('messageCreate', async message => {
const commandData = fn.dotCommands.getCommandData(message); const commandData = fn.dotCommands.getCommandData(message);
// if (isDev) console.log(commandData); // if (isDev) console.log(commandData);
if (commandData.isValid && commandData.isCommand && (message.author.id == process.env.ownerId)) { if (commandData.isValid && commandData.isCommand) {
try { try {
client.dotCommands.get(commandData.command).execute(message, commandData); client.dotCommands.get(commandData.command).execute(message, commandData);
} }

View File

@ -265,6 +265,19 @@ const functions = {
console.error('Somehow a non-command made it to checkCommands()'); console.error('Somehow a non-command made it to checkCommands()');
} }
return commandData; return commandData;
},
checkPermissions(type, userId) {
if (type === "devTeam") {
const { devTeamIds } = config;
let matchFound = false;
for (let i = 0; i < devTeamIds.length; i++) {
if (userId === devTeamIds[i]) matchFound = true;
}
return matchFound;
} else if (type === "owner") {
return config.ownerId === userId;
}
} }
}, },
rankings: { rankings: {