Giphy Command

This commit is contained in:
Daniel Odendahl Jr
2017-05-25 22:24:35 +00:00
parent 56618b15e9
commit c030ad7b0d
8 changed files with 54 additions and 7 deletions
+2 -1
View File
@@ -65,7 +65,8 @@ module.exports = class BanCommand extends Command {
**Action:** Ban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
await modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
+2 -1
View File
@@ -64,7 +64,8 @@ module.exports = class KickCommand extends Command {
**Action:** Kick
**Reason:** ${reason}
`);
return modlogs.send({ embed });
await modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
+2 -1
View File
@@ -68,7 +68,8 @@ module.exports = class SoftbanCommand extends Command {
**Action:** Softban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
await modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
+2 -1
View File
@@ -59,7 +59,8 @@ module.exports = class UnbanCommand extends Command {
**Action:** Unban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
await modlogs.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
+2 -1
View File
@@ -60,6 +60,7 @@ module.exports = class WarnCommand extends Command {
**Action:** Warn
**Reason:** ${reason}
`);
return modlogs.send({ embed });
await modlogs.send({ embed });
return null;
}
};
+2 -1
View File
@@ -33,7 +33,8 @@ module.exports = class StarCommand extends Command {
.setDescription(message.content)
.setImage(message.attachments.first() ? message.attachments.first().url : null)
.setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A'));
return channel.send({ embed });
await channel.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
+41
View File
@@ -0,0 +1,41 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { GIPHY_KEY } = process.env;
module.exports = class GiphyCommand extends Command {
constructor(client) {
super(client, {
name: 'giphy',
group: 'search',
memberName: 'giphy',
description: 'Searches for GIFs with Giphy.',
args: [
{
key: 'query',
prompt: 'What would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, args) {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const { query } = args;
try {
const { body } = await snekfetch
.get('http://api.giphy.com/v1/gifs/search')
.query({
q: query,
api_key: GIPHY_KEY
});
if (!body.data.length) throw new Error('No Results.');
return msg.say({ files: [body.data[0].images.original.url] })
.catch(err => msg.say(`${err.name}: ${err.message}`));
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "21.1.4",
"version": "21.2.0",
"description": "A Discord Bot",
"main": "Shard.js",
"scripts": {