Added Undo command
This commit is contained in:
@@ -32,6 +32,7 @@ module.exports.loadCommands = function() {
|
||||
addCommand('Ping', 'ping', undefined, 'ping', 'returns round trip to discords servers', false, Commands.ping);
|
||||
addCommand('Cat', 'cat', undefined, 'cat', 'returns a picture of a cat', false, Commands.cat);
|
||||
addCommand('Dog', 'dog', undefined, 'dog', 'returns a picture of a dog', false, Commands.dog);
|
||||
addCommand('Undo', 'undo', undefined, 'undo', 'deletes last message sent by Jeffery from the channel the command was issued in', false, Commands.undo);
|
||||
|
||||
//rule commands
|
||||
addCommand('Rules', 'rules', undefined, 'rules', 'returns all the rules for the server the command was issued on', false, RuleCommands.rules);
|
||||
|
||||
@@ -51,3 +51,17 @@ module.exports.dog = async function(message, msg, args, discordclient) {
|
||||
em.setImage(output);
|
||||
message.channel.send(em);
|
||||
}
|
||||
|
||||
module.exports.undo = function (message, msg, args, discordclient) {
|
||||
message.channel.fetchMessages({ limit: 50 })
|
||||
.then((_messages) => {
|
||||
var messages = _messages.array();
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
if (messages[i].author.id === discordclient.user.id) {
|
||||
messages[i].delete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user