mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
cloop discord support
This commit is contained in:
parent
3780245861
commit
333b524f84
1 changed files with 76 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
function add(command, interval, bot) {
|
||||
const id = setInterval(() => bot.core.run(command), interval);
|
||||
|
||||
|
@ -14,9 +15,29 @@ function clear() {
|
|||
|
||||
bot.cloops = [];
|
||||
}
|
||||
function list(bot) {
|
||||
function list(bot, discord, channeldc) {
|
||||
const message = [];
|
||||
|
||||
if (discord) {
|
||||
for (const [id, cloop] of Object.entries(bot.cloops)) {
|
||||
message.push(id);
|
||||
message.push(' > ');
|
||||
message.push(`\`${cloop.command}\``);
|
||||
message.push(' - ');
|
||||
message.push(cloop.interval);
|
||||
message.push('\n');
|
||||
}
|
||||
|
||||
message.pop();
|
||||
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Cloops')
|
||||
.setDescription(message.join(''));
|
||||
channeldc.send({embeds: [Embed]});
|
||||
return;
|
||||
}
|
||||
|
||||
message.push({text: 'Cloops:', color: 'green'});
|
||||
message.push('\n');
|
||||
|
||||
|
@ -81,4 +102,58 @@ module.exports = {
|
|||
return;
|
||||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||
if (!bot.cloops) bot.cloops = [];
|
||||
|
||||
if (args[0]==='add') {
|
||||
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {
|
||||
if (args[2]) {
|
||||
if (!Number(args[1])) throw new SyntaxError('Invalid interval');
|
||||
add(args.slice(2).join(' '), args[1], bot);
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Cloop')
|
||||
.setDescription(`Added cloop \`${args.slice(2).join(' ')}\` with interval ${args[1]} to the cloops`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (args[0]==='list') {
|
||||
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {
|
||||
list(bot, true, channeldc);
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (args[0]==='remove') {
|
||||
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {
|
||||
remove(args[1]);
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Cloop')
|
||||
.setDescription(`Removed cloop \`${args[1]}\``);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (args[0]==='removeall') {
|
||||
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {
|
||||
clear();
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Cloop')
|
||||
.setDescription('Removed all looped commands');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
return;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue