Skip to content

Commit 7eeaf60

Browse files
committed
🍻 Bioman rewritten using Akairo
Once again, it's a huge commit. Basically, it does the same thing than the 0.9.0 version but it now uses the framework Akairo. - Commando.js has been abandonned for Akairo (close #46, close #79) - Better code (close #54, close #72, close #74, close #77, close #78) - The Horsengel roulette game is now a npm package (close #69) - i18n is implemented using i18next (close #45, close #15) but not complete - New commands: `deafen`, `mute`, `undeafen`, `unban`, `unmute`
1 parent 846b989 commit 7eeaf60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1423
-933
lines changed

bioman.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

commands/admin/ban.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

commands/admin/kick.js

Lines changed: 0 additions & 90 deletions
This file was deleted.

commands/fun/gif.js

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
const commando = require('discord.js-commando');
2-
const config = require ('../../config.js');
3-
const richEmbed = require('../../util/richEmbedHelper.js');
1+
const { Command } = require('discord-akairo');
2+
const Discord = require('discord.js');
3+
const i18n = require('i18next');
4+
const config = require ('../../config.json');
45
const giphy = require('giphy-api')(config.giphyToken);
56

6-
module.exports = class GifCommand extends commando.Command {
7-
constructor(bot) {
8-
super(bot, {
9-
name: 'gif',
10-
group: 'fun',
11-
memberName: 'gif',
12-
description: 'Sends a random GIF depending on a keyword. If no keyword is indicated, a random GIF will be displayed.',
13-
throttling: {
14-
usages: config.throttlingUsages,
15-
duration: config.throttlingDuration
16-
},
17-
18-
args: [{
19-
key: 'keyword',
20-
label: 'keyword',
21-
prompt: 'Wich keyword do you want to use to search for a random GIF?',
22-
type: 'string',
23-
default: 'random'
24-
}]
7+
class GifCommand extends Command {
8+
constructor() {
9+
super('gif', {
10+
aliases: ['gif'],
11+
category: 'fun',
12+
args: [
13+
{
14+
id: 'keyword',
15+
default: 'random'
16+
}
17+
]
2518
});
2619
}
2720

28-
async run(msg, args) {
29-
const commander = msg.member;
21+
exec(msg, args) {
22+
const author = msg.member;
3023
const keyword = args.keyword;
3124

3225
giphy.random({
3326
tag: keyword,
3427
rating: config.gifRating,
3528
fmt: 'json'
3629
})
37-
.then(function(result) {
30+
.then(result => {
3831
if (Object.keys(result.data).length > 0) {
39-
console.log(`The GIF ${result.data.url} has been sent using the keyword: ${keyword}.`);
40-
if(config.richEmbed) {
41-
return msg.channel.send({embed: richEmbed.gif(commander.user, keyword, result.data.image_url, result.data.url)});
42-
} else {
43-
return msg.channel.send(`*${result.data.image_url} \n via **GIPHY** (${result.data.url})*`);
44-
}
32+
return msg.channel.send({embed: this.embed(author.user, keyword, result.data.image_url, result.data.url)});
4533
} else {
46-
console.log(`No GIF has been found using the keyword: ${keyword}.`);
47-
return msg.reply(`*No GIF has been found using the keyword: ${keyword}.*`);
34+
return msg.reply(`*${i18n.t('gif.noResult')}*`, { keyword });
4835
}
49-
}).catch(function() {
50-
console.log('*A problem has occured while the bot tried to fine a GIF.');
51-
return msg.reply(`*I believe that a server issue occured. Try again with the same keyword.*`);
36+
}).catch(() => {
37+
return msg.reply(`*${i18n.t('gif.error')}*`);
5238
});
53-
}
54-
};
39+
};
40+
41+
embed(author, keyword, image, link) {
42+
return new Discord.RichEmbed()
43+
.setTitle(i18n.t('gif.title'))
44+
.setAuthor(author.tag, author.displayAvatarURL)
45+
.setColor('RANDOM')
46+
.setFooter(i18n.t('gif.poweredBy'), 'https://pbs.twimg.com/profile_images/699676239620083713/WCUM0RqH_400x400.jpg')
47+
.setDescription(`${i18n.t('gif.originalLink')} ${link}`)
48+
.setImage(image)
49+
.addField('Keyword', keyword);
50+
};
51+
}
52+
53+
module.exports = GifCommand;

commands/fun/say.js

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,32 @@
1-
const commando = require('discord.js-commando');
2-
const config = require ('../../config.js');
1+
const { Command } = require('discord-akairo');
2+
const i18n = require('i18next');
3+
const config = require('../../config.json');
34

4-
module.exports = class SayCommand extends commando.Command {
5-
constructor(bot) {
6-
super(bot, {
7-
name: 'say',
8-
group: 'fun',
9-
memberName: 'say',
10-
description: 'Make Bioman say something.',
11-
throttling: {
12-
usages: config.throttlingUsages,
13-
duration: config.throttlingDuration
14-
},
15-
16-
args: [{
17-
key: 'sentence',
18-
label: 'sentence',
19-
prompt: 'What do you want me to say?',
20-
type: 'string'
21-
}]
5+
class SayCommand extends Command {
6+
constructor() {
7+
super('say', {
8+
aliases: ['say'],
9+
category: 'fun',
10+
args: [
11+
{
12+
id: 'sentence',
13+
match: 'content'
14+
}
15+
]
2216
});
2317
}
2418

25-
async run(msg, args) {
26-
const commander = msg.member;
19+
async exec(msg, args) {
2720
const bot = msg.guild.me;
2821
const sentence = args.sentence;
2922

30-
if (commander.hasPermission('SEND_TTS_MESSAGES')) {
31-
if (bot.hasPermission('SEND_TTS_MESSAGES')) {
32-
await msg.delete();
33-
await bot.setNickname('Biomane');
34-
console.log(`The member ${commander.user.tag} made Bioman says: "${sentence}"`);
35-
const message = await msg.channel.send(`${sentence}`, {tts: true});
36-
await message.delete();
37-
await bot.setNickname(config.name);
38-
msg.channel.send(`*${sentence}*`);
39-
return;
40-
} else {
41-
console.log(`Bioman couldn\'t sent a TTS message because he doesn't have the permission.`);
42-
return msg.reply('*I don\'t have the permission to speak.*');
43-
}
44-
} else {
45-
console.log(`The member ${commander.user.tag} tried to make Bioman say: "${sentence}".`);
46-
return msg.reply('*I don\'t have the right to repeat what you said.*');
47-
}
23+
await msg.delete();
24+
await bot.setNickname(i18n.t('say.botNamePronunciation'));
25+
const message = await msg.channel.send(`${sentence}`, {tts: true});
26+
await message.delete();
27+
await bot.setNickname(config.name);
28+
return msg.channel.send(`*${sentence}*`);
4829
}
49-
};
30+
}
31+
32+
module.exports = SayCommand;

0 commit comments

Comments
 (0)