Enable dev team dot commands
This commit is contained in:
parent
105fb2827f
commit
a28957b956
@ -5,5 +5,10 @@
|
|||||||
"treeHeight": 0,
|
"treeHeight": 0,
|
||||||
"validCommands": [],
|
"validCommands": [],
|
||||||
"rankMessageId": "",
|
"rankMessageId": "",
|
||||||
"rankings": []
|
"rankings": [],
|
||||||
|
"devTeamIds": [
|
||||||
|
"481933290912350209",
|
||||||
|
"269249959973355520"
|
||||||
|
],
|
||||||
|
"ownerId": "481933290912350209"
|
||||||
}
|
}
|
@ -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."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,37 +4,46 @@ 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) {
|
||||||
args = commandData.args.split(" ");
|
if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
|
||||||
if (message.client.guildInfos.has(args[0])) {
|
try {
|
||||||
let guildInfo = message.client.guildInfos.get(args[0]);
|
// Code Here
|
||||||
const guild = await message.client.guilds.fetch(args[0]).catch(async e => {
|
args = commandData.args.split(" ");
|
||||||
await message.reply("I was unable to fetch the guild.");
|
if (message.client.guildInfos.has(args[0])) {
|
||||||
console.error(`Error fetching guild to send message: ${e}`);
|
let guildInfo = message.client.guildInfos.get(args[0]);
|
||||||
});
|
const guild = await message.client.guilds.fetch(args[0]).catch(async e => {
|
||||||
const guildOwner = await message.client.users.fetch(guild.ownerId).catch(async e => {
|
await message.reply("I was unable to fetch the guild.");
|
||||||
await message.reply("I was unable to fetch the guild owner.");
|
console.error(`Error fetching guild to send message: ${e}`);
|
||||||
console.error(`Error fetching guild owner to send message: ${e}`);
|
});
|
||||||
});
|
const guildOwner = await message.client.users.fetch(guild.ownerId).catch(async e => {
|
||||||
await guildOwner.createDM().then(async dm => {
|
await message.reply("I was unable to fetch the guild owner.");
|
||||||
await dm.send(args.join(" ")).catch(async e => {
|
console.error(`Error fetching guild owner to send message: ${e}`);
|
||||||
await message.reply("I was unable to send the DM.");
|
});
|
||||||
console.error(`Error sending DM message: ${e}`);
|
await guildOwner.createDM().then(async dm => {
|
||||||
});
|
await dm.send(args.join(" ")).catch(async e => {
|
||||||
}).catch(async e => {
|
await message.reply("I was unable to send the DM.");
|
||||||
await message.reply("I was unable to create the DM.");
|
console.error(`Error sending DM message: ${e}`);
|
||||||
console.error(`Error creating DM to send message: ${e}`);
|
});
|
||||||
const channel = await guild.channels.fetch(guildInfo.reminderChannelId).catch(async e => {
|
}).catch(async e => {
|
||||||
await message.reply("I was unable to fetch the channel.");
|
await message.reply("I was unable to create the DM.");
|
||||||
console.error(`Error fetching channel to send message: ${e}`);
|
console.error(`Error creating DM to send message: ${e}`);
|
||||||
});
|
const channel = await guild.channels.fetch(guildInfo.reminderChannelId).catch(async e => {
|
||||||
await channel.send(args.join(" ")).catch(async e => {
|
await message.reply("I was unable to fetch the channel.");
|
||||||
await message.reply("I was unable to send the message.");
|
console.error(`Error fetching channel to send message: ${e}`);
|
||||||
console.error(`Error sending message: ${e}`);
|
});
|
||||||
});
|
await channel.send(args.join(" ")).catch(async e => {
|
||||||
});
|
await message.reply("I was unable to send the message.");
|
||||||
} else {
|
console.error(`Error sending message: ${e}`);
|
||||||
throw "Guild doesn't exist in database!";
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
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."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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)) {
|
||||||
await message.reply("Pong!");
|
try {
|
||||||
|
await message.reply("Pong!");
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
await message.reply(fn.builders.errorEmbed("There was an error running the command."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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) {
|
||||||
let servers = [];
|
if (fn.dotCommands.checkPermissions(this.permission, message.author.id)) {
|
||||||
const count = JSON.stringify(message.client.guilds.cache.size);
|
try {
|
||||||
servers.push("I'm currently in " + count + " servers.");
|
let servers = [];
|
||||||
const guilds = await message.client.guilds.cache;
|
const count = JSON.stringify(message.client.guilds.cache.size);
|
||||||
// await guilds.each(g => {
|
servers.push("I'm currently in " + count + " servers.");
|
||||||
// servers.push(g.name + "," + g.ownerId);
|
const guilds = await message.client.guilds.cache;
|
||||||
// });
|
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
24
dot-commands/setupview.js
Normal 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."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
main.js
2
main.js
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -247,9 +247,9 @@ const functions = {
|
|||||||
}
|
}
|
||||||
commandData.isCommand = true;
|
commandData.isCommand = true;
|
||||||
// Get the first part of the message, everything leading up to the final period
|
// Get the first part of the message, everything leading up to the final period
|
||||||
commandData.args = message.content.slice(0,finalPeriod).toLowerCase();
|
commandData.args = message.content.slice(0, finalPeriod).toLowerCase();
|
||||||
// Get the last part of the message, everything after the final period
|
// Get the last part of the message, everything after the final period
|
||||||
commandData.command = message.content.slice(finalPeriod).replace('.','').toLowerCase();
|
commandData.command = message.content.slice(finalPeriod).replace('.', '').toLowerCase();
|
||||||
commandData.author = `${message.author.username}#${message.author.discriminator}`;
|
commandData.author = `${message.author.username}#${message.author.discriminator}`;
|
||||||
return this.checkCommand(commandData);
|
return this.checkCommand(commandData);
|
||||||
},
|
},
|
||||||
@ -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: {
|
||||||
@ -762,7 +775,7 @@ const functions = {
|
|||||||
errorFlag = true;
|
errorFlag = true;
|
||||||
status = strings.error.noTakeRole;
|
status = strings.error.noTakeRole;
|
||||||
});
|
});
|
||||||
if(!errorFlag) status = strings.error.yesTakeRole;
|
if (!errorFlag) status = strings.error.yesTakeRole;
|
||||||
} else {
|
} else {
|
||||||
await functions.roles.giveRole(interaction.member, role).catch(e => {
|
await functions.roles.giveRole(interaction.member, role).catch(e => {
|
||||||
errorFlag = true;
|
errorFlag = true;
|
||||||
@ -824,7 +837,7 @@ const functions = {
|
|||||||
// Make sure guildInfo is what we expect, the watch channel isnt blank, and notifications are enabled
|
// Make sure guildInfo is what we expect, the watch channel isnt blank, and notifications are enabled
|
||||||
if (guildInfo instanceof GuildInfo && guildInfo.watchChannelId != "" && guildInfo.notificationsEnabled) {
|
if (guildInfo instanceof GuildInfo && guildInfo.watchChannelId != "" && guildInfo.notificationsEnabled) {
|
||||||
// Fetch the Guild
|
// Fetch the Guild
|
||||||
const guild = await client.guilds.fetch(guildInfo.guildId).catch(e => {throw "Attempted to fetch guild I'm no longer in."});
|
const guild = await client.guilds.fetch(guildInfo.guildId).catch(e => { throw "Attempted to fetch guild I'm no longer in." });
|
||||||
// Fetch the Channel
|
// Fetch the Channel
|
||||||
const channel = await guild.channels.fetch(guildInfo.watchChannelId);
|
const channel = await guild.channels.fetch(guildInfo.watchChannelId);
|
||||||
// Create the filter function
|
// Create the filter function
|
||||||
|
Loading…
Reference in New Issue
Block a user