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