Switched to discord akairo

This commit is contained in:
Loic Bersier 2018-12-30 01:20:24 +01:00
parent 2fa0b76baf
commit 2fb624e265
73 changed files with 1212 additions and 1858 deletions

0
TODO
View file

View file

@ -1,4 +0,0 @@
module.exports = function blacklist(reasons, message){
return message.channel.send(`You have been blacklisted for the following reasons: **${reasons}**`)
}

View file

@ -1,46 +1,46 @@
const { Command } = require('discord.js-commando');
const blacklist = require('../../json/blacklist.json');
const fs = require('fs'); const fs = require('fs');
const { prefix } = require('../../config.json') const { Command } = require('discord-akairo');
module.exports = class AutoresponseCommand extends Command {
constructor(client) { class autoresponseCommand extends Command {
super(client, { constructor() {
name: 'autoresponse', super('autoresponse', {
group: 'admin', aliases: ['autoresponse'],
memberName: 'autoresponse', category: 'admin',
userPermissions: ['ADMINISTRATOR'],
description: `Can disable autoresponse in the channel (you can add "ALL" like this "${prefix} enable/disable all" to enable/disable in every channel (EXPERIMENTAL))`,
args: [ args: [
{ {
key: 'text', id: 'text',
prompt: 'Disable or enable?', type: 'string'
type: 'string',
oneOf: ['disable', 'enable','disable all', 'enable all'],
}, },
{ {
key: 'all', id: 'all',
prompt: 'Disable or enable in every channel? (EXPERIMENTAL)', type: 'string'
type: 'string',
oneOf: ['all', ''],
default: ''
} }
] ],
userPermissions: ['ADMINISTRATOR'],
channelRestriction: 'guild',
description: {
content: 'enable/disable autoresponse',
usage: '[enable/disable] (optional) [all]',
examples: ['enable all']
}
}); });
} }
async run(message, { text, all }) { async exec(message, args) {
if(blacklist[message.author.id]) let text = args.text;
return message.channel.send("You are blacklisted") let all = args.all;
let autoresponse = {} let autoresponse = {}
let json = JSON.stringify(autoresponse) let json = JSON.stringify(autoresponse)
if (all == 'all') { if (all == 'all') {
const guild = this.client.guilds.get(message.guild.id); const guild = this.client.guilds.get(message.guild.id);
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data){ fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data){
if (err){ if (err){
console.log(err); console.log(err);
} else { } else {
autoresponse = JSON.parse(data); //now it an object autoresponse = JSON.parse(data); //now it an object
guild.channels.forEach(channel => autoresponse [channel] = text) guild.channels.forEach(channel => autoresponse [channel] = text)
json = JSON.stringify(autoresponse); //convert it back to json json = JSON.stringify(autoresponse); //convert it back to json
@ -51,22 +51,22 @@ module.exports = class AutoresponseCommand extends Command {
} }
})}}); })}});
return message.say('Auto response have been disable/enable on every channel') return message.channel.send('Auto response have been disable/enable on every channel')
} else if(text == 'disable' || 'enable') {
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data){ } else if (text == 'disable' || 'enable') {
if (err){ fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data){
console.log(err); if (err){
} else { console.log(err);
autoresponse = JSON.parse(data); //now it an object } else {
autoresponse [message.channel.id] = text autoresponse = JSON.parse(data); //now it an object
json = JSON.stringify(autoresponse); //convert it back to json autoresponse [message.channel.id] = text
fs.writeFile('./json/autoresponse.json', json, 'utf8', function(err) { json = JSON.stringify(autoresponse); //convert it back to json
if(err) { fs.writeFile('./json/autoresponse.json', json, 'utf8', function(err) {
return console.log(err); if(err) {
} return console.log(err);
})}}); }
})}})};
return message.say(`Autoresponse have been ${text}d`); return message.channel.send(`Autoresponse have been ${text}d`);
} }}
} module.exports = autoresponseCommand;
};

View file

@ -1,48 +1,45 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const blacklist = require('../../json/blacklist.json');
module.exports = class BanCommand extends Command { class BanCommand extends Command {
constructor(client) { constructor() {
super(client, { super('ban', {
name: 'ban', aliases: ['ban'],
group: 'admin', category: 'admin',
memberName: 'ban', args: [
description: 'ban the mentionned user', {
guildOnly: true, id: 'member',
clientPermissions: ['BAN_MEMBERS'], type: 'member'
userPermissions: ['BAN_MEMBERS'], },
args: [ {
{ id: 'reasons',
key: 'member', type: 'string'
prompt: 'Wich member would you like to ban?', }
type: 'member', ],
}, clientPermissions: ['BAN_MEMBERS'],
{ userPermissions: ['BAN_MEMBERS'],
key: 'reasons', channelRestriction: 'guild',
prompt: 'What is the reasons of the kick', description: {
type: 'string', content: 'Ban user',
default: '' usage: '[@user]',
} examples: ['@user big dumb dumb']
] }
}); });
} }
async run(message, { member, reasons }) { async exec(message, args) {
let member = args.member;
let reasons = args.reasons;
if(member == this.client) if(member == this.client)
return message.say('Cant kick me fool') return message.channel.send('Cant ban me fool')
if(!reasons) if(!reasons)
reasons = 'Nothing have been specified' reasons = 'Nothing have been specified'
if(member.id === message.author.id) if(member.id === message.author.id)
return message.say("Why would you ban yourself ?") return message.channel.send("Why would you ban yourself ?")
try {
await member.send(`https://youtu.be/55-mHgUjZfY\nYou have been banned for the following reasons: "${reasons}"`)
} catch(err) {
console.error(`Could not dm the user, probably disabled\n${err}`)
}
member.ban(`Banned by : ${message.author.username} for the following reasons : ${reasons}`) member.ban(`Banned by : ${message.author.username} for the following reasons : ${reasons}`)
.then(() => message.reply(`${member.user.username} was succesfully banned with the following reasons "${reasons}".`)) .then(() => message.reply(`${member.user.username} was succesfully banned with the following reasons "${reasons}".`))
}
}
}; module.exports = BanCommand;
};

View file

@ -1,20 +0,0 @@
const { Command } = require('discord.js-commando');
const blacklist = require('../../json/blacklist.json');
module.exports = class cbCommand extends Command {
constructor(client) {
super(client, {
name: 'cb',
group: 'admin',
memberName: 'cb',
description: 'spam a bunch of dot to quickly make something disspear',
userPermissions: ['MANAGE_MESSAGES'],
guildOnly: true,
});
}
run(message) {
message.say('.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.')
}
};

View file

@ -1,42 +1,47 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const blacklist = require('../../json/blacklist.json');
module.exports = class KickCommand extends Command { class KickCommand extends Command {
constructor(client) { constructor() {
super(client, { super('kick', {
name: 'kick', aliases: ['kick'],
group: 'admin', category: 'admin',
memberName: 'kick', strip: 'none',
description: 'Kick the mentionned user', args: [
guildOnly: true, {
clientPermissions: ['KICK_MEMBERS'], id: 'member',
userPermissions: ['KICK_MEMBERS'], type: 'member'
args: [ },
{ {
key: 'member', id: 'reasons',
prompt: 'Wich member would you like to kick?', type: 'string'
type: 'member', }
}, ],
{ clientPermissions: ['KICK_MEMBERS'],
key: 'reasons', userPermissions: ['KICK_MEMBERS'],
prompt: 'What is the reasons of the kick', channelRestriction: 'guild',
type: 'string', description: {
default: '' content: 'Kick user',
} usage: '[@user]',
] examples: ['@user big dumb dumb']
}
}); });
} }
async run(message, { member, reasons }) { async exec(message, args) {
if(member == this.client) let member = args.member;
message.say('Cant kick me fool') let reasons = args.reasons;
if(!reasons)
reasons = 'Nothing have been specified.' if(member === this.client.user)
return message.channel.say('Cant kick me fool');
if(member.id === message.author.id) if(member.id === message.author.id)
return message.say("Why would you kick yourself ?") return message.channel.say("Why would you kick yourself ?");
await member.send(`You have been kicked for the following reasons: "${reasons}"`) if(!reasons)
.error(err => console.error(`Could not dm the user, probably disabled\n${err}`)) reasons = 'Nothing have been specified.';
member.kick(`Kicked by : ${message.author.username} for the following reasons : ${reasons}`)
await member.kick(`Kicked by : ${message.author.username} for the following reasons : ${reasons}`)
.then(() => message.reply(`${member.user.username} was succesfully kicked with the following reasons "${reasons}".`)) .then(() => message.reply(`${member.user.username} was succesfully kicked with the following reasons "${reasons}".`))
}; .catch(err => console.error(err))
}; }
}
module.exports = KickCommand;

View file

@ -1,32 +1,31 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const blacklist = require('../../json/blacklist.json');
module.exports = class PruneCommand extends Command { class PruneCommand extends Command {
constructor(client) { constructor() {
super(client, { super('Prune', {
name: 'prune', aliases: ['Prune'],
aliases: ['purge', 'clear', 'clean'], category: 'admin',
group: 'admin',
memberName: 'prune',
description: 'Bulk delete messages.',
clientPermissions: ['READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'],
userPermissions: ['MANAGE_MESSAGES'],
guildOnly: true,
args: [ args: [
{ {
key: 'amount', id: "amount",
prompt: 'How many messages would you like to delete? ( choose a number between 1 & 99 )', type: "string"
type: 'integer',
min: '1',
max: '99'
} }
] ],
clientPermissions: ['MANAGE_MESSAGES'],
userPermissions: ['MANAGE_MESSAGES'],
channelRestriction: 'guild',
description: {
content: 'Bulk delete messages',
usage: '[amount]',
examples: ['50']
}
}); });
} }
run(message, { amount }) { async exec(message,args) {
amount = amount+1 if (args.amount > 99) return;
message.channel.bulkDelete(amount, true); message.channel.bulkDelete(args.amount + 1, true);
} }
}; }
module.exports = PruneCommand;

View file

@ -1,51 +1,54 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
module.exports = class CustomResponseCommand extends Command { class PruneCommand extends Command {
constructor(client) { constructor() {
super(client, { super('Slowmode', {
name: 'slowmode', aliases: ['slowmode', 'slow'],
aliases: ['slow'], category: 'admin',
group: 'admin',
memberName: 'slowmode',
description: `Custom auto response`,
userPermissions: ['MANAGE_CHANNELS'],
clientPermissions: ['MANAGE_CHANNELS'],
args: [ args: [
{ {
key: 'slowmodeNumber', id: "slowmodeNumber",
prompt: 'How many seconds should the slowmode be? ( 0 to remove it )', type: "integer"
type: 'integer',
}, },
{ {
key: 'realtime', id: "realtime",
prompt: 'How long shoud it remain', type: "integer",
default: '', optional: true,
type: 'integer',
} }
] ],
clientPermissions: ['MANAGE_CHANNELS'],
userPermissions: ['MANAGE_CHANNELS'],
channelRestriction: 'guild',
description: {
content: 'Put a channel in slowmode',
usage: '[1-120 slowmode] [time it stays on]',
examples: ['267065637183029248']
}
}); });
} }
async run(message, { slowmodeNumber, realtime }) { async exec(message,args) {
let slowmodeNumber = args.slowmodeNumber;
let realtime = args.realtime;
if (slowmodeNumber > 120) if (slowmodeNumber > 120)
return message.say("Slowmode can only be set to 120 seconds or lower!"); return message.channel.send("Slowmode can only be set to 120 seconds or lower!");
message.channel.setRateLimitPerUser(slowmodeNumber); message.channel.setRateLimitPerUser(slowmodeNumber);
if (realtime) { if (realtime) {
let time = 60000 * realtime; let time = 60000 * realtime;
message.say(`Slowmode have been set to ${slowmodeNumber} seconds and will end in ${realtime} minutes!`); message.channel.send(`Slowmode have been set to ${slowmodeNumber} seconds and will end in ${realtime} minutes!`);
setTimeout (function (){ setTimeout (function (){
message.channel.setRateLimitPerUser(0); message.channel.setRateLimitPerUser(0);
return message.say("Slowmode is now disabled!") return message.channel.send("Slowmode is now disabled!")
}, time); }, time);
} else { } else {
if (slowmodeNumber == 0) if (slowmodeNumber == 0)
return message.say("Slowmode have been disabled!") return message.channel.send("Slowmode have been disabled!")
return message.say(`Slowmode have been set to ${slowmodeNumber} seconds!`); return message.channel.send(`Slowmode have been set to ${slowmodeNumber} seconds!`);
} }
}
}
module.exports = PruneCommand;
}
};

View file

@ -1,36 +1,36 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const blacklist = require('../../json/blacklist.json');
const fs = require('fs'); const fs = require('fs');
module.exports = class CustomResponseCommand extends Command { class TagCommand extends Command {
constructor(client) { constructor() {
super(client, { super('tag', {
name: 'tag', aliases: ['tag'],
aliases: ['customresponse'], category: 'admin',
group: 'admin', split: 'quoted',
memberName: 'tag',
description: `Custom auto response`,
userPermissions: ['MANAGE_MESSAGES'],
args: [ args: [
{ {
key: 'trigger', id: "trigger",
prompt: 'The word that will trigger the autoresponse (use "--" instead of spaces)', type: "string"
type: 'string',
}, },
{ {
key: 'response', id: "response",
prompt: 'The response to the word ( you can use spaces here )', type: "string"
type: 'string',
} }
] ],
channelRestriction: 'guild',
description: {
content: 'Create custom autoresponse',
usage: '[trigger] [response]',
examples: ['"do you know da wea" "Fuck off dead meme"']
}
}); });
} }
async run(message, { trigger, response }) { async exec(message, args) {
if(blacklist[message.author.id]) let trigger = args.trigger;
return message.channel.send("You are blacklisted") let response = args.response;
trigger = trigger.toLowerCase(); trigger = trigger.toLowerCase();
do { do {
trigger = trigger.replace('--', ' ') trigger = trigger.replace('--', ' ')
} while (trigger.includes('--')) } while (trigger.includes('--'))
@ -58,6 +58,8 @@ module.exports = class CustomResponseCommand extends Command {
} }
})}}); })}});
return message.say(`autoresponse have been set to ${trigger} : ${response}`); return message.channel.send(`autoresponse have been set to ${trigger} : ${response}`);
} }
}; }
module.exports = TagCommand;

View file

@ -1,28 +1,31 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const blacklist = require('../../json/blacklist.json');
module.exports = class UnbanCommand extends Command { class UnbanCommand extends Command {
constructor(client) { constructor() {
super(client, { super('unban', {
name: 'unban', aliases: ['unban'],
group: 'admin', category: 'admin',
memberName: 'unban', args: [
description: 'unban the provided id', {
guildOnly: true, id: 'member',
clientPermissions: ['BAN_MEMBERS'], type: 'user'
userPermissions: ['BAN_MEMBERS'], }
args: [ ],
{ clientPermissions: ['BAN_MEMBERS'],
key: 'member', userPermissions: ['BAN_MEMBERS'],
prompt: 'Wich member would you like to unban?', channelRestriction: 'guild',
type: 'user', description: {
} content: 'unban users',
] usage: '[user id]',
examples: ['267065637183029248']
}
}); });
} }
async run(message, { member }) { async exec(message, args) {
message.guild.unban(member) message.guild.unban(args.member)
.then(() => message.reply(`user was succesfully unbanned.`)); .then(() => message.reply(`user was succesfully unbanned.`));
}; }
}; }
module.exports = UnbanCommand;

View file

@ -1,48 +0,0 @@
const { Command } = require('discord.js-commando');
const blacklist = require('../../json/blacklist.json');
const fs = require('fs');
module.exports = class CustomResponseCommand extends Command {
constructor(client) {
super(client, {
name: 'untag',
aliases: ['rmcustomresponse'],
group: 'admin',
memberName: 'untag',
description: `remove custom autoresponse`,
userPermissions: ['MANAGE_MESSAGES'],
args: [
{
key: 'trigger',
prompt: 'What is the word to remove',
type: 'string',
}
]
});
}
async run(message, { trigger }) {
if(blacklist[message.author.id])
return message.channel.send("You are blacklisted")
trigger = trigger.toLowerCase();
let customresponse = {}
let json = JSON.stringify(customresponse)
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
if (err){
console.log(err);
} else {
customresponse = JSON.parse(data); //now it an object
delete customresponse[trigger]
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);
}
})}});
return message.say(`The following autoresponse have been deleted: ${trigger}`);
}
};

View file

@ -1,34 +0,0 @@
const { Command } = require('discord.js-commando');
const Discord = require('discord.js');
const fetch = require('node-fetch')
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class AdviceCommand extends Command {
constructor(client) {
super(client, {
name: 'advice',
group: 'fun',
memberName: 'advice',
description: `Show some random advice`,
});
}
async run(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
fetch("http://api.adviceslip.com/advice").then((response) => {
return response.json();
}).then((response) => {
const adviceEmbed = new Discord.RichEmbed()
.setColor("#ff9900")
.setTitle(response.slip.slip_id)
.setDescription(response.slip.advice)
message.say(adviceEmbed);
});
}};

View file

@ -1,35 +0,0 @@
const { Command } = require('discord.js-commando');
const fetch = require('node-fetch')
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class BadMemeCommand extends Command {
constructor(client) {
super(client, {
name: 'badmeme',
group: 'fun',
memberName: 'badmeme',
description: `Take random images from imgur`,
});
}
async run(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
fetch("https://api.imgur.com/3/gallery/hot/day?showViral=true&mature=false&perPage=100&album_previews=true", {
headers: { "Authorization": "Client-ID e4cb6948f80f295" },
}).then((response) => {
return response.json();
}).then((response) => {
if (response.success == 'false')
return message.say('An error has occured')
const i = Math.floor((Math.random() * response.data.length));
message.say(`**${response.data[i].title}**`)
message.say(response.data[i].link);
});
}};

View file

@ -1,30 +0,0 @@
const { Command } = require('discord.js-commando');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class clapCommand extends Command {
constructor(client) {
super(client, {
name: 'clap',
group: 'fun',
memberName: 'clap',
description: `Repeat the text you send with clap`,
args: [
{
key: 'text',
prompt: 'What do you want me to say',
type: 'string',
}
]
});
}
async run(message, { text }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let clap = text.replace(/ /g, ' 👏 ');
message.delete();
message.say(`${clap} 👏`);
}};

View file

@ -1,25 +0,0 @@
const { Command } = require('discord.js-commando');
const responseObject = require("../../json/randVid.json");
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class dankCommand extends Command {
constructor(client) {
super(client, {
name: 'dank',
group: 'fun',
memberName: 'dank',
description: `send some random dank vid (yea sorry for that name). There is currently **${Object.keys(responseObject).length}** vid`,
});
}
async run(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
const number = Object.keys(responseObject).length;
const vidNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
message.channel.send(`${vidNumber}: ${responseObject[vidNumber]}`);
}
};

View file

@ -1,59 +0,0 @@
const { Command } = require('discord.js-commando');
const responseObject = require("../../json/despacito.json");
const { createCanvas, loadImage, getContext } = require('canvas')
const superagent = require('superagent')
const Discord = require('discord.js');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class DespacitoCommand extends Command {
constructor(client) {
super(client, {
name: 'despacito',
group: 'fun',
memberName: 'despacito',
description: `despacito`,
args: [
{
key: 'user',
prompt: 'What do you want me to say',
type: 'user',
default: ''
}
]
});
}
async run(message, { user }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
if (!user) {
const number = Object.keys(responseObject).length;
const despacitoNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
return message.channel.send({files: [responseObject[despacitoNumber]]}).catch(error => {
message.say('an error as occured')
})
} else if (user.id === this.client.user.id) {
return message.say('Nice try but you wont get me :^)');
} else {
const canvas = createCanvas(660, 660);
const ctx = canvas.getContext('2d');
const background = await loadImage(user.avatarURL);
ctx.drawImage(background, 5, 12, canvas.width, canvas.height);
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/6/1539381851-untitled.png');
const bg = await loadImage(buffer);
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'despacito.png');
message.delete();
message.say(`${user.username}, you have been despacito'd`, attachment).catch(error => {
message.say('an error as occured')
})
}
}
};

View file

@ -1,36 +0,0 @@
const { Command } = require('discord.js-commando');
const emojiCharacters = require('../../emojiCharacters');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class emoteSayCommand extends Command {
constructor(client) {
super(client, {
name: 'emotesay',
group: 'fun',
memberName: 'emotesay',
description: `repeat the text in dancing letters`,
args: [
{
key: 'text',
prompt: 'What do you want me to say',
type: 'string',
}
]
});
}
async run(message, { text }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
message.delete();
let emojiArray = [];
for (let i = 0; i < text.length; i++)
emojiArray[i] = emojiCharacters[text.toLowerCase().split('')[i]];
message.say(emojiArray.join(""))
}
};

View file

@ -1,25 +0,0 @@
const { Command } = require('discord.js-commando');
const responseObject = require("../../json/funfact.json");
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class FunFactCommand extends Command {
constructor(client) {
super(client, {
name: 'funfact',
group: 'fun',
memberName: 'funfact',
description: `Send some fun fact. If you would like to see some of yours fun fact you can send them to @Supositware | Baguette#8211. There is currently **${Object.keys(responseObject).length}** fun fact.`,
});
}
async run(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
const number = Object.keys(responseObject).length;
const funFactNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
message.channel.send(`Fun fact: ${responseObject[funFactNumber]}`);
}
};

View file

@ -1,26 +0,0 @@
const { Command } = require('discord.js-commando');
const fetch = require('node-fetch')
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class BadMemeCommand extends Command {
constructor(client) {
super(client, {
name: 'ib',
aliases: ['inspirobot'],
group: 'fun',
memberName: 'ib',
description: `Return a random inspiration from inspirobot`,
});
}
async run(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
fetch('http://inspirobot.me/api?generate=true')
.then(res => res.text())
.then(body => message.channel.send({files: [body]}))
}}

View file

@ -1,45 +0,0 @@
const { Command } = require('discord.js-commando');
const printer = require('printer');
const { printChannel } = require('../../config.json');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class printCommand extends Command {
constructor(client) {
super(client, {
name: 'print',
aliases: ['dundermifflin', 'wastedevinkandmoney'],
group: 'fun',
memberName: 'print',
description: 'print whatever you want using the dev printer ! ( yea really, send a feedback requesting the image and i\'il send it to you. )',
throttling: {
usages: 1,
duration: 86400,
},
args: [
{
key: 'text',
prompt: 'What do you want to print? ( text only )',
type: 'string',
}
]
});
}
async run(message, { text }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
const channel = this.client.channels.get(printChannel);
printer.printDirect({data:`Printed by: ${message.author.username}\n\n${text}`
, type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
, success:function(jobID){
console.log("sent to printer with ID: "+jobID);
message.say("Printing now! ( You will receive your print shortly ( if the dev isint sleeping that is ))");
channel.send(`${message.author.username} (${message.author.id}) Asked for a print with the following text: ${text}`);
}
, error:function(err){console.log(err); message.say("An error has occured, the printer is most likely disconnected, try again later")}
});
}
};

View file

@ -1,56 +0,0 @@
const { Command } = require('discord.js-commando');
const Discord = require('discord.js');
const fetch = require('node-fetch');
const SelfReloadJSON = require('self-reload-json');
const { prefix } = require('../../config.json')
const blacklist = require('../../json/blacklist.json');
module.exports = class redditCommand extends Command {
constructor(client) {
super(client, {
name: 'reddit',
group: 'fun',
memberName: 'reddit',
description: `Show a random images from the subreddit you choose`,
args: [
{
key: 'sub',
prompt: 'Wich subreddit would you like to see?',
type: 'string',
}
]
});
}
async run(message, { sub }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let /* the bodies hit the */ i = Math.floor((Math.random() * 10) + 1);
let a = 0
fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => {
return response.json();
}).then((response) => {
if (!response.data)
return message.say('Not a valid subreddit')
while (response.data.children[i].data.post_hint !== 'image') {
i = Math.floor((Math.random() * response.data.children.length));
a++
if (a == 5)
return message.say("Could not find any images")
}
if (response.data.children[i].data.over_18 == true)
return message.say(`No nsfw ( if you want a nsfw version of this commands use the feedback commands "${prefix} feedback <your feedback>")`)
const redditEmbed = new Discord.RichEmbed()
.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)
.setFooter(`${response.data.children[i].data.ups} 💬 ${response.data.children[i].data.num_comments}`)
message.say(redditEmbed);
}
)}}

View file

@ -1,58 +0,0 @@
const { Command } = require('discord.js-commando');
const textToSpeech = require('@google-cloud/text-to-speech');
const gclient = new textToSpeech.TextToSpeechClient();
const SelfReloadJSON = require('self-reload-json');
const fs = require('fs');
const blacklist = require('../../json/blacklist.json');
module.exports = class BadMemeCommand extends Command {
constructor(client) {
super(client, {
name: 'tts',
group: 'fun',
memberName: 'tts',
description: `Return what you type in a tts file`,
args: [
{
key: 'text',
prompt: 'What do you want to be said',
type: 'string',
}
]
});
}
async run(message, { text }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
// Construct the request
const request = {
input: {text: text},
// Select the language and SSML Voice Gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// Select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};
// Performs the Text-to-Speech request
gclient.synthesizeSpeech(request, (err, response) => {
if (err) {
console.error('ERROR:', err);
return;
}
// Write the binary audio content to a local file
fs.writeFile('tts.mp3', response.audioContent, 'binary', err => {
if (err) {
console.error('ERROR:', err);
message.say('An error has occured, the message is probably too long')
return;
}
console.log('Audio content written to file: tts.mp3');
message.say({files: ['./tts.mp3']})
});
});
}}

View file

@ -0,0 +1,33 @@
const { Command } = require('discord-akairo');
const Discord = require('discord.js');
const fetch = require('node-fetch');
class AdviceCommand extends Command {
constructor() {
super('advice', {
aliases: ['advice'],
category: 'general',
description: {
content: 'Send some random advices',
usage: '',
examples: ['']
}
});
}
async exec(message) {
fetch("http://api.adviceslip.com/advice").then((response) => {
return response.json();
}).then((response) => {
const adviceEmbed = new Discord.RichEmbed()
.setColor("#ff9900")
.setTitle(response.slip.slip_id)
.setDescription(response.slip.advice)
message.channel.send(adviceEmbed);
})}
}
module.exports = AdviceCommand;

View file

@ -0,0 +1,33 @@
const { Command } = require('discord-akairo');
const fetch = require('node-fetch')
class ImgurCommand extends Command {
constructor() {
super('imgur', {
aliases: ['badmeme', 'imgur'],
category: 'general',
description: {
content: 'Send some random images from imgur',
usage: '',
examples: ['']
}
});
}
async exec(message) {
fetch("https://api.imgur.com/3/gallery/hot/day?showViral=true&mature=false&perPage=100&album_previews=true", {
headers: { "Authorization": "Client-ID e4cb6948f80f295" },
}).then((response) => {
return response.json();
}).then((response) => {
if (response.success == 'false')
return message.channel.send('An error has occured')
const i = Math.floor((Math.random() * response.data.length));
message.channel.send(`**${response.data[i].title}**\n${response.data[i].link}`);
});
}
}
module.exports = ImgurCommand;

30
commands/general/clap.js Normal file
View file

@ -0,0 +1,30 @@
const { Command } = require('discord-akairo');
class ClapCommand extends Command {
constructor() {
super('clap', {
aliases: ['clap'],
category: 'general',
split: 'none',
args: [
{
id: "text",
type: "string"
}
],
description: {
content: 'replace 👏 the 👏 spaces 👏 with 👏 clap 👏',
usage: '[text]',
examples: ['replace the spaces with clap']
}
});
}
async exec(message, args) {
let clap = args.text.replace(/ /g, ' 👏 ');
message.delete();
message.channel.send(`${clap} 👏`);
}
}
module.exports = ClapCommand;

View file

@ -0,0 +1,35 @@
const { Command } = require('discord-akairo');
const emojiCharacters = require('../../emojiCharacters');
class EmotesayCommand extends Command {
constructor() {
super('emotesay', {
aliases: ['emotesay', 'esay'],
category: 'general',
split: 'none',
args: [
{
id: "text",
type: "string"
}
],
description: {
content: 'Replace the text you send with dancing letters',
usage: '[text]',
examples: ['Hello']
}
});
}
async exec(message, args) {
let text = args.text;
message.delete();
let emojiArray = [];
for (let i = 0; i < text.length; i++)
emojiArray[i] = emojiCharacters[text.toLowerCase().split('')[i]];
message.channel.send(emojiArray.join(""))
}
}
module.exports = EmotesayCommand;

23
commands/general/ib.js Normal file
View file

@ -0,0 +1,23 @@
const { Command } = require('discord-akairo');
const fetch = require('node-fetch');
class InspiroBotCommand extends Command {
constructor() {
super('InspiroBot', {
aliases: ['inspirobot', 'ib'],
category: 'general',
description: {
content: 'Send images from Inspirobot',
usage: '',
examples: ['']
}
});
}
async exec(message) {
fetch('http://inspirobot.me/api?generate=true')
.then(res => res.text())
.then(body => message.channel.send({files: [body]}))
}
}
module.exports = InspiroBotCommand;

View file

@ -0,0 +1,52 @@
const { Command } = require('discord-akairo');
const fetch = require('node-fetch');
class RedditCommand extends Command {
constructor() {
super('reddit', {
aliases: ['reddit'],
category: 'general',
split: 'none',
args: [
{
id: 'sub',
type: 'string'
}
],
description: {
content: 'Send random images from the subreddit you choose',
usage: '[subreddit]',
examples: ['2meirl4meirl']
}
});
}
async exec(message, args) {
let sub = args.sub;
fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => {
return response.json();
}).then((response) => {
if (!response.data)
return message.channel.send('Not a valid subreddit')
while (response.data.children[i].data.post_hint !== 'image') {
i = Math.floor((Math.random() * response.data.children.length));
a++
if (a == 5)
return message.channel.send("Could not find any images")
}
if (response.data.children[i].data.over_18 == true)
return message.channel.send(`No nsfw ( if you want a nsfw version of this commands use the feedback commands "${prefix} feedback <your feedback>")`)
const redditEmbed = new Discord.RichEmbed()
.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)
.setFooter(`${response.data.children[i].data.ups} 💬 ${response.data.children[i].data.num_comments}`)
message.channel.send(redditEmbed);
})
}
}
module.exports = RedditCommand;

View file

@ -1,32 +1,31 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class sayCommand extends Command { class SayCommand extends Command {
constructor(client) { constructor() {
super(client, { super('say', {
name: 'say', aliases: ['say'],
aliases: ['repeat'], category: 'general',
group: 'fun', split: 'none',
memberName: 'say', args: [
description: `Repeat the text you send ( can also use [verb] [noun] [adverbs] [adjective] [activities] [celebrities] [countries] [diseases] [elements] [hobbies] [music] [prefixes] [pronoun] [state] [title] [unit] [member] [number] to replace it with something else )`, {
args: [ id: 'text',
{ type: 'string',
key: 'text', }
prompt: 'What do you want me to say', ],
type: 'string', description: {
} content: 'Repeat what you say but can also replace ',
] usage: '[text]',
examples: ['[member] is a big [adverbs] [verb]']
}
}); });
} }
async run(message, { text }) { async exec(message, args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); let text = args.text;
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
if (!text) return;
// Load all the different files // Load all the different files
const verb = require('../../dictionary/verbs.json') const verb = require('../../dictionary/verbs.json')
const noun = require('../../dictionary/noun.json') const noun = require('../../dictionary/noun.json')
const adverbs = require('../../dictionary/adjectives.json') const adverbs = require('../../dictionary/adjectives.json')
@ -75,6 +74,8 @@ module.exports = class sayCommand extends Command {
} while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]')) } while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]'))
// Send the final text // Send the final text
message.say(text); return message.channel.send(text);
} }
}; }
module.exports = SayCommand;

View file

@ -1,32 +1,30 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class saydCommand extends Command { class SayCommand extends Command {
constructor(client) { constructor() {
super(client, { super('sayd', {
name: 'sayd', aliases: ['sayd'],
aliases: ['repeatd'], category: 'general',
group: 'fun', split: 'none',
memberName: 'sayd', clientPermissions: 'MANAGE_MESSAGES',
description: `Repeat the text you send and delete it after ward( can also use [verb] [noun] [adverbs] [adjective] [activities] [celebrities] [countries] [diseases] [elements] [hobbies] [music] [prefixes] [pronoun] [state] [title] [unit] [member] [number] to replace it with something else )`, args: [
args: [ {
{ id: 'text',
key: 'text', type: 'string'
prompt: 'What do you want me to say', }
type: 'string', ],
} description: {
] content: 'Repeat what you say but delete the text you sent',
usage: '[text]',
examples: ['[member] is a big [adverbs] [verb]']
}
}); });
} }
async run(message, { text }) { async exec(message, args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); let text = args.text;
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
// Load all the different files
// Load all the different files
const verb = require('../../dictionary/verbs.json') const verb = require('../../dictionary/verbs.json')
const noun = require('../../dictionary/noun.json') const noun = require('../../dictionary/noun.json')
const adverbs = require('../../dictionary/adjectives.json') const adverbs = require('../../dictionary/adjectives.json')
@ -74,9 +72,10 @@ module.exports = class saydCommand extends Command {
// Verify if it replaced everything // Verify if it replaced everything
} while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]')) } while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]'))
// Send the final text // Send the final text
message.delete(); message.delete();
message.say(text); return message.channel.send(text);
} }
}; }
module.exports = SayCommand;

56
commands/general/tts.js Normal file
View file

@ -0,0 +1,56 @@
const { Command } = require('discord-akairo');
const textToSpeech = require('@google-cloud/text-to-speech');
const gclient = new textToSpeech.TextToSpeechClient();
class TtsCommand extends Command {
constructor() {
super('tts', {
aliases: ['tts'],
category: 'general',
split: 'none',
args: [
{
id: 'text',
type: 'string'
}
],
description: {
content: 'Send a mp3 of what you wrote in tts',
usage: '[text]',
examples: ['hello']
}
});
}
async exec(message, args) {
// Construct the request
const request = {
input: {text: text},
// Select the language and SSML Voice Gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// Select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};
// Performs the Text-to-Speech request
gclient.synthesizeSpeech(request, (err, response) => {
if (err) {
console.error('ERROR:', err);
return;
}
// Write the binary audio content to a local file
fs.writeFile('tts.mp3', response.audioContent, 'binary', err => {
if (err) {
console.error('ERROR:', err);
message.channel.send('An error has occured, the message is probably too long')
return;
}
console.log('Audio content written to file: tts.mp3');
message.channel.send({files: ['./tts.mp3']})
});
});
}
}
module.exports = TtsCommand;

View file

@ -1,33 +1,28 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const textToSpeech = require('@google-cloud/text-to-speech'); const textToSpeech = require('@google-cloud/text-to-speech');
const gclient = new textToSpeech.TextToSpeechClient(); const gclient = new textToSpeech.TextToSpeechClient();
const SelfReloadJSON = require('self-reload-json');
const fs = require('fs');
const blacklist = require('../../json/blacklist.json');
class TtsvcCommand extends Command {
module.exports = class ttsvcCommand extends Command { constructor() {
constructor(client) { super('ttsvc', {
super(client, { aliases: ['ttsvc'],
name: 'ttsvc', category: 'general',
group: 'fun', split: 'none',
memberName: 'ttsvc',
description: `Play what you write in tts in vc`,
args: [ args: [
{ {
key: 'text', id: 'text',
prompt: 'What do you want to be said', type: 'string'
type: 'string',
} }
] ],
description: {
content: 'Say what you wrote in voice channel',
usage: '[text]',
examples: ['hello']
}
}); });
} }
async run(message, { text }) { async exec(message, args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
// Construct the request // Construct the request
const request = { const request = {
input: {text: text}, input: {text: text},
@ -73,4 +68,6 @@ module.exports = class ttsvcCommand extends Command {
}); });
}); });
}); });
}} }
}
module.exports = TtsvcCommand;

View file

@ -1,41 +1,36 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas') const { createCanvas, loadImage, getContext } = require('canvas');
const superagent = require('superagent') const superagent = require('superagent');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class FetishCommand extends Command {
constructor() {
super('fetish', {
module.exports = class fetishCommand extends Command { aliases: ['fetish'],
constructor(client) { category: 'images',
super(client, { args: [
name: 'fetish', {
group: 'images', id: 'image',
memberName: 'fetish', type: 'string'
description: `My fetish`, }
]
}); });
} }
async run(message) { async exec(message,args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
let image = null let image = args.image;
if (!Attachment[0]) if (!Attachment[0] && !image)
image = message.author.displayAvatarURL image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif')) else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry') return message.channel.send('Gif dosent work, sorry')
else else if (!image)
image = Attachment[0].url image = Attachment[0].url
const canvas = createCanvas(528, 559) const canvas = createCanvas(528, 559)
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/2/1539644291-my-fetish-5910119d988512.png').catch(error => { const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/2/1539644291-my-fetish-5910119d988512.png').catch(error => {
return message.say('An error as occured, please try again') return message.channel.send('An error as occured, please try again')
}) })
ctx.drawImage(background, 0, 0, canvas.width, canvas.height); ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
const { body: buffer } = await superagent.get(image); const { body: buffer } = await superagent.get(image);
@ -44,9 +39,11 @@ module.exports = class fetishCommand extends Command {
const attachment = new Discord.Attachment(canvas.toBuffer(), 'myfetish.png'); const attachment = new Discord.Attachment(canvas.toBuffer(), 'myfetish.png');
message.say(attachment).catch(error => {
message.say('an error as occured. Check the bot/channel permissions')
})
} message.channel.send(attachment).catch(() => {
}; message.channel.send('an error as occured. Check the bot/channel permissions')
})
}
}
module.exports = FetishCommand;

View file

@ -1,52 +1,46 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas') const { createCanvas, loadImage, getContext } = require('canvas');
const superagent = require('superagent') const superagent = require('superagent');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class GodCommand extends Command {
constructor() {
module.exports = class godCommand extends Command { super('god', {
constructor(client) { aliases: ['god'],
super(client, { category: 'images',
name: 'god',
group: 'images',
memberName: 'god',
description: `Retweet if you aren't afraid to have a picture of god on your timeline`,
}); });
} }
async run(message) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
let image = null let image = args.image;
if (!Attachment[0]) if (!Attachment[0] && !image)
image = message.author.displayAvatarURL image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif')) else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry') return message.channel.send('Gif dosent work, sorry')
else else if (!image)
image = Attachment[0].url image = Attachment[0].url
const canvas = createCanvas(310, 400) const canvas = createCanvas(310, 400)
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
const background = await loadImage(image); const background = await loadImage(image);
ctx.drawImage(background, 20, 80, 275, 250); ctx.drawImage(background, 20, 80, 275, 250);
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/42/1/1539555260-untitled.png').catch(error => { const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/42/1/1539555260-untitled.png').catch(() => {
return message.say('An error as occured, please try again') return message.channel.send('An error as occured, please try again')
}) })
const bg = await loadImage(buffer); const bg = await loadImage(buffer);
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'god.png'); const attachment = new Discord.Attachment(canvas.toBuffer(), 'god.png');
message.say(attachment).catch(error => { message.delete();
message.say('an error as occured. Check the bot/channel permissions') message.channel.send(attachment)
.catch(() => {
message.channel.send('an error as occured. Check the bot/channel permissions')
}) })
}
}
} module.exports = GodCommand;
};

View file

@ -1,52 +0,0 @@
const { Command } = require('discord.js-commando');
const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas')
const superagent = require('superagent')
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class humanCommand extends Command {
constructor(client) {
super(client, {
name: 'human',
group: 'images',
memberName: 'human',
description: `HUMAN ?! YOU DARE CALL THAT THING HUMAN?!?!`,
});
}
async run(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array();
let image = null
if (!Attachment[0])
image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry')
else
image = Attachment[0].url
const canvas = createCanvas(578, 400)
const ctx = canvas.getContext('2d')
const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/1/1539594726-untitled.png').catch(error => {
return message.say('An error as occured, please try again')
})
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
const { body: buffer } = await superagent.get(image);
const bg = await loadImage(buffer);
ctx.drawImage(bg, 420, 120, 150, 150);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'human.png');
message.say(attachment).catch(error => {
message.say('an error as occured. Check the bot/channel permissions')
})
}
};

View file

@ -1,45 +1,26 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas') const { createCanvas, loadImage, getContext } = require('canvas');
const superagent = require('superagent') const superagent = require('superagent');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class IdubbbzCommand extends Command {
constructor() {
super('idubbbz', {
module.exports = class idubbbzCommand extends Command { aliases: ['idubbbz', 'edups'],
constructor(client) { category: 'images',
super(client, {
name: 'idubbbz',
aliases: ['idubbz', 'edups'],
group: 'images',
memberName: 'idubbbz',
description: `Put the text you send in idubbbz piece of paper`,
args: [
{
key: 'text',
prompt: 'What do you the paper to say?',
type: 'string',
default: 'Nigger Faggot'
}
]
}); });
} }
async run(message, { text }) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
let image = null let image = args.image;
if (!Attachment[0]) if (!Attachment[0] && !image)
image = message.author.displayAvatarURL image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif')) else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry') return message.channel.send('Gif dosent work, sorry')
else else if (!image)
image = Attachment[0].url image = Attachment[0].url
const canvas = createCanvas(1281, 627) const canvas = createCanvas(1281, 627)
const applyText = (canvas, text) => { const applyText = (canvas, text) => {
@ -61,7 +42,7 @@ module.exports = class idubbbzCommand extends Command {
const background = await loadImage(image); const background = await loadImage(image);
ctx.drawImage(background, 620, 100, 200, 200); ctx.drawImage(background, 620, 100, 200, 200);
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539510207-untitled.png').catch(error => { const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539510207-untitled.png').catch(error => {
return message.say('An error as occured, please try again') return message.channel.send('An error as occured, please try again')
}) })
const bg = await loadImage(buffer); const bg = await loadImage(buffer);
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
@ -71,9 +52,10 @@ module.exports = class idubbbzCommand extends Command {
const attachment = new Discord.Attachment(canvas.toBuffer(), 'edups.png'); const attachment = new Discord.Attachment(canvas.toBuffer(), 'edups.png');
message.say(attachment).catch(error => { message.channel.send(attachment).catch(error => {
message.say('an error as occured. Check the bot/channel permissions') message.channel.send('an error as occured. Check the bot/channel permissions')
}) })
}
}
} module.exports = IdubbbzCommand;
};

View file

@ -1,45 +1,25 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas') const { createCanvas, loadImage, getContext } = require('canvas');
const superagent = require('superagent') const superagent = require('superagent');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class IdubbbzPaintCommand extends Command {
constructor() {
super('idubbbzpaint', {
module.exports = class idubbbzpaintCommand extends Command { aliases: ['idubbbzpaint', 'edupspaint'],
constructor(client) { category: 'images',
super(client, {
name: 'idubbbzpaint',
aliases: ['idubbzpaint', 'edupspaint'],
group: 'images',
memberName: 'painting',
description: `Put the image you send or you in idubbbz painting`,
args: [
{
key: 'text',
prompt: 'What do you the paper to say?',
type: 'string',
default: 'Perfection'
}
]
}); });
} }
async run(message, { text }) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
let image = null let image = args.image;
if (!Attachment[0]) if (!Attachment[0] && !image)
image = message.author.displayAvatarURL image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif')) else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry') return message.channel.send('Gif dosent work, sorry')
else else if (!image)
image = Attachment[0].url image = Attachment[0].url
const canvas = createCanvas(1024, 544) const canvas = createCanvas(1024, 544)
const applyText = (canvas, text) => { const applyText = (canvas, text) => {
@ -61,7 +41,7 @@ module.exports = class idubbbzpaintCommand extends Command {
const background = await loadImage(image); const background = await loadImage(image);
ctx.drawImage(background, 140, 40, 400, 340); ctx.drawImage(background, 140, 40, 400, 340);
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539533685-untitled.png').catch(error => { const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539533685-untitled.png').catch(error => {
return message.say('An error as occured, please try again') return message.channel.send('An error as occured, please try again')
}) })
const bg = await loadImage(buffer); const bg = await loadImage(buffer);
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
@ -71,9 +51,10 @@ module.exports = class idubbbzpaintCommand extends Command {
const attachment = new Discord.Attachment(canvas.toBuffer(), 'edupspaint.png'); const attachment = new Discord.Attachment(canvas.toBuffer(), 'edupspaint.png');
message.say(attachment).catch(error => { message.channel.send(attachment).catch(error => {
message.say('an error as occured. Check the bot/channel permissions') message.channel.send('an error as occured. Check the bot/channel permissions')
}) })
}
}
} module.exports = IdubbbzPaintCommand;
};

View file

@ -1,51 +1,48 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas') const { createCanvas, loadImage, getContext } = require('canvas');
const superagent = require('superagent') const superagent = require('superagent');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class LikeCommand extends Command {
constructor() {
module.exports = class likeCommand extends Command { super('like', {
constructor(client) { aliases: ['like'],
super(client, { category: 'images',
name: 'like', args: [
group: 'images', {
memberName: 'like', id: 'image',
description: `What the hell is this and why did my grandsone like it`, type: 'string'
}
]
}); });
} }
async run(message) { async exec(message,args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
let image = null let image = args.image;
if (!Attachment[0]) if (!Attachment[0] && !image)
image = message.author.displayAvatarURL image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif')) else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry') return message.channel.send('Gif dosent work, sorry')
else else if (!image)
image = Attachment[0].url image = Attachment[0].url
const canvas = createCanvas(386, 399) const canvas = createCanvas(386, 399)
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
const background = await loadImage(image); const background = await loadImage(image);
ctx.drawImage(background, 40, 0, 300, 255); ctx.drawImage(background, 40, 0, 300, 255);
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539547403-untitled.png').catch(error => { const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/7/1539547403-untitled.png').catch(error => {
return message.say('An error as occured, please try again') return message.channel.send('An error as occured, please try again')
}) })
const bg = await loadImage(buffer); const bg = await loadImage(buffer);
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
const attachment = new Discord.Attachment(canvas.toBuffer(), 'like.png'); const attachment = new Discord.Attachment(canvas.toBuffer(), 'like.png');
message.say(attachment).catch(error => { message.channel.send(attachment).catch(error => {
message.say('an error as occured. Check the bot/channel permissions') message.channel.send('an error as occured. Check the bot/channel permissions')
}) })
}
}
} module.exports = LikeCommand;
};

View file

@ -1,40 +1,37 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const Discord = require('discord.js'); const Discord = require('discord.js');
const { createCanvas, loadImage, getContext } = require('canvas') const { createCanvas, loadImage, getContext } = require('canvas');
const superagent = require('superagent') const superagent = require('superagent');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class UglyCommand extends Command {
constructor() {
module.exports = class uglyCommand extends Command { super('ugly', {
constructor(client) { aliases: ['ugly'],
super(client, { category: 'images',
name: 'ugly', args: [
group: 'images', {
memberName: 'ugly', id: 'image',
description: `You are very ugly!`, type: 'string',
optional: true,
}
]
}); });
} }
async run(message) { async exec(message,args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
let image = null let image = args.image;
if (!Attachment[0]) if (!Attachment[0] && !image)
image = message.author.displayAvatarURL image = message.author.displayAvatarURL
else if(Attachment[0] && Attachment[0].url.endsWith('gif')) else if(Attachment[0] && Attachment[0].url.endsWith('gif'))
return message.say('Gif dosent work, sorry') return message.channel.send('Gif dosent work, sorry')
else else if (!image)
image = Attachment[0].url image = Attachment[0].url
const canvas = createCanvas(323, 400) const canvas = createCanvas(323, 400)
const ctx = canvas.getContext('2d') const ctx = canvas.getContext('2d')
const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/1/1539598678-untitled.png').catch(error => { const background = await loadImage('https://image.noelshack.com/fichiers/2018/42/1/1539598678-untitled.png').catch(error => {
return message.say('An error as occured, please try again') return message.channel.send('An error as occured, please try again')
}) })
ctx.drawImage(background, 0, 0, canvas.width, canvas.height); ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
const { body: buffer } = await superagent.get(image); const { body: buffer } = await superagent.get(image);
@ -43,9 +40,10 @@ module.exports = class uglyCommand extends Command {
const attachment = new Discord.Attachment(canvas.toBuffer(), 'ugly.png'); const attachment = new Discord.Attachment(canvas.toBuffer(), 'ugly.png');
message.say(attachment).catch(error => { message.channel.send(attachment).catch(error => {
message.say('an error as occured. Check the bot/channel permissions') message.channel.send('an error as occured. Check the bot/channel permissions')
}) })
}
}
} module.exports = UglyCommand;
};

View file

@ -1,50 +0,0 @@
const { Command } = require('discord.js-commando');
const fs = require('fs');
module.exports = class BlacklistCommand extends Command {
constructor(client) {
super(client, {
name: 'blacklist',
aliases: ['niggerlist'],
group: 'owner',
memberName: 'blacklist',
description: `To blacklist a user from the bot`,
ownerOnly: true,
args: [
{
key: 'user',
prompt: 'Who do you want to blacklist',
type: 'user',
},
{
key: 'reasons',
prompt: 'Who do you want to blacklist',
type: 'string',
default: 'Didin\'t provide any reasons'
}
]
});
}
async run(message, { user, reasons }) {
let blacklist = {}
let json = JSON.stringify(blacklist)
if(user) {
fs.readFile('json/blacklist.json', 'utf8', function readFileCallback(err, data){
if (err){
console.log(err);
} else {
blacklist = JSON.parse(data); //now it an object
blacklist [user] = reasons
json = JSON.stringify(blacklist); //convert it back to json
json = json.replace(/[<@!>]/g, '')
fs.writeFile('json/blacklist.json', json, 'utf8', function(err) {
if(err) {
return console.log(err);
}
})}});
return message.say(`User ${user} have been blacklisted`);
}
}
};

View file

@ -1,31 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class BotavatarCommand extends Command {
constructor(client) {
super(client, {
name: 'botavatar',
group: 'owner',
memberName: 'botavatar',
description: 'Change the avatar of the bot',
ownerOnly: true,
args: [
{
key: 'pic',
prompt: 'Wich avatar should i have?',
type: 'string',
default: ''
}
]
});
}
async run(message, { pic }) {
let Attachment = (message.attachments).array();
let image = null
if (!Attachment[0])
return message.say('You didint provide any images')
else
image = Attachment[0].url
this.client.user.setAvatar(image);
message.say('The avatar have been changed succesfully');
}
};

View file

@ -1,17 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class DedCommand extends Command {
constructor(client) {
super(client, {
name: 'ded',
aliases: ['shutdown', 'dead', 'restart', 'reboot'],
group: 'owner',
memberName: 'ded',
description: 'Reboot the bot',
ownerOnly: true,
});
}
async run(message) {
await message.say('k bye thx\nhttps://i.redd.it/lw8hrvr0l4f11.jpg');
process.exit();
}}

View file

@ -1,37 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class dmCommand extends Command {
constructor(client) {
super(client, {
name: 'dm',
group: 'owner',
memberName: 'dm',
aliases: ['pm'],
description: 'Dm the user id',
ownerOnly: true,
args: [
{
key: 'user',
prompt: 'Wich user would you like to dm?',
type: 'user',
},
{
key: 'text',
prompt: 'What do you want to say to the user',
type: 'string',
}
]
});
}
async run(message, { user, text }) {
let Attachment = (message.attachments).array();
if (Attachment[0]) {
user.send(`**Message from the dev:**\n${text}\n${Attachment[0].url}`)
message.say(`DM sent to ${user.username}`)
}
else {
user.send(`**Message from the dev:**\n${text}`)
message.say(`DM sent to ${user.username}`)
}
}
};

View file

@ -1,24 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class dmCommand extends Command {
constructor(client) {
super(client, {
name: 'emit',
group: 'owner',
memberName: 'emit',
aliases: ['event', 'emitevent'],
description: 'Trigger an event',
ownerOnly: true,
args: [
{
key: 'event',
prompt: 'Wich event do you want to trigger?',
type: 'string',
}
]
});
}
async run(message, { event }) {
this.client.emit(`${event}`);
}
};

46
commands/owner/eval.js Normal file
View file

@ -0,0 +1,46 @@
const { Command } = require('discord-akairo');
class EvalCommand extends Command {
constructor() {
super('eval', {
aliases: ['eval'],
split: 'none',
category: 'owner',
args: [
{
id: 'eval',
type: 'string'
}
],
ownerOnly: 'true',
description: {
content: 'Execute javascript',
usage: '[code]',
examples: ['message.channel.send(\'Hi\')']
}
});
}
async exec(message, args) {
const clean = text => {
if (typeof(text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
try {
const code = args.eval
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), {code:"xl"});
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
}
module.exports = EvalCommand;

View file

@ -1,24 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class StatusCommand extends Command {
constructor(client) {
super(client, {
name: 'status',
group: 'owner',
memberName: 'status',
description: 'Change the status of the bot',
ownerOnly: true,
args: [
{
key: 'status',
prompt: 'Wich status should i have?',
type: 'string',
}
]
});
}
async run(message, { status }) {
this.client.user.setActivity(status);
message.say(`Status have been set to ${status}`);
}
};

View file

@ -1,25 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class UsernameCommand extends Command {
constructor(client) {
super(client, {
name: 'username',
group: 'owner',
memberName: 'username',
description: 'Change the username of the bot',
ownerOnly: true,
args: [
{
key: 'username',
prompt: 'Wich status should i have?',
type: 'string',
}
]
});
}
async run(message, { username }) {
this.client.user.setUsername(username);
message.say(`The username have been changed sucessfully to ${username}`);
}
};

View file

@ -1,40 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class BSEspamCommand extends Command {
constructor(client) {
super(client, {
name: 'bsespam',
group: 'reserved',
memberName: 'bsespam',
description: `FOR Big Snow Energy only\nSpam the text you send`,
throttling: {
usages: 2,
duration: 3600,
},
args: [
{
key: 'number',
prompt: 'How many times do you want to repeat it?',
type: 'integer',
validate: number => number < 11,
default: '1'
},
{
key: 'text',
prompt: 'What do you want me to say',
type: 'string',
}
]
});
}
async run(message, { number, text }) {
if (message.author.id != "428387534842626048")
return message.say('Command only available to **Big Snow Energy**')
for(let i = 0; i < number; i++) {
message.say(text);
}
message.say('Finished :)');
}
};

View file

@ -1,34 +1,30 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class AvatarCommand extends Command {
module.exports = class AvatarCommand extends Command { constructor() {
constructor(client) { super('avatar', {
super(client, { aliases: ['avatar', 'avy'],
name: 'avatar', category: 'utility',
group: 'utility',
memberName: 'avatar',
description: 'Send the avatar of the mentionned user.',
args: [ args: [
{ {
key: 'user', id: 'user',
prompt: 'What do you want me to say', type: 'user'
type: 'user',
default: ''
} }
] ],
description: {
content: 'Show avatar of the mentioned user or you',
usage: '(optional) [@user]',
examples: ['', '@user']
}
}); });
} }
async run(message, { user }) { async exec(message, args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); if (!args.user)
if(blacklistJson[message.author.id]) return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL}`);
return blacklist(blacklistJson[message.author.id] , message)
if (!user)
return message.say(`Your avatar:\n${message.author.displayAvatarURL}`);
else else
return message.say(`${user.username}'s avatar:\n${user.displayAvatarURL}`); return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL}`);
} }
}; }
module.exports = AvatarCommand;

View file

@ -1,36 +1,34 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const fs = require('fs'); const fs = require('fs');
const youtubedl = require('youtube-dl'); const youtubedl = require('youtube-dl');
const SelfReloadJSON = require('self-reload-json');
const { fbuser, fbpasswd } = require('../../config.json'); const { fbuser, fbpasswd } = require('../../config.json');
const blacklist = require('../../json/blacklist.json');
class DownloadCommand extends Command {
module.exports = class downloadCommand extends Command { constructor() {
constructor(client) { super('download', {
super(client, { aliases: ['download', 'dl'],
name: 'download', category: 'utility',
group: 'utility',
memberName: 'download',
description: `Download any video from the link you provided.`,
args: [ args: [
{ {
key: 'link', id: "link",
prompt: 'Wich video would you like to download?', type: "string",
type: 'string', default: "https://www.youtube.com/watch?v=6n3pFFPSlW4"
default: 'https://www.youtube.com/watch?v=6n3pFFPSlW4'
} }
] ],
clientPermissions: ['ATTACH_FILES'],
description: {
content: 'Download videos from different website from the link you provided',
usage: '[link]',
examples: ['https://www.youtube.com/watch?v=6n3pFFPSlW4']
}
}); });
} }
async run(message, { link }) { async exec(message,args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); let link = args.link;
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
if(link.includes("http") || link.includes("www")) { if(link.includes("http") || link.includes("www")) {
message.say('Downloading...').then(msg => { message.channel.send('Downloading <a:loadingmin:527579785212329984>').then(msg => {
video.on('end', function() { video.on('end', function() {
msg.delete() msg.delete()
}) })
@ -39,15 +37,16 @@ module.exports = class downloadCommand extends Command {
video.pipe(fs.createWriteStream('./video.mp4')) video.pipe(fs.createWriteStream('./video.mp4'))
video.on('error', function error(err) { video.on('error', function error(err) {
console.log('error 2:', err); console.log('error 2:', err);
message.say("An error has occured, i can't download from the link you provided.") message.channel.send("An error has occured, i can't download from the link you provided.")
}); });
video.on('end', function() { video.on('end', function() {
message.delete(); message.delete();
message.channel.send(`Downloaded by ${message.author.username}`, {files: ["./video.mp4"]}) message.channel.send(`Downloaded by ${message.author.username}`, {files: ["./video.mp4"]})
.catch(error => message.say('File too big')) .catch(() => message.channel.send('File too big'))
}) })
} else } else
message.say("You need to input a valid link") message.channel.send("You need to input a valid link")
} }
}
} module.exports = DownloadCommand;

View file

@ -1,38 +1,33 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const { feedbackChannel } = require('../../config.json'); const { feedbackChannel } = require('../../config.json');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class FeedbackCommand extends Command {
const fs = require('fs'); constructor() {
module.exports = class feedbackCommand extends Command { super('feedback', {
constructor(client) { aliases: ['feedback'],
super(client, { category: 'utility',
name: 'feedback', split: 'none',
group: 'utility',
memberName: 'feedback',
description: `Send feedback ( if you abuse you will get blacklisted )`,
throttling: {
usages: 2,
duration: 60,
},
args: [ args: [
{ {
key: 'text', id: "text",
prompt: 'What would you want to send as feedback?', type: "string"
type: 'string',
} }
] ],
description: {
content: 'Send feedback to the bot owner',
usage: '[What do you want to say]',
examples: ['Hello, i just wanted to say hi!']
}
}); });
} }
async run(message, { text }) { async exec(message,args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); let text = args.text;
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
const channel = this.client.channels.get(feedbackChannel); const channel = this.client.channels.get(feedbackChannel);
channel.send(`from ${message.author.username} (${message.author.id}) : ${text}`); channel.send(`from ${message.author.username} (${message.author.id}) : ${text}`);
message.say('Your feedback has been sent!'); message.channel.send('Your feedback has been sent!');
} }
}; }
module.exports = FeedbackCommand;

94
commands/utility/help.js Normal file
View file

@ -0,0 +1,94 @@
const { Command } = require('discord-akairo');
const { prefix } = require('../../config.json');
class HelpCommand extends Command {
constructor() {
super('help', {
aliases: ['help', 'halp', 'h'],
category: 'utility',
clientPermissions: ['EMBED_LINKS'],
quoted: false,
args: [
{
id: 'command',
type: 'commandAlias',
prompt: {
start: 'Which command do you need help with?',
retry: 'Please provide a valid command.',
optional: true
}
}
],
description: {
content: 'Displays a list of commands or information about a command.',
usage: '[command]',
examples: ['', 'star', 'remove-rep']
}
});
}
exec(message, { command }) {
if (!command) return this.execCommandList(message);
const prefix = this.handler.prefix(message);
const description = Object.assign({
content: 'No description available.',
usage: '',
examples: [],
fields: []
}, command.description);
const embed = this.client.util.embed()
.setColor(0xFFAC33)
.setTitle(`\`${prefix}${command.aliases[0]} ${description.usage}\``)
.addField('Description', description.content);
for (const field of description.fields) embed.addField(field.name, field.value);
if (description.examples.length) {
const text = `${prefix}${command.aliases[0]}`;
embed.addField('Examples', `\`${text} ${description.examples.join(`\`\n\`${text} `)}\``, true);
}
if (command.aliases.length > 1) {
embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true);
}
return message.util.send({ embed });
}
async execCommandList(message) {
const embed = this.client.util.embed()
.setColor(0xFFAC33)
.addField('Command List',
[
'This is a list of commands.',
`To view details for a command, do \`${prefix}help <command>\`.`
]);
for (const category of this.handler.categories.values()) {
const title = {
general: '📝\u2000General',
images: '💕\u2000Images',
utility: '⭐\u2000Utility',
admin: '😎\u2000Admin',
owner: '⚡\u2000Owner'
}[category.id];
if (title) embed.addField(title, `\`${category.map(cmd => cmd.aliases[0]).join('` `')}\``);
}
const shouldReply = message.guild && message.channel.permissionsFor(this.client.user).has('SEND_MESSAGES');
try {
await message.author.send({ embed });
if (shouldReply) return message.util.reply('I\'ve sent you a DM with the command list.');
} catch (err) {
if (shouldReply) return message.util.reply('I could not send you the command list in DMs.');
}
return undefined;
}
}
module.exports = HelpCommand;

View file

@ -1,47 +0,0 @@
const { Command } = require('discord.js-commando');
const Discord = require('discord.js');
const fetch = require('node-fetch')
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class InfoCommand extends Command {
constructor(client) {
super(client, {
name: 'info',
group: 'fun',
memberName: 'info',
description: `Search DuckDuckGo for answer`,
args: [
{
key: 'search',
prompt: 'What do you want me to search',
type: 'string',
}
]
});
}
async run(message, { search }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let searchURL = encodeURI(search)
fetch("https://api.duckduckgo.com/?q=" + searchURL + "&format=json").then((response) => {
return response.json();
}).then((response) => {
if (response.unsafe == 1)
return message.say("No nsfw sorry...")
const ddgEmbed = new Discord.RichEmbed()
.setColor("#ff9900")
.setTitle(response.Heading)
.setURL(response.AbstractURL)
.setDescription(response.Abstract)
.addField("Topic", response.meta.topic)
.setImage(response.Image)
.setTimestamp()
message.say(ddgEmbed);
});
}};

View file

@ -1,25 +1,24 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const { supportServer } = require('../../config.json'); const { supportServer } = require('../../config.json');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class InviteCommand extends Command {
module.exports = class InviteCommand extends Command { constructor() {
constructor(client) { super('invite', {
super(client, { aliases: ['invite'],
name: 'invite', category: 'utility',
group: 'utility', channelRestriction: 'guild',
memberName: 'invite', description: {
description: 'Send invite to add the bot', content: 'Send invite link for the bot and support server',
usage: '',
examples: ['']
}
}); });
} }
async run(message) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); message.channel.send('Check your dm')
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
message.say('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 :)`); 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 :)`);
} }
}; }
module.exports = InviteCommand;

View file

@ -1,41 +1,25 @@
const { oneLine } = require('common-tags'); const { Command } = require('discord-akairo');
const { Command } = require('discord.js-commando');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class PingCommand extends Command {
module.exports = class PingCommand extends Command { constructor() {
constructor(client) { super('ping', {
super(client, { aliases: ['ping', 'hello'],
name: 'ping', category: 'utility',
group: 'util', description: {
memberName: 'ping', content: 'Ping the bot',
description: 'Checks the bot\'s ping to the Discord server.', usage: '',
throttling: { examples: ['']
usages: 5,
duration: 10
} }
}); });
} }
async run(message) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); return message.util.reply('Pong!').then(sent => {
if(blacklistJson[message.author.id]) const timeDiff = (sent.editedAt || sent.createdAt) - (message.editedAt || message.createdAt);
return blacklist(blacklistJson[message.author.id] , message) const text = `🔂\u2000**RTT**: ${timeDiff} ms\n💟\u2000**Heartbeat**: ${Math.round(this.client.ping)} ms`;
return message.util.reply(`Pong!\n${text}`);
if(!message.editable) { });
const pingMsg = await message.say('Pinging...'); }
return pingMsg.edit(oneLine` }
${message.channel.type !== 'dm' ? `${message.author},` : ''}
<:ping:499226870047571978> Pong! The message round-trip took **${pingMsg.createdTimestamp - message.createdTimestamp}**ms. module.exports = PingCommand;
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
`);
} else {
await message.edit('Pinging...');
return message.edit(oneLine`
Pong! The message round-trip took **${message.editedTimestamp - message.createdTimestamp}**ms.
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
`);
}
}
};

View file

@ -1,42 +1,39 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class ServerCommand extends Command {
module.exports = class ServerCommand extends Command { constructor() {
constructor(client) { super('server', {
super(client, { aliases: ['server', 'serverinfo'],
name: 'server', category: 'utility',
group: 'utility', channelRestriction: 'guild',
guildOnly: 'true', description: {
memberName: 'server', content: 'Show info about the server',
description: 'Show some stats about the server', usage: '',
guildOnly: true, examples: ['']
}
}); });
} }
async run(message) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
try { try {
let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`); const customresponse = require(`../tag/${message.guild.id}.json`);
var count = Object.keys(customresponse).length var count = Object.keys(customresponse).length
} catch { } catch {
var count = 'None' var count = 'None'
} }
const addEmbed = {
const addEmbed = {
color: 0x0099ff, color: 0x0099ff,
title: 'Stats of the server', title: 'Stats of the server',
thumbnail: { thumbnail: {
url: `${message.guild.iconURL}`, 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}**`, 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.say({ embed: addEmbed }); message.channel.send({ embed: addEmbed });
} }
}; }
module.exports = ServerCommand;

View file

@ -1,23 +1,19 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class StatsCommand extends Command {
module.exports = class statsCommand extends Command { constructor() {
constructor(client) { super('stats', {
super(client, { aliases: ['stats'],
name: 'stats', category: 'utility',
group: 'utility', description: {
memberName: 'stats', content: 'Show some stats about the bot',
description: 'Show bot stats.', usage: '',
examples: ['']
}
}); });
} }
async run(message) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
let totalSeconds = (this.client.uptime / 1000); let totalSeconds = (this.client.uptime / 1000);
let days = Math.floor(totalSeconds / 86400); let days = Math.floor(totalSeconds / 86400);
let hours = Math.floor(totalSeconds / 3600); let hours = Math.floor(totalSeconds / 3600);
@ -27,4 +23,6 @@ module.exports = class statsCommand extends Command {
let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`; 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}\``); return message.channel.send(`Servers: \`${this.client.guilds.size}\`\nChannels: \`${this.client.channels.size}\`\nUsers: \`${this.client.users.size}\`\nBot uptime: \`${uptime}\``);
} }
}; }
module.exports = StatsCommand;

View file

@ -1,23 +0,0 @@
const { Command } = require('discord.js-commando');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
module.exports = class supportMeCommand extends Command {
constructor(client) {
super(client, {
name: 'supportme',
group: 'utility',
memberName: 'supportme',
description: `Support me and my bot`,
});
}
async run(message, { text }) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
message.say('If you want to support me and my bot you can donate here\nhttps://donatebot.io/checkout/487640086859743232\nor here on patreon: https://patreon.com/user?u=15330358&utm_medium=social&utm_source=twitter&utm_campaign=creatorshare\n(This is totally optional dont feel forced to do it)');
}
};

View file

@ -1,27 +1,25 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const blacklist = require('../../json/blacklist.json');
const Discord = require('discord.js'); class taglistCommand extends Command {
const SelfReloadJSON = require('self-reload-json'); constructor() {
const fs = require('fs'); super('taglist', {
module.exports = class taglistCommand extends Command { aliases: ['taglist'],
constructor(client) { category: 'utility',
super(client, { channelRestriction: 'guild',
name: 'taglist', description: {
group: 'utility', content: 'Show the list of tag for this server.',
memberName: 'taglist', usage: '',
description: `List all the tag` examples: ['']
}
}); });
} }
async run(message) { async exec(message) {
if(blacklist[message.author.id])
return message.channel.send("You are blacklisted")
try { try {
let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`); let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`);
let count = Object.keys(customresponse).length let count = Object.keys(customresponse).length
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){ fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
if (err) { if (err) {
console.log(err); console.log(err);
@ -35,14 +33,12 @@ module.exports = class taglistCommand extends Command {
.setDescription(`Trigger:Response\n\n${json}`) .setDescription(`Trigger:Response\n\n${json}`)
.setFooter(`You have ${count} tags on this server`) .setFooter(`You have ${count} tags on this server`)
message.say(tagEmbed); message.channel.send(tagEmbed);
}); });
} catch { } catch {
message.say('An error has occured, do you have any tags on the server?') message.channel.send('An error has occured, do you have any tags on the server?')
} }
}
}
module.exports = taglistCommand;
}
};

View file

@ -1,59 +1,63 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const fetch = require('node-fetch')
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
const Discord = require('discord.js'); const Discord = require('discord.js');
const fetch = require('node-fetch');
const { yandexAPI } = require('../../config.json'); const { yandexAPI } = require('../../config.json');
module.exports = class translationCommand extends Command { class TranslationCommand extends Command {
constructor(client) { constructor() {
super(client, { super('translation', {
name: 'translation', aliases: ['translation', 'trn'],
aliases: ['trn', 'translate'], category: 'utility',
group: 'utility', description: 'Translate the text you send into the lanuguage you selected',
memberName: 'translation', split: 'none',
description: `Translate what you say in english`,
args: [ args: [
{ {
key: 'language', id: 'language',
prompt: 'In what language do you want me to translate to? ( You can get the list here https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/)',
type: 'string', type: 'string',
default: 'en', default: 'en'
oneOf: ["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"]
}, },
{ {
key: 'text', id: 'text',
prompt: 'What do you want me to translate',
type: 'string', type: 'string',
} }
] ],
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?']
}
}); });
} }
async run(message, { text, language }) { async exec(message, args) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json'); console.log(args.language , args.text)
if(blacklistJson[message.author.id]) let language = args.language;
return blacklist(blacklistJson[message.author.id] , message) let text = args.text;
let textURI = encodeURI(text) let textURI = encodeURI(text)
fetch(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${yandexAPI}&text=${textURI}&lang=${language}&options=1`,{ fetch(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${yandexAPI}&text=${textURI}&lang=${language}&options=1`,{
}).then((response) => { }).then((response) => {
return response.json(); return response.json();
}).then((response) => { }).then((response) => {
if (response.code != '200') if (response.code == '502')
return message.say('An error has occured') return message.channel.send(`${response.message}, you probably didin't input the correct language code, you can check them here! https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/`)
else if (response.code != '200')
return message.channel.send('An error has occured')
const translationEmbed = new Discord.RichEmbed() const translationEmbed = new Discord.RichEmbed()
.setColor('#0099ff') .setColor('#0099ff')
.setTitle('Asked for the following translation:') .setTitle('Asked for the following translation:')
.setAuthor(message.author.username) .setAuthor(message.author.username)
.setDescription(response.text[0]) .setDescription(response.text[0])
.addField('Original text', text) .addField('Original text', text)
.addField('Translated from', response.detected.lang) .addField('Translated from', response.detected.lang)
.setTimestamp() .setTimestamp()
.setFooter('Powered by Yandex.Translate '); .setFooter('Powered by Yandex.Translate ');
message.say(translationEmbed) message.channel.send(translationEmbed)
}); });
}}; }
}
module.exports = TranslationCommand;

View file

@ -1,24 +1,20 @@
const { Command } = require('discord.js-commando'); const { Command } = require('discord-akairo');
const SelfReloadJSON = require('self-reload-json');
const blacklist = require('../../json/blacklist.json');
class UpdootCommand extends Command {
module.exports = class UpDootCommand extends Command { constructor() {
constructor(client) { super('updoot', {
super(client, { aliases: ['updoot', 'upvote', 'vote'],
name: 'updoot', category: 'utility',
aliases: ['vote'], channelRestriction: 'guild',
group: 'utility', description: {
memberName: 'updoot', content: 'Send a link to vote for my bot',
description: 'Send link to updoot my bot :D.', usage: '',
examples: ['']
}
}); });
} }
async run(message) { async exec(message) {
let blacklistJson = new SelfReloadJSON('./json/blacklist.json');
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
const upDoot = { const upDoot = {
color: 0x93C54B, color: 0x93C54B,
title: 'Vote for my bot', title: 'Vote for my bot',
@ -33,4 +29,6 @@ module.exports = class UpDootCommand extends Command {
message.channel.send({ embed: upDoot }); message.channel.send({ embed: upDoot });
} }
}; }
module.exports = UpdootCommand;

169
index.js
View file

@ -1,147 +1,32 @@
const { CommandoClient } = require('discord.js-commando'); const { AkairoClient } = require('discord-akairo');
const Discord = require('discord.js'); const { token, prefix, ownerID } = require('./config.json');
const path = require('path');
const { token, prefix, statsChannel, ownerID, supportServer } = require('./config.json');
const responseObject = require("./json/reply.json");
const reactObject = require("./json/react.json");
const imgResponseObject = require("./json/imgreply.json");
const SelfReloadJSON = require('self-reload-json');
// Prefix and ownerID and invite to support server
const client = new CommandoClient({
commandPrefix: prefix,
owner: ownerID,
invite: supportServer,
unknownCommandResponse: false,
disableEveryone: true,
});
// Command groups
client.registry
.registerDefaultTypes()
.registerGroups([
['fun', 'Fun'],
['images', 'Images'],
['utility', 'Utility'],
['reserved', 'Reserved'],
['admin', 'Admins'],
['owner', 'Owner'],
]) const client = new AkairoClient({
.registerDefaultGroups() ownerID: ownerID,
.registerDefaultCommands({ prefix: prefix,
ping: false emitters: {
}) process
.registerCommandsIn(path.join(__dirname, 'commands')); },
// Ready messages handleEdits: true,
client.on('ready', async () => { commandUtil: true,
// Send stats to the console commandUtilLifetime: 600000,
console.log(`\x1b[32mLogged in as \x1b[34m${client.user.tag}\x1b[0m! (\x1b[33m${client.user.id}\x1b[0m)`); commandDirectory: './commands/',
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`); inhibitorDirectory: './inhibitors/',
// Send stats to the "stats" channel in the support server if its not the test bot listenerDirectory: './listeners/'
if (client.user.id == 377563711927484418) { }, {
const channel = client.channels.get(statsChannel); disableEveryone: true
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`); }
}); });
// When bot join a guild send embeds with details about it. // Ready messages dosent work on the listeners event for some reasons
client.on("guildCreate", async guild => { client.on('ready', async () => {
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`); // Send stats to the console
const channel = client.channels.get(statsChannel); console.log(`\x1b[32mLogged in as \x1b[34m${client.user.tag}\x1b[0m! (\x1b[33m${client.user.id}\x1b[0m)`);
const addEmbed = new Discord.RichEmbed() 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`);
.setColor("#52e80d") // Send stats to the "stats" channel in the support server if its not the test bot
.setTitle('Someone added me ! YAY :D') if (client.user.id == 377563711927484418) {
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') const channel = client.channels.get(statsChannel);
.setThumbnail(guild.iconURL) 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}`);
.setDescription(`${guild.name}\n${guild.id}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\n(${guild.owner.id})`) client.user.setActivity(`${prefix} feedback <feedback> to tell me what you think of the bot! | ${prefix} help`); }
.setTimestamp()
channel.send({ embed: addEmbed });
});
// When bot get kicked from a guild send embeds with details about it.
client.on("guildDelete", async guild => {
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 = client.channels.get(statsChannel);
const kickEmbed = new Discord.RichEmbed()
.setColor("#FF0000")
.setTitle('They kicked me out :(')
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4')
.setThumbnail(guild.iconURL)
.setDescription(`${guild.name}\n${guild.id}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\n(${guild.owner.id})`)
.setTimestamp()
channel.send({ embed: kickEmbed });
console.log('***BOT KICKED***')
}); });
client.login(token);
client.on("message", async (message) => {
var customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`);
customresponse.on('error', function(err) { console.log('test') })
var autoresponse = new SelfReloadJSON('./json/autoresponse.json');
let message_content = message.content.toLowerCase();
// fix a stupid bug that happen for idk wich reasons pls why tf it happen
if (message_content == ('stop')) return;
if (message_content == ('is')) return;
if (message_content == ('on')) return;
if (message_content == ('once')) return;
if (message_content == ('save')) return;
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
if(imgResponseObject[message_content]) {
message.channel.send({files: [imgResponseObject[message_content]]});
}
// React only to the messages
else if(reactObject[message_content]) {
message.react(reactObject[message_content]);
}
// auto respond to messages
else if(responseObject[message_content]) {
message.channel.send(responseObject[message_content]);
// If it contain "like if" react with 👍
} else if (message_content.includes("like if")) {
message.react("\u{1F44D}")
// If it contain "jeff" react with a jeff emote
} else if (message_content.includes("jeff")) {
message.react("496028845967802378")
}
}}
})
// Very basic starboard
client.on('messageReactionAdd', async (reaction, message) => {
let messageContent = reaction.message.content;
let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`);
let messageAuthor = reaction.message.author.username;
let messageChannel = reaction.message.channel.name;
if (reaction.emoji.name === '🌟' && reaction.count === 4) {
const channel = client.channels.find(channel => channel.name === "starboard");
channel.send(`From the channel: **${messageChannel}**\n${messageAuthor}\n${messageContent}\n${messageAttachments}`)
.catch
console.error('There is no starboard')
}
if (reaction.emoji.name === '✡' && reaction.count === 4) {
const channel = client.channels.find(channel => channel.name === "shameboard");
channel.send(`From the channel: **${messageChannel}**\n${messageAuthor}\n${messageContent}\n${messageAttachments}`)
.catch
console.error('There is no shameboard')
}
})
client.on('error', console.error);
process.on('unhandledRejection', error => console.error('Uncaught Promise Rejection', error));
client.login(token);

16
inhibitors/blacklist.js Normal file
View file

@ -0,0 +1,16 @@
const { Inhibitor } = require('discord-akairo');
class BlacklistInhibitor extends Inhibitor {
constructor() {
super('blacklist', {
reason: 'blacklist'
})
}
exec(message) {
const blacklist = ['501856229123948545', '497730155691638784'];
return blacklist.includes(message.author.id);
}
}
module.exports = BlacklistInhibitor;

View file

@ -1,5 +0,0 @@
{
"501856229123948545": "Fuck off wierd userbot",
"497730155691638784": "Fuck off wierd userbot",
"503501944694767626": "User with invite username are not welcome."
}

View file

@ -1,11 +0,0 @@
{
"1": "https://cdn.discordapp.com/attachments/475999813587173406/498088708210425866/image-50.jpg",
"2": "https://cdn.discordapp.com/attachments/475999813587173406/498088708872994818/image-29.png",
"3": "https://cdn.discordapp.com/attachments/475999813587173406/498088708872994821/magik-2.png",
"4": "https://cdn.discordapp.com/attachments/475999813587173406/498088709443289088/image-26.png",
"5": "https://cdn.discordapp.com/attachments/475999813587173406/498088709443289089/image-301.jpg",
"6": "https://cdn.discordapp.com/attachments/475999813587173406/498088709883953162/458da9a.jpg",
"7": "https://cdn.discordapp.com/attachments/349122704995254275/498086713026150400/despacito-eS6Lm.jpg",
"8": "https://cdn.discordapp.com/attachments/240843640375607296/498096605661102090/38026328_1287563578041482_711316145507926016_n.png",
"9": "https://cdn.discordapp.com/attachments/348937971858145293/500357748043677706/7Kva2utdL.png"
}

View file

@ -1,7 +0,0 @@
{
"1": "When i first did the badmeme command the bot used to stock the pic locally lole good thing i fixed after that.",
"2": "You can put your own fun fact if you want you can dm @Supositware | Baguette#82110.",
"3": "feline dicks have little barbs",
"4": "This bot is running on a raspberry pi !",
"5": "Male nipples can lactate"
}

View file

@ -1,16 +0,0 @@
{
"1": "https://twitter.com/i/status/1037932315727618048",
"2": "https://www.youtube.com/watch?v=W3GrSMYbkBE",
"3": "https://www.youtube.com/watch?v=OuzRcfWyurE",
"4": "https://www.youtube.com/watch?v=IejjQzExNM4",
"5": "https://www.youtube.com/watch?v=zUAtDlAoaac",
"6": "https://cdn.discordapp.com/attachments/435167348652245002/486334823808630784/video.mov",
"7": "https://cdn.discordapp.com/attachments/453648629303869440/485557714970345494/DASH_4_8_M_1.mp4",
"8": "https://youtu.be/Gl6ekgobG2k",
"9": "https://www.youtube.com/watch?v=hzyMs_8k58Y",
"10": "https://www.youtube.com/watch?v=e6mfgX9TdCg",
"11": "https://twitter.com/i/status/1038774986855604225",
"12": "https://twitter.com/i/status/1038015132545282048",
"13": "https://twitter.com/i/status/1042002164728639490",
"14": "https://twitter.com/i/status/1043840216530866176"
}

View file

@ -1 +0,0 @@
{}

View file

@ -0,0 +1,16 @@
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

@ -0,0 +1,16 @@
const { Listener } = require('discord-akairo');
class CommandBlockedListener extends Listener {
constructor() {
super('commandBlocked', {
emitter: 'commandHandler',
eventName: 'commandBlocked'
});
}
exec(message, command, reason) {
console.log(`${message.author.username} was blocked from using ${command.id} because of ${reason}!`);
}
}
module.exports = CommandBlockedListener;

52
listeners/message.js Normal file
View file

@ -0,0 +1,52 @@
const { Listener } = require('discord-akairo');
const responseObject = require("../json/reply.json");
const reactObject = require("../json/react.json");
const imgResponseObject = require("../json/imgreply.json");
class MessageListener extends Listener {
constructor() {
super('message', {
emitter: 'client',
eventName: 'message'
});
}
async exec(message) {
const autoresponse = require("../json/autoresponse.json");
let message_content = message.content.toLowerCase();
if (message.author.bot) return; {
// If autoresponse is enable send the response
if(autoresponse[message.channel.id] == 'enable') {
// Reply with images as attachement
if(imgResponseObject[message_content]) {
message.channel.send({files: [imgResponseObject[message_content]]});
}
// React only to the messages
else if(reactObject[message_content]) {
message.react(reactObject[message_content]);
}
// auto respond to messages
else if(responseObject[message_content]) {
message.channel.send(responseObject[message_content]);
// If it contain "like if" react with 👍
} else if (message_content.includes("like if")) {
message.react("\u{1F44D}")
// If it contain "jeff" react with a jeff emote
} else if (message_content.includes("jeff")) {
message.react("496028845967802378")
}
}
const customresponse = require(`../tag/${message.guild.id}.json`);
// User autoresponse
if(customresponse[message_content]) {
message.channel.send(customresponse[message_content])
}
}
}
}
module.exports = MessageListener;

View file

@ -1,33 +1,23 @@
{ {
"name": "discordbot", "name": "djs12",
"version": "1.0.0", "version": "1.0.0",
"description": "A simple discord bot made with discord.js and commando", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": {
"type": "git",
"url": "git+https://gitlab.com/loicbersier/discordbot.git"
},
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"bugs": {
"url": "https://gitlab.com/loicbersier/discordbot/issues"
},
"homepage": "https://gitlab.com/loicbersier/discordbot#readme",
"dependencies": { "dependencies": {
"@google-cloud/text-to-speech": "^0.4.0", "@google-cloud/text-to-speech": "^0.4.0",
"canvas": "^2.0.1", "canvas": "^2.2.0",
"discord.js": "file:../discord.js-11.4-dev", "discord-akairo": "^7.5.5",
"discord.js-commando": "^0.10.0", "discord.js": "^11.4.2",
"node-fetch": "^2.2.0", "node-fetch": "^2.3.0",
"node-gyp": "^3.8.0", "reload-json": "^0.3.1",
"node-opus": "^0.3.1",
"printer": "^0.2.2",
"self-reload-json": "^0.4.0", "self-reload-json": "^0.4.0",
"superagent": "^4.0.0-beta.5", "superagent": "^4.1.0",
"youtube-dl": "^1.12.2" "youtube-dl": "^1.12.2"
} }
} }

View file

@ -1,33 +0,0 @@
# A simple discord bot
A simple discord bot made with discord.js and commando
## Feature
- Kick and ban user, you can provid a reasons and the user will know
- Faceapp
- put images into other images ( i dont know how to explain so here a picture of it: <img src="https://cdn.discordapp.com/attachments/488094005071183913/514869492615086113/edupspaint.png">)
- take images from reddit & imgur
- can make the bot write thing in emote or just repeat what the user say
- Print thing from the printer dev ( yes really, to disable simple delete print.js or disable with "${prefix} unload print")
- autoresponse ( that can be disable with a simple command "${prefix} autoresponse disable ("all" for server wide))
- and more !
### Installing
To install you need the dependency for [**node-canvas**](https://github.com/Automattic/node-canvas) and for [**node-printer ( for ubuntu )**](https://github.com/tojocky/node-printer)
then for the bot do the following commands
```
git clone https://gitlab.com/loicbersier/discordbot
npm install
```
##### Special thanks to
discord.js (https://github.com/discordjs) for providing discord.js, commando and the discord.js guide<br>
All the people who made all the node modules<br>
[TG/LW] Tina the Cyclops#5861 for inspiring me to make this bot
[You can also support me on patreon](https://patreon.com/user?u=15330358&utm_medium=social&utm_source=twitter&utm_campaign=creatorshare)