Merge branch 'V12' into 'master'
V12 See merge request LoicBersier/DiscordBot!2
This commit is contained in:
commit
1e6e47c39b
31 changed files with 241 additions and 163 deletions
|
@ -16,10 +16,6 @@
|
|||
"error",
|
||||
"tab"
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"windows"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -4,11 +4,8 @@ node_modules
|
|||
node_modules\
|
||||
.vscode
|
||||
video.mp4
|
||||
json/autoresponse.json
|
||||
json/blacklist.json
|
||||
json/customresponse.json
|
||||
tag/*
|
||||
starboard/*
|
||||
tts.mp3
|
||||
ttsvc.mp3
|
||||
package.json
|
||||
starboard/487640086859743232.json
|
||||
|
|
|
@ -37,7 +37,7 @@ class TagCommand extends Command {
|
|||
|
||||
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
|
||||
if (err) {
|
||||
fs.writeFile(`./tag/${message.guild.id}.json`, `{'${trigger}':'${response}'}`, function (err) {
|
||||
fs.writeFile(`./tag/${message.guild.id}.json`, `{"${trigger}":"${response}"}`, function (err) {
|
||||
if (err) {
|
||||
|
||||
console.log(err);
|
||||
|
@ -49,7 +49,6 @@ class TagCommand extends Command {
|
|||
json = JSON.stringify(customresponse); //convert it back to json
|
||||
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||
if (err) {
|
||||
|
||||
return console.log(err);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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,7 +19,7 @@ class AdviceCommand extends Command {
|
|||
fetch('http://api.adviceslip.com/advice').then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
const adviceEmbed = new Discord.RichEmbed()
|
||||
const adviceEmbed = new MessageEmbed()
|
||||
.setColor('#ff9900')
|
||||
.setTitle(response.slip.slip_id)
|
||||
.setDescription(response.slip.advice);
|
||||
|
|
|
@ -21,6 +21,8 @@ class ClapCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message, args) {
|
||||
if (!args.text)
|
||||
return;
|
||||
let clap = args.text.replace(/ /g, ' 👏 ');
|
||||
message.delete();
|
||||
message.channel.send(`${clap} 👏`);
|
||||
|
|
|
@ -23,6 +23,8 @@ class EmotesayCommand extends Command {
|
|||
|
||||
async exec(message, args) {
|
||||
let text = args.text;
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
message.delete();
|
||||
let emojiArray = [];
|
||||
|
|
|
@ -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 {
|
||||
|
@ -11,7 +11,7 @@ class RedditCommand extends Command {
|
|||
args: [
|
||||
{
|
||||
id: 'sub',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
}
|
||||
],
|
||||
description: {
|
||||
|
@ -25,6 +25,8 @@ class RedditCommand extends Command {
|
|||
async exec(message, args) {
|
||||
let sub = args.sub;
|
||||
let i, a;
|
||||
if (!sub)
|
||||
return;
|
||||
|
||||
fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => {
|
||||
return response.json();
|
||||
|
@ -39,8 +41,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)
|
||||
|
|
|
@ -15,13 +15,15 @@ class SayCommand extends Command {
|
|||
description: {
|
||||
content: 'Repeat what you say but can also replace ',
|
||||
usage: '[text]',
|
||||
examples: ['[member] is a big [adverbs] [verb]']
|
||||
examples: ['[member] is a big [adverb] [verb]']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
let text = args.text;
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
// Load all the different files
|
||||
const verb = require('../../dictionary/verbs.json');
|
||||
|
|
|
@ -23,6 +23,8 @@ class SaydCommand extends Command {
|
|||
|
||||
async exec(message, args) {
|
||||
let text = args.text;
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
// Load all the different files
|
||||
const verb = require('../../dictionary/verbs.json');
|
||||
|
|
|
@ -12,7 +12,8 @@ class IdubbbzCommand extends Command {
|
|||
args: [
|
||||
{
|
||||
id: 'text',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
default: 'nigger fagget'
|
||||
},
|
||||
{
|
||||
id: 'image',
|
||||
|
|
|
@ -11,7 +11,8 @@ class IdubbbzPaintCommand extends Command {
|
|||
args: [
|
||||
{
|
||||
id: 'text',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
default: 'Perfection'
|
||||
},
|
||||
{
|
||||
id: 'image',
|
||||
|
|
|
@ -20,10 +20,10 @@ class AvatarCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message, args) {
|
||||
if (!args.user) // While these kind of statments work you really should use {}
|
||||
return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL}`);
|
||||
if (!args.user)
|
||||
return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL()}`);
|
||||
else
|
||||
return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL}`);
|
||||
return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL()}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
commands/utility/credit.js
Normal file
21
commands/utility/credit.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
|
||||
class creditCommand extends Command {
|
||||
constructor() {
|
||||
super('credit', {
|
||||
aliases: ['credit'],
|
||||
category: 'utility',
|
||||
description: {
|
||||
content: 'Show credits for the bot',
|
||||
usage: '(optional) [@user]',
|
||||
examples: ['', '@user']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message) {
|
||||
message.channel.send('Thanks to Tina the Cyclops girl#0064 for inspiring me making a bot,\nThanks to discord.js team for making discord.js\nThanks to 1computer1 for making discord-akairo and the help command');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = creditCommand;
|
|
@ -15,7 +15,7 @@ class InviteCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message) {
|
||||
message.channel.send('Check your dm')
|
||||
message.channel.send('Check your dm');
|
||||
return message.author.send(`You can add me from here: https://discordapp.com/oauth2/authorize?client_id=${this.client.user.id}&scope=bot&permissions=0\nYou can also join my support server over here: ${supportServer} come and say hi :)`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}`);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 = 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();
|
||||
|
||||
|
||||
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}**`,
|
||||
};
|
||||
|
||||
message.channel.send({ embed: addEmbed });
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const reload = require('auto-reload');
|
||||
|
||||
class StatsCommand extends Command {
|
||||
constructor() {
|
||||
|
@ -14,6 +16,13 @@ class StatsCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message) {
|
||||
const autoresponse = reload('../../json/autoresponse.json');
|
||||
let autoresponseStatus;
|
||||
if (autoresponse[message.channel.id] == undefined || autoresponse[message.channel.id] == 'disable')
|
||||
autoresponseStatus = 'disabled';
|
||||
else if (autoresponse[message.channel.id] == 'enable')
|
||||
autoresponseStatus = 'enabled';
|
||||
|
||||
let totalSeconds = (this.client.uptime / 1000);
|
||||
let days = Math.floor(totalSeconds / 86400);
|
||||
let hours = Math.floor(totalSeconds / 3600);
|
||||
|
@ -21,7 +30,21 @@ class StatsCommand extends Command {
|
|||
let minutes = Math.floor(totalSeconds / 60);
|
||||
let seconds = totalSeconds.toFixed(0) % 60;
|
||||
let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
|
||||
return message.channel.send(`Servers: \`${this.client.guilds.size}\`\nChannels: \`${this.client.channels.size}\`\nUsers: \`${this.client.users.size}\`\nBot uptime: \`${uptime}\``);
|
||||
const used = process.memoryUsage().heapUsed / 1024 / 1024;
|
||||
|
||||
const statsEmbed = new MessageEmbed()
|
||||
.setColor('#0099ff')
|
||||
.setTitle('Bot stats')
|
||||
.setAuthor('Haha yes')
|
||||
.addField('Servers', this.client.guilds.size, true)
|
||||
.addField('Channels', this.client.channels.size, true)
|
||||
.addField('Users', this.client.users.size, true)
|
||||
.addField('Uptime', uptime, true)
|
||||
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
|
||||
.addField('Autoresponse in this channel',autoresponseStatus,true)
|
||||
.setTimestamp();
|
||||
|
||||
return message.channel.send(statsEmbed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
@ -18,10 +18,13 @@ class taglistCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message) {
|
||||
let customresponse = reload(`../../tag/${message.guild.id}.json`);
|
||||
let count = Object.keys(customresponse).length;
|
||||
|
||||
|
||||
try {
|
||||
var customresponse = reload(`../../tag/${message.guild.id}.json`);
|
||||
var count = Object.keys(customresponse).length;
|
||||
} catch (err) {
|
||||
message.channel.send('An error has occured, do you have any tags on the server?');
|
||||
console.error(err);
|
||||
}
|
||||
await fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
|
@ -31,7 +34,7 @@ class taglistCommand extends Command {
|
|||
let json = JSON.stringify(data);
|
||||
json = json.replace(/[{}'\\]+/g, '');
|
||||
json = json.replace(/,+/g, '\n');
|
||||
const tagEmbed = new Discord.RichEmbed()
|
||||
const tagEmbed = new MessageEmbed()
|
||||
.setColor('#ff9900')
|
||||
.setTitle('Tags list')
|
||||
.setDescription(`Trigger:Response\n\n${json}`)
|
||||
|
@ -40,7 +43,6 @@ class taglistCommand extends Command {
|
|||
message.channel.send(tagEmbed);
|
||||
});
|
||||
|
||||
message.channel.send('An error has occured, do you have any tags on the server?');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
|
|
64
index.js
64
index.js
|
@ -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({
|
||||
|
||||
class hahaYesClient extends AkairoClient {
|
||||
constructor() {
|
||||
super({
|
||||
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`); }
|
||||
this.commandHandler = new CommandHandler(this, {
|
||||
directory: './commands/',
|
||||
prefix: prefix,
|
||||
commandUtil: true,
|
||||
commandUtilLifetime: 60000,
|
||||
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);
|
1
json/autoresponse.json
Normal file
1
json/autoresponse.json
Normal file
|
@ -0,0 +1 @@
|
|||
{}
|
1
json/starboard.json
Normal file
1
json/starboard.json
Normal file
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -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;
|
|
@ -4,7 +4,7 @@ class CommandBlockedListener extends Listener {
|
|||
constructor() {
|
||||
super('commandBlocked', {
|
||||
emitter: 'commandHandler',
|
||||
eventName: 'commandBlocked'
|
||||
event: 'commandBlocked'
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { Listener } = require('discord-akairo');
|
||||
const Discord = require('discord.js');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { statsChannel } = require('../config.json');
|
||||
|
||||
|
||||
|
@ -7,14 +7,14 @@ class guildCreateListener extends Listener {
|
|||
constructor() {
|
||||
super('guildCreate', {
|
||||
emitter: 'client',
|
||||
eventName: 'guildCreate'
|
||||
event: 'guildCreate'
|
||||
});
|
||||
}
|
||||
|
||||
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')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { Listener } = require('discord-akairo');
|
||||
const Discord = require('discord.js');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { statsChannel } = require('../config.json');
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ class guildCreateListener extends Listener {
|
|||
constructor() {
|
||||
super('guildDelete', {
|
||||
emitter: 'client',
|
||||
eventName: 'guildDelete'
|
||||
event: 'guildDelete'
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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')
|
||||
|
|
|
@ -4,20 +4,26 @@ const reactObject = require('../json/react.json');
|
|||
const imgResponseObject = require('../json/imgreply.json');
|
||||
const reload = require('auto-reload');
|
||||
|
||||
class MessageListener extends Listener {
|
||||
class messageListener extends Listener {
|
||||
constructor() {
|
||||
super('message', {
|
||||
emitter: 'client',
|
||||
eventName: 'message'
|
||||
event: 'message'
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message) {
|
||||
let autoresponse = reload('../json/autoresponse.json');
|
||||
let message_content = message.content.toLowerCase();
|
||||
let customresponse = reload(`../tag/${message.guild.id}.json`);
|
||||
|
||||
if (message.author.bot) return; {
|
||||
|
||||
// User autoresponse
|
||||
if(customresponse[message_content]) {
|
||||
message.channel.send(customresponse[message_content]);
|
||||
}
|
||||
|
||||
// If autoresponse is enable send the response
|
||||
if(autoresponse[message.channel.id] == 'enable') {
|
||||
// Reply with images as attachement
|
||||
|
@ -39,13 +45,8 @@ class MessageListener extends Listener {
|
|||
message.react('496028845967802378');
|
||||
}
|
||||
}
|
||||
let customresponse = reload(`../tag/${message.guild.id}.json`);
|
||||
// User autoresponse
|
||||
if(customresponse[message_content]) {
|
||||
message.channel.send(customresponse[message_content]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageListener;
|
||||
module.exports = messageListener;
|
|
@ -1,51 +1,57 @@
|
|||
const { Listener } = require('discord-akairo');
|
||||
const Discord = require('discord.js');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const reload = require('auto-reload');
|
||||
let messageID = require('../json/starboard.json');
|
||||
|
||||
class MessageReactionAddListener extends Listener {
|
||||
constructor() {
|
||||
super('messagereactionadd', {
|
||||
emitter: 'client',
|
||||
eventName: 'messageReactionAdd'
|
||||
event: 'messageReactionAdd'
|
||||
});
|
||||
}
|
||||
|
||||
async exec(reaction, message, client) {
|
||||
async exec(reaction) {
|
||||
let messageContent = reaction.message.content;
|
||||
let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`);
|
||||
|
||||
if (reaction.emoji.name === '🌟' && reaction.count === 4) {
|
||||
if (messageID.includes(reaction.message.id))
|
||||
return console.log('Message already in starboard!');
|
||||
|
||||
messageID.push(reaction.message.id);
|
||||
|
||||
let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`);
|
||||
const channel = this.client.channels.get(starboardChannel['starboard']);
|
||||
|
||||
const starEmbed = new Discord.RichEmbed()
|
||||
const starEmbed = new MessageEmbed()
|
||||
.setColor()
|
||||
.setDescription(messageContent)
|
||||
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
|
||||
.setTimestamp()
|
||||
.setTimestamp();
|
||||
|
||||
channel.send({ embed: starEmbed});
|
||||
return channel.send(`From: ${reaction.message.channel}\n${messageAttachments}`);
|
||||
return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`);
|
||||
}
|
||||
if (reaction.emoji.name === '✡' && reaction.count === 4) {
|
||||
let shameboardChannel = reload(`../starboard/${message.guild.id}.json`);
|
||||
const channel = client.channels.get(shameboardChannel['shameboard']);
|
||||
if (messageID.includes(reaction.message.id))
|
||||
return console.log('Message already in starboard!');
|
||||
|
||||
const starEmbed = new Discord.RichEmbed()
|
||||
messageID.push(reaction.message.id);
|
||||
|
||||
let shameboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`);
|
||||
const channel = this.client.channels.get(shameboardChannel['shameboard']);
|
||||
|
||||
const shameEmbed = new MessageEmbed()
|
||||
.setColor()
|
||||
.setDescription(messageContent)
|
||||
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
|
||||
.setTimestamp()
|
||||
.setTimestamp();
|
||||
|
||||
try {
|
||||
channel.send({ embed: starEmbed});
|
||||
await channel.send(messageAttachments);
|
||||
} catch(err) {
|
||||
console.error('There is no shameboard');
|
||||
channel.send({ embed: shameEmbed});
|
||||
return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageReactionAddListener;
|
26
listeners/ready.js
Normal file
26
listeners/ready.js
Normal 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;
|
31
package.json
31
package.json
|
@ -1,37 +1,32 @@
|
|||
{
|
||||
"name": "discordbot",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple discord bot made with discord.js and commando",
|
||||
"name": "hahayes",
|
||||
"version": "2.1.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"auto-reload": "^0.1.0",
|
||||
"canvas": "^2.2.0",
|
||||
"eslint": "^5.11.1",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"discord.js": "^11.4.2",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"discord-akairo": "^7.5.5",
|
||||
"eslint-plugin-node": "^8.0.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"discord-akairo": "github:1Computer1/discord-akairo#master",
|
||||
"discord.js": "github:discordjs/discord.js#master",
|
||||
"node-fetch": "^2.3.0",
|
||||
"reload-json": "^0.3.1",
|
||||
"superagent": "^4.1.0",
|
||||
"youtube-dl": "^1.12.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"devDependencies": {
|
||||
"eslint": "^5.11.1",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-node": "^8.0.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitlab.com/LoicBersier/DiscordBot.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/LoicBersier/DiscordBot/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/LoicBersier/DiscordBot#readme"
|
||||
"homepage": "https://gitlab.com/LoicBersier/DiscordBot#readme",
|
||||
"description": ""
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue