updated the change from discord v12 and akairo v8

This commit is contained in:
Supositware 2019-01-02 10:21:21 +01:00
parent d2d4fda926
commit bda3ea4765
13 changed files with 119 additions and 97 deletions

View file

@ -1,5 +1,5 @@
const { Command } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const fetch = require('node-fetch');
class AdviceCommand extends Command {
@ -19,8 +19,7 @@ class AdviceCommand extends Command {
fetch('http://api.adviceslip.com/advice').then((response) => {
return response.json();
}).then((response) => {
const adviceEmbed = new Discord.RichEmbed()
.setColor('#ff9900')
const adviceEmbed = new MessageEmbed() .setColor('#ff9900')
.setTitle(response.slip.slip_id)
.setDescription(response.slip.advice);

View file

@ -1,5 +1,5 @@
const { Command } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const fetch = require('node-fetch');
class RedditCommand extends Command {
@ -39,8 +39,7 @@ class RedditCommand extends Command {
}
if (response.data.children[i].data.over_18 == true)
return message.channel.send('No nsfw');
const redditEmbed = new Discord.RichEmbed()
.setColor('#ff9900')
const redditEmbed = new MessageEmbed() .setColor('#ff9900')
.setTitle(response.data.children[i].data.title)
.setImage(response.data.children[i].data.url)
.setURL('https://reddit.com' + response.data.children[i].data.permalink)

View file

@ -16,7 +16,7 @@ class PingCommand extends Command {
async exec(message) {
return message.util.reply('Pong!').then(sent => {
const timeDiff = (sent.editedAt || sent.createdAt) - (message.editedAt || message.createdAt);
const text = `🔂\u2000**RTT**: ${timeDiff} ms\n💟\u2000**Heartbeat**: ${Math.round(this.client.ping)} ms`;
const text = `🔂\u2000**PING**: ${timeDiff} ms`;
return message.util.reply(`Pong!\n${text}`);
});
}

View file

@ -1,4 +1,5 @@
const { Command } = require('discord-akairo');
const { MessageEmbed } = require('discord.js');
class ServerCommand extends Command {
constructor() {
@ -15,19 +16,17 @@ class ServerCommand extends Command {
}
async exec(message) {
const customresponse = require(`../tag/${message.guild.id}.json`);
const customresponse = require(`../../tag/${message.guild.id}.json`);
var count = Object.keys(customresponse).length;
const addEmbed = {
color: 0x0099ff,
title: 'Stats of the server',
thumbnail: {
url: `${message.guild.iconURL}`,
},
description: `Member: **${message.guild.memberCount}** \nChannel number: **${message.guild.channels.size}**\nGuild created at **${message.guild.createdAt}**\nOwner: **${message.guild.owner}**\nTag number: **${count}**`,
};
const addEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Stats of the server')
.setAuthor(message.author.username)
.setDescription(`Member: **${message.guild.memberCount}** \nChannel number: **${message.guild.channels.size}**\nGuild created at **${message.guild.createdAt}**\nOwner: **${message.guild.owner}**\nTag number: **${count}**`)
.setTimestamp();
message.channel.send({ embed: addEmbed });
}

View file

@ -1,5 +1,5 @@
const { Command } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const reload = require('auto-reload');
const fs = require('fs');
@ -31,8 +31,7 @@ class taglistCommand extends Command {
let json = JSON.stringify(data);
json = json.replace(/[{}'\\]+/g, '');
json = json.replace(/,+/g, '\n');
const tagEmbed = new Discord.RichEmbed()
.setColor('#ff9900')
const tagEmbed = new MessageEmbed() .setColor('#ff9900')
.setTitle('Tags list')
.setDescription(`Trigger:Response\n\n${json}`)
.setFooter(`You have ${count} tags on this server`);

View file

@ -1,5 +1,5 @@
const { Command } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const fetch = require('node-fetch');
const { yandexAPI } = require('../../config.json');
@ -8,11 +8,13 @@ class TranslationCommand extends Command {
super('translation', {
aliases: ['translation', 'trn'],
category: 'utility',
split: 'sticky',
args: [
{
id: 'language',
type: 'string',
type: ['az','ml','sq','mt','am','mk','en','mi','ar','mr','hy','mhr','af','mn','eu','de','ba','ne','be','no','bn','pa','my','pap','bg','fa','bs','pl','cy','pt','hu','ro','vi','ru','ht','ceb','gl','sr','nl','si','mrj','sk','el','sl','ka','sw','gu','su','da','tg','he','th','yi','tl','id','ta','ga','tt','it','te','is','tr','es','udm','kk','uz','kn','uk','ca','ur','ky','fi','zh','fr','ko','hi','xh','hr','km','cs','lo','sv','la','gd','lv','et','lt','eo','lb','jv','mg','ja','ms'],
prompt: {
retry: 'That\'s not a valid language! try again.'
},
default: 'en'
},
{
@ -23,7 +25,7 @@ class TranslationCommand extends Command {
description: {
content: 'Translate what you send in your desired language. You can find the language code here: https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/',
usage: '[language code] [Text to translate]',
examples: ['fr What are we doing today?', 'en Que faisons-nous aujourd\'hui?']
examples: ['fr "What are we doing today?"', 'en "Que faisons-nous aujourd\'hui?"']
}
});
}
@ -43,7 +45,7 @@ class TranslationCommand extends Command {
return message.channel.send('An error has occured');
const translationEmbed = new Discord.RichEmbed()
const translationEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Asked for the following translation:')
.setAuthor(message.author.username)

View file

@ -1,4 +1,5 @@
const { Command } = require('discord-akairo');
const { MessageEmbed } = require('discord.js');
class UpdootCommand extends Command {
constructor() {
@ -15,17 +16,14 @@ class UpdootCommand extends Command {
}
async exec(message) {
const upDoot = {
color: 0x93C54B,
title: 'Vote for my bot',
url: 'https://discordbots.org/bot/377563711927484418/vote',
description: 'You can vote for my bot if you think the bot is awesome!',
timestamp: new Date(),
footer: {
text: 'Thanks for the updoots',
icon_url: 'https://cdn.discordapp.com/avatars/377563711927484418/1335d202aa466dbeaa4ed2e4b616484a.png?size=2048',
},
};
const upDoot = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Vote for my bot')
.setURL('https://discordbots.org/bot/377563711927484418/vote')
.setAuthor(message.author.username)
.setDescription('You can vote for my bot if you think the bot is awesome!')
.setTimestamp()
.setFooter('Thanks for the updoots', 'https://cdn.discordapp.com/avatars/377563711927484418/1335d202aa466dbeaa4ed2e4b616484a.png?size=2048');
message.channel.send({ embed: upDoot });
}

View file

@ -1,33 +1,49 @@
const { AkairoClient } = require('discord-akairo');
const { token, prefix, ownerID, statsChannel } = require('./config.json');
const { AkairoClient, CommandHandler, InhibitorHandler, ListenerHandler } = require('discord-akairo');
const { token, prefix, ownerID } = require('./config.json');
const client = new AkairoClient({
ownerID: ownerID,
prefix: prefix,
allowMention: true,
handleEdits: true,
emitters: {
process
},
commandUtil: true,
commandUtilLifetime: 600000,
commandDirectory: './commands/',
inhibitorDirectory: './inhibitors/',
listenerDirectory: './listeners/'
}, {
disableEveryone: true
});
// Ready messages dosent work on the listeners event for some reasons
client.on('ready', async () => {
// Send stats to the console
console.log(`\x1b[32mLogged in as \x1b[34m${client.user.tag}\x1b[0m! (\x1b[33m${client.user.id}\x1b[0m)`);
console.log(`Ready to serve in \x1b[33m${client.channels.size}\x1b[0m channels on \x1b[33m${client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${client.users.size}\x1b[0m users. \x1b${client.readyAt}\x1b[0m`);
// Send stats to the 'stats' channel in the support server if its not the test bot
if (client.user.id == 377563711927484418) {
const channel = client.channels.get(statsChannel);
channel.send(`Ready to serve in ${client.channels.size} channels on ${client.guilds.size} servers, for a total of ${client.users.size} users. ${client.readyAt}`);
client.user.setActivity(`${prefix} feedback <feedback> to tell me what you think of the bot! | ${prefix} help`); }
});
class hahaYesClient extends AkairoClient {
constructor() {
super({
ownerID: ownerID,
}, {
disableEveryone: true
});
this.commandHandler = new CommandHandler(this, {
directory: './commands/',
prefix: prefix,
commandUtil: true,
commandUtilLifetime: 600000,
allowMention: true,
handleEdits: true,
});
this.inhibitorHandler = new InhibitorHandler(this, {
directory: './inhibitors/',
emitters: {
process
},
});
this.listenerHandler = new ListenerHandler(this, {
directory: './listeners/'
});
this.listenerHandler.setEmitters({
commandHandler: this.commandHandler,
inhibitorHandler: this.inhibitorHandler,
listenerHandler: this.listenerHandler
});
this.commandHandler.useInhibitorHandler(this.inhibitorHandler);
this.commandHandler.useListenerHandler(this.listenerHandler);
this.listenerHandler.loadAll();
this.inhibitorHandler.loadAll();
this.commandHandler.loadAll();
}
}
const client = new hahaYesClient();
client.login(token);

View file

@ -1,16 +0,0 @@
const { Listener } = require('discord-akairo');
class UnhandledRejectionListener extends Listener {
constructor() {
super('unhandledRejection', {
eventName: 'unhandledRejection',
emitter: 'process'
});
}
exec(error) {
console.error(error);
}
}
module.exports = UnhandledRejectionListener;

View file

@ -1,5 +1,5 @@
const { Listener } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const { statsChannel } = require('../config.json');
@ -14,7 +14,7 @@ class guildCreateListener extends Listener {
async exec(guild) {
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`);
const channel = this.client.channels.get(statsChannel);
const addEmbed = new Discord.RichEmbed()
const addEmbed = new MessageEmbed()
.setColor('#52e80d')
.setTitle('Someone added me ! YAY :D')
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4')

View file

@ -1,5 +1,5 @@
const { Listener } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const { statsChannel } = require('../config.json');
@ -15,7 +15,7 @@ class guildCreateListener extends Listener {
console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`);
const channel = this.client.channels.get(statsChannel);
const kickEmbed = new Discord.RichEmbed()
const kickEmbed = new MessageEmbed()
.setColor('#FF0000')
.setTitle('They kicked me out :(')
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4')

View file

@ -1,5 +1,5 @@
const { Listener } = require('discord-akairo');
const Discord = require('discord.js');
const { MessageEmbed } = require('discord.js');
const reload = require('auto-reload');
class MessageReactionAddListener extends Listener {
@ -18,11 +18,11 @@ class MessageReactionAddListener extends Listener {
let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`);
const channel = this.client.channels.get(starboardChannel['starboard']);
const starEmbed = new Discord.RichEmbed()
.setColor()
.setDescription(messageContent)
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
.setTimestamp()
const starEmbed = new MessageEmbed()
.setColor()
.setDescription(messageContent)
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
.setTimestamp();
channel.send({ embed: starEmbed});
return channel.send(`From: ${reaction.message.channel}\n${messageAttachments}`);
@ -31,11 +31,11 @@ class MessageReactionAddListener extends Listener {
let shameboardChannel = reload(`../starboard/${message.guild.id}.json`);
const channel = client.channels.get(shameboardChannel['shameboard']);
const starEmbed = new Discord.RichEmbed()
.setColor()
.setDescription(messageContent)
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
.setTimestamp()
const starEmbed = new MessageEmbed()
.setColor()
.setDescription(messageContent)
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
.setTimestamp();
try {
channel.send({ embed: starEmbed});

26
listeners/ready.js Normal file
View file

@ -0,0 +1,26 @@
const { Listener } = require('discord-akairo');
const { prefix, statsChannel } = require('../config.json');
class ReadyListener extends Listener {
constructor() {
super('ready', {
emitter: 'client',
event: 'ready'
});
}
async exec() {
// Send stats to the console
console.log(`\x1b[32mLogged in as \x1b[34m${this.client.user.tag}\x1b[0m! (\x1b[33m${this.client.user.id}\x1b[0m)`);
console.log(`Ready to serve in \x1b[33m${this.client.channels.size}\x1b[0m channels on \x1b[33m${this.client.guilds.size}\x1b[0m servers, for a total of \x1b[33m${this.client.users.size}\x1b[0m users. \x1b${this.client.readyAt}\x1b[0m`);
// Send stats to the 'stats' channel in the support server if its not the test bot
if (this.client.user.id == 377563711927484418) {
const channel = this.client.channels.get(statsChannel);
channel.send(`Ready to serve in ${this.client.channels.size} channels on ${this.client.guilds.size} servers, for a total of ${this.client.users.size} users. ${this.client.readyAt}`);
this.client.user.setActivity(`${prefix} feedback <feedback> to tell me what you think of the bot! | ${prefix} help`);
}
}
}
module.exports = ReadyListener;