mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Giphy Command
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ module.exports = class WarnCommand extends Command {
|
||||
**Action:** Warn
|
||||
**Reason:** ${reason}
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
await modlogs.send({ embed });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "21.1.4",
|
||||
"version": "21.2.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user