various fixes for djs v12
This commit is contained in:
parent
e826ed8fca
commit
af6153ef40
16 changed files with 65 additions and 38 deletions
|
@ -38,7 +38,7 @@ class autoresponseCommand extends Command {
|
||||||
|
|
||||||
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
|
fs.readFile('./json/autoresponse.json', 'utf8', function readFileCallback(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ class autoresponseCommand extends Command {
|
||||||
json = json.replace(/[<#>]/g, '');
|
json = json.replace(/[<#>]/g, '');
|
||||||
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.close();
|
|
||||||
return message.channel.send('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') {
|
} else if (text == 'disable' || 'enable') {
|
||||||
|
@ -68,7 +68,7 @@ class autoresponseCommand extends Command {
|
||||||
json = JSON.stringify(autoresponse); //convert it back to json
|
json = JSON.stringify(autoresponse); //convert it back to json
|
||||||
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
fs.writeFile('./json/autoresponse.json', json, 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -76,7 +76,7 @@ class autoresponseCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.close();
|
|
||||||
return message.channel.send(`Autoresponse have been ${text}d`);
|
return message.channel.send(`Autoresponse have been ${text}d`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class shameboardCommand extends Command {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
fs.close();
|
|
||||||
return message.channel.send('This channel have been set as the shameboard');
|
return message.channel.send('This channel have been set as the shameboard');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -34,13 +34,13 @@ class shameboardCommand extends Command {
|
||||||
var json = JSON.stringify(shameboard); //convert it back to json
|
var json = JSON.stringify(shameboard); //convert it back to json
|
||||||
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) {
|
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fs.close();
|
|
||||||
return message.channel.send('This channel have been set as the shameboard');
|
return message.channel.send('This channel have been set as the shameboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class StarBoardCommand extends Command {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
fs.close();
|
|
||||||
return message.channel.send('This channel have been set as the starboard');
|
return message.channel.send('This channel have been set as the starboard');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -34,13 +34,13 @@ class StarBoardCommand extends Command {
|
||||||
var json = JSON.stringify(starboard); //convert it back to json
|
var json = JSON.stringify(starboard); //convert it back to json
|
||||||
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) {
|
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fs.close();
|
|
||||||
return message.channel.send('This channel have been set as the starboard');
|
return message.channel.send('This channel have been set as the starboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ class TagCommand extends Command {
|
||||||
|
|
||||||
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) {
|
||||||
fs.writeFile(`./tag/${message.guild.id}.json`, `{'${trigger}':'${response}'}`, function (err) {
|
fs.writeFile(`./tag/${message.guild.id}.json`, `{"${trigger}":"${response}"}`, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -49,14 +49,13 @@ class TagCommand extends Command {
|
||||||
json = JSON.stringify(customresponse); //convert it back to json
|
json = JSON.stringify(customresponse); //convert it back to json
|
||||||
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) {
|
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.close();
|
|
||||||
return message.channel.send(`autoresponse have been set to ${trigger} : ${response}`);
|
return message.channel.send(`autoresponse have been set to ${trigger} : ${response}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,14 +40,14 @@ class UnTagCommand extends Command {
|
||||||
json = JSON.stringify(customresponse); //convert it back to json
|
json = JSON.stringify(customresponse); //convert it back to json
|
||||||
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) {
|
fs.writeFile(`./tag/${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.close();
|
|
||||||
return message.channel.send(`The following autoresponse have been deleted: ${trigger}`);
|
return message.channel.send(`The following autoresponse have been deleted: ${trigger}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ class AdviceCommand extends Command {
|
||||||
fetch('http://api.adviceslip.com/advice').then((response) => {
|
fetch('http://api.adviceslip.com/advice').then((response) => {
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
const adviceEmbed = new MessageEmbed() .setColor('#ff9900')
|
const adviceEmbed = new MessageEmbed()
|
||||||
|
.setColor('#ff9900')
|
||||||
.setTitle(response.slip.slip_id)
|
.setTitle(response.slip.slip_id)
|
||||||
.setDescription(response.slip.advice);
|
.setDescription(response.slip.advice);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ class EmotesayCommand extends Command {
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let text = args.text;
|
let text = args.text;
|
||||||
|
if (!text)
|
||||||
|
return;
|
||||||
|
|
||||||
message.delete();
|
message.delete();
|
||||||
let emojiArray = [];
|
let emojiArray = [];
|
||||||
|
|
|
@ -11,7 +11,10 @@ class RedditCommand extends Command {
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
id: 'sub',
|
id: 'sub',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
prompt: {
|
||||||
|
retry: 'That\'s not a valid subreddit! try again.'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
description: {
|
description: {
|
||||||
|
|
|
@ -15,13 +15,15 @@ class SayCommand extends Command {
|
||||||
description: {
|
description: {
|
||||||
content: 'Repeat what you say but can also replace ',
|
content: 'Repeat what you say but can also replace ',
|
||||||
usage: '[text]',
|
usage: '[text]',
|
||||||
examples: ['[member] is a big [adverbs] [verb]']
|
examples: ['[member] is a big [adverb] [verb]']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let text = args.text;
|
let text = args.text;
|
||||||
|
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');
|
||||||
|
|
|
@ -23,6 +23,8 @@ class SaydCommand extends Command {
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let text = args.text;
|
let text = args.text;
|
||||||
|
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');
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TtsCommand extends Command {
|
||||||
// Performs the Text-to-Speech request
|
// Performs the Text-to-Speech request
|
||||||
gclient.synthesizeSpeech(request, (err, response) => {
|
gclient.synthesizeSpeech(request, (err, response) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
fs.close();
|
|
||||||
console.error('ERROR:', err);
|
console.error('ERROR:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,13 +48,13 @@ class TtsCommand extends Command {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('ERROR:', err);
|
console.error('ERROR:', err);
|
||||||
message.channel.send('An error has occured, the message is probably too long');
|
message.channel.send('An error has occured, the message is probably too long');
|
||||||
fs.close();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Audio content written to file: tts.mp3');
|
console.log('Audio content written to file: tts.mp3');
|
||||||
message.channel.send({ files: ['./tts.mp3'] });
|
message.channel.send({ files: ['./tts.mp3'] });
|
||||||
});
|
});
|
||||||
fs.close();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class TtsvcCommand extends Command {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('ERROR:', err);
|
console.error('ERROR:', err);
|
||||||
message.channel.send('An error has occured, the message is probably too long');
|
message.channel.send('An error has occured, the message is probably too long');
|
||||||
fs.close();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Audio content written to file: ttsvc.mp3');
|
console.log('Audio content written to file: ttsvc.mp3');
|
||||||
|
|
|
@ -20,10 +20,10 @@ class AvatarCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
if (!args.user) // While these kind of statments work you really should use {}
|
if (!args.user)
|
||||||
return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL}`);
|
return message.channel.send(`Your avatar:\n${message.author.displayAvatarURL()}`);
|
||||||
else
|
else
|
||||||
return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL}`);
|
return message.channel.send(`${args.user.username}'s avatar:\n${args.user.displayAvatarURL()}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ class DownloadCommand extends Command {
|
||||||
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(() => message.channel.send('File too big'));
|
.catch(() => message.channel.send('File too big'));
|
||||||
fs.close();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fs.close();
|
|
||||||
message.channel.send('You need to input a valid link');
|
message.channel.send('You need to input a valid link');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
class StatsCommand extends Command {
|
class StatsCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -21,7 +22,21 @@ class StatsCommand extends Command {
|
||||||
let minutes = Math.floor(totalSeconds / 60);
|
let minutes = Math.floor(totalSeconds / 60);
|
||||||
let seconds = totalSeconds.toFixed(0) % 60;
|
let seconds = totalSeconds.toFixed(0) % 60;
|
||||||
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}\``);
|
const used = process.memoryUsage().heapUsed / 1024 / 1024;
|
||||||
|
|
||||||
|
const statsEmbed = new MessageEmbed()
|
||||||
|
.setColor('#0099ff')
|
||||||
|
.setTitle('Bot stats')
|
||||||
|
.setAuthor('Haha yes')
|
||||||
|
.addField('Servers', this.client.guilds.size, true)
|
||||||
|
.addField('Channels', this.client.channels.size, true)
|
||||||
|
.addField('Users', this.client.users.size, true)
|
||||||
|
.addField('Uptime', uptime, true)
|
||||||
|
.addField('Ram usage', `${Math.round(used * 100) / 100} MB`, true)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter('Powered by Yandex.Translate ');
|
||||||
|
|
||||||
|
return message.channel.send(statsEmbed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,28 +18,31 @@ class taglistCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message) {
|
async exec(message) {
|
||||||
let customresponse = reload(`../../tag/${message.guild.id}.json`);
|
try {
|
||||||
let count = Object.keys(customresponse).length;
|
var customresponse = reload(`../../tag/${message.guild.id}.json`);
|
||||||
|
var count = Object.keys(customresponse).length;
|
||||||
|
} catch (err) {
|
||||||
|
message.channel.send('An error has occured, do you have any tags on the server?');
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
await fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
|
await fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
fs.close();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let json = JSON.stringify(data);
|
let json = JSON.stringify(data);
|
||||||
json = json.replace(/[{}'\\]+/g, '');
|
json = json.replace(/[{}'\\]+/g, '');
|
||||||
json = json.replace(/,+/g, '\n');
|
json = json.replace(/,+/g, '\n');
|
||||||
const tagEmbed = new MessageEmbed() .setColor('#ff9900')
|
const tagEmbed = new MessageEmbed()
|
||||||
|
.setColor('#ff9900')
|
||||||
.setTitle('Tags list')
|
.setTitle('Tags list')
|
||||||
.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.channel.send(tagEmbed);
|
message.channel.send(tagEmbed);
|
||||||
});
|
});
|
||||||
fs.close();
|
|
||||||
message.channel.send('An error has occured, do you have any tags on the server?');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue