From 63781153c6e3ad62aaf36fa6de88208bac0c92e3 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 30 Jan 2020 11:55:48 +0100 Subject: [PATCH 1/6] Changed footer --- commands/utility/download.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/utility/download.js b/commands/utility/download.js index 3ff62143..1db2696b 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -54,7 +54,7 @@ class DownloadCommand extends Command { .setColor(message.member.displayHexColor) .setAuthor(`Downloaded by ${message.author.username}`, message.author.displayAvatarURL(), link) .setDescription(args.caption) - .setFooter('You can get the original video by clicking on the "downloaded by" message!'); + .setFooter(`You can get the original video by clicking on the "downloaded by ${message.author.username}" message!`); if (link.includes('http') || link.includes('www')) { From ed75c7a7d30fa39bf23a0f0ee6dec2e55d4d6c46 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 30 Jan 2020 12:02:27 +0100 Subject: [PATCH 2/6] --removeall --- commands/admin/banword.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/commands/admin/banword.js b/commands/admin/banword.js index d268004a..ade44367 100644 --- a/commands/admin/banword.js +++ b/commands/admin/banword.js @@ -12,20 +12,22 @@ class BannedWordsCommand extends Command { { id: 'word', type: 'string', - prompt: { - start: 'What word should be banned', - }, match: 'rest' }, { id: 'remove', match: 'flag', flag: '--remove' + }, + { + id: 'removeall', + match: 'flag', + flag: '--removeall' } ], channelRestriction: 'guild', description: { - content: 'Ban word on the server. --remove to delete a banned word', + content: 'Ban word on the server. --remove to delete a banned word. --removeaall to remove every banned word', usage: '[word to ban]', examples: ['owo'] } @@ -33,6 +35,13 @@ class BannedWordsCommand extends Command { } async exec(message, args) { + if (args.removeall) { + BannedWords.destroy({where: {serverID: message.guild.id}}); + return message.channel.send('The banned word have been reset.'); + } + + if (!args.word) return message.channel.send('Please specify a word to ban!'); + args.word = args.word.replace(/[\u0250-\ue007]/g, ''); const bannedWords = await BannedWords.findOne({where: {word: args.word.toLowerCase(), serverID: message.guild.id}}); From a10c453ecf2e0263449c06e804986ffd86f6da5c Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 30 Jan 2020 17:50:31 +0100 Subject: [PATCH 3/6] Set your rank to a color of your choice --- commands/utility/color.js | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 commands/utility/color.js diff --git a/commands/utility/color.js b/commands/utility/color.js new file mode 100644 index 00000000..26b661cd --- /dev/null +++ b/commands/utility/color.js @@ -0,0 +1,79 @@ +const { Command } = require('discord-akairo'); + +class colorCommand extends Command { + constructor() { + super('color', { + aliases: ['color', 'colour'], + category: 'utility', + clientPermissions: ['SEND_MESSAGES', 'MANAGE_ROLES'], + args: [ + { + id: 'color', + type: 'string' + } + ], + description: { + content: 'Set your rank to a specified hex value OR (ColorResolvable)[https://discord.js.org/#/docs/main/master/typedef/ColorResolvable]', + usage: '[hex color OR ColorResolvable]', + examples: ['#FF0000', 'WHITE'] + } + }); + } + + async exec(message, args) { + let ColorResolvable = [ + 'default', + 'white', + 'aqua', + 'green', + 'blue', + 'yellow', + 'purple', + 'luminous_vivid_pink', + 'gold', + 'orange', + 'red', + 'grey', + 'darker_grey', + 'navy', + 'dark_aqua', + 'dark_green', + 'dark_blue', + 'dark_purple', + 'dark_vivid_pink', + 'dark_gold', + 'dark_orange', + 'dark_red', + 'dark_grey', + 'light_grey', + 'dark_navy' + ]; + + if (args.color.match(/^#[0-9A-F]{6}$/i) || ColorResolvable.includes(args.color.toLowerCase())) { + let role = message.guild.roles.find(role => role.name === args.color); + if (!role) { + message.guild.roles.create({ + data: { + name: args.color, + color: args.color.toUpperCase(), + permissions: 0 + }, + reason: 'Color command' + }); + return message.channel.send('Role created! try again to apply it to yourself!'); + } else if (message.guild.member(message.author).roles.has(role.id)) { + message.guild.member(message.author).roles.remove(role); + return message.channel.send('Role removed!'); + } + /* For some reason this doesn't work. + role = message.guild.roles.find(role => role.name === args.color); + */ + message.guild.member(message.author).roles.add(role); + return message.channel.send('Role added!'); + } else { + return message.channel.send(`${args.color} is not a valide color`); + } + } +} + +module.exports = colorCommand; \ No newline at end of file From c3f4c9d7866bd13f7f14aad4e60da8a686e342ad Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 1 Feb 2020 02:06:16 +0100 Subject: [PATCH 4/6] Fix dectalk --- commands/fun/tts/dectalk.js | 2 +- commands/fun/tts/dectalkvc.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/fun/tts/dectalk.js b/commands/fun/tts/dectalk.js index d20f9a56..a0304ac5 100644 --- a/commands/fun/tts/dectalk.js +++ b/commands/fun/tts/dectalk.js @@ -30,7 +30,7 @@ class dectalkCommand extends Command { async exec(message, args) { args.decMessage = rand.random(args.decMessage, message); args.decMessage = args.decMessage.replace('\n', ' '); - let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["\s'$`\\])/g,'\\$1'); + let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1'); if (process.platform == 'win32') { exec(`cd .\\dectalk && .\\say.exe -w dectalk.wav "${decMessage}"`) diff --git a/commands/fun/tts/dectalkvc.js b/commands/fun/tts/dectalkvc.js index 58e7c54e..647cec89 100644 --- a/commands/fun/tts/dectalkvc.js +++ b/commands/fun/tts/dectalkvc.js @@ -30,7 +30,7 @@ class dectalkvcCommand extends Command { async exec(message, args) { args.decMessage = rand.random(args.decMessage, message); args.decMessage = args.decMessage.replace('\n', ' '); - let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["\s'$`\\])/g,'\\$1'); + let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1'); if (process.platform == 'win32') { exec(`cd .\\dectalk && .\\say.exe -w dectalkvc.wav "${decMessage}"`) From f893b53ba011742e9b1bb127baea80998d619e48 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 1 Feb 2020 02:36:48 +0100 Subject: [PATCH 5/6] use tmpdir --- commands/fun/tts/dectalk.js | 10 ++++++---- commands/fun/tts/dectalkvc.js | 10 ++++++---- commands/fun/tts/sam.js | 5 +++-- commands/fun/tts/samvc.js | 5 +++-- commands/fun/tts/tts.js | 6 ++++-- commands/fun/tts/ttsvc.js | 9 +++++---- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/commands/fun/tts/dectalk.js b/commands/fun/tts/dectalk.js index a0304ac5..78d1bb2c 100644 --- a/commands/fun/tts/dectalk.js +++ b/commands/fun/tts/dectalk.js @@ -1,6 +1,7 @@ const { Command } = require('discord-akairo'); const util = require('util'); const exec = util.promisify(require('child_process').exec); +const os = require('os'); const rand = require('../../../rand.js'); class dectalkCommand extends Command { @@ -28,23 +29,24 @@ class dectalkCommand extends Command { } async exec(message, args) { + let output = `${os.tmpdir()}/${message.id}_dectalk.wav`; args.decMessage = rand.random(args.decMessage, message); args.decMessage = args.decMessage.replace('\n', ' '); let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1'); if (process.platform == 'win32') { - exec(`cd .\\dectalk && .\\say.exe -w dectalk.wav "${decMessage}"`) + exec(`cd .\\dectalk && .\\say.exe -w ${output} "${decMessage}"`) .catch(err => { console.error(err); return message.channel.send('Oh no! an error has occured!'); }) .then(() => { - return message.channel.send({files: ['./dectalk/dectalk.wav']}); + return message.channel.send({files: [output]}); }); } else if (process.platform == 'linux' || process.platform == 'darwin') { let loadingmsg = await message.channel.send('Processing ( this can take some time ) '); - exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalk.wav "${decMessage}"`) + exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${output} "${decMessage}"`) .catch(err => { loadingmsg.delete(); console.error(err); @@ -52,7 +54,7 @@ class dectalkCommand extends Command { }) .then(() => { loadingmsg.delete(); - return message.channel.send({files: ['./dectalk/dectalk.wav']}); + return message.channel.send({files: [output]}); }); } } diff --git a/commands/fun/tts/dectalkvc.js b/commands/fun/tts/dectalkvc.js index 647cec89..3a000412 100644 --- a/commands/fun/tts/dectalkvc.js +++ b/commands/fun/tts/dectalkvc.js @@ -1,6 +1,7 @@ const { Command } = require('discord-akairo'); const util = require('util'); const exec = util.promisify(require('child_process').exec); +const os = require('os'); const rand = require('../../../rand.js'); class dectalkvcCommand extends Command { @@ -28,12 +29,13 @@ class dectalkvcCommand extends Command { } async exec(message, args) { + let output = `${os.tmpdir()}/${message.id}_dectalk.wav`; args.decMessage = rand.random(args.decMessage, message); args.decMessage = args.decMessage.replace('\n', ' '); let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1'); if (process.platform == 'win32') { - exec(`cd .\\dectalk && .\\say.exe -w dectalkvc.wav "${decMessage}"`) + exec(`cd .\\dectalk && .\\say.exe -w ${output} "${decMessage}"`) .catch(err => { console.error(err); return message.channel.send('Oh no! an error has occured!'); @@ -43,7 +45,7 @@ class dectalkvcCommand extends Command { if (!voiceChannel) return message.say('Please enter a voice channel first.'); try { const connection = await voiceChannel.join(); - const dispatcher = connection.play('./dectalk/dectalk.wav'); + const dispatcher = connection.play(output); dispatcher.once('finish', () => voiceChannel.leave()); dispatcher.once('error', () => voiceChannel.leave()); return null; @@ -56,7 +58,7 @@ class dectalkvcCommand extends Command { } else if (process.platform == 'linux' || process.platform == 'darwin') { let loadingmsg = await message.channel.send('Processing ( this can take some time ) '); - exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalkvc.wav "${decMessage}"`) + exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${output} "${decMessage}"`) .catch(err => { loadingmsg.delete(); console.error(err); @@ -68,7 +70,7 @@ class dectalkvcCommand extends Command { try { loadingmsg.delete(); const connection = await voiceChannel.join(); - const dispatcher = connection.play('./dectalk/dectalkvc.wav'); + const dispatcher = connection.play(output); dispatcher.once('finish', () => voiceChannel.leave()); dispatcher.once('error', () => voiceChannel.leave()); return null; diff --git a/commands/fun/tts/sam.js b/commands/fun/tts/sam.js index 84d7c821..55cd5cf9 100644 --- a/commands/fun/tts/sam.js +++ b/commands/fun/tts/sam.js @@ -1,6 +1,7 @@ const { Command } = require('discord-akairo'); const axios = require('axios'); const fs = require('fs'); +const os = require('os'); const rand = require('../../../rand.js'); class samCommand extends Command { @@ -76,9 +77,9 @@ class samCommand extends Command { 'Content-Type': 'audio/mpeg', }, }).then((result) => { - const outputFilename = './sam.wav'; + const outputFilename = `${os.tmpdir}/${message.id}_sam.wav`; fs.writeFileSync(outputFilename, result.data); - return message.channel.send({files: ['./sam.wav']}); + return message.channel.send({files: [outputFilename]}); }); } diff --git a/commands/fun/tts/samvc.js b/commands/fun/tts/samvc.js index f8bf14a7..96a4efd5 100644 --- a/commands/fun/tts/samvc.js +++ b/commands/fun/tts/samvc.js @@ -1,6 +1,7 @@ const { Command } = require('discord-akairo'); const axios = require('axios'); const fs = require('fs'); +const os = require('os'); const rand = require('../../../rand.js'); class samvcCommand extends Command { @@ -76,7 +77,7 @@ class samvcCommand extends Command { 'Content-Type': 'audio/mpeg', }, }).then(async (result) => { - const outputFilename = './samvc.wav'; + const outputFilename = `${os.tmpdir}/${message.id}_sam.wav`; fs.writeFile(outputFilename, result.data, async function(err) { if (err) console.error(err); @@ -84,7 +85,7 @@ class samvcCommand extends Command { if (!voiceChannel) return message.say('Please enter a voice channel first.'); try { const connection = await voiceChannel.join(); - const dispatcher = connection.play('./samvc.wav'); + const dispatcher = connection.play(outputFilename); dispatcher.once('finish', () => voiceChannel.leave()); dispatcher.once('error', () => voiceChannel.leave()); return null; diff --git a/commands/fun/tts/tts.js b/commands/fun/tts/tts.js index 5c3899cd..5c4d60f5 100644 --- a/commands/fun/tts/tts.js +++ b/commands/fun/tts/tts.js @@ -3,6 +3,7 @@ const textToSpeech = require('@google-cloud/text-to-speech'); const rand = require('../../../rand.js'); const gclient = new textToSpeech.TextToSpeechClient(); const fs = require('fs'); +const os = require('os'); class TtsCommand extends Command { constructor() { @@ -30,6 +31,7 @@ class TtsCommand extends Command { async exec(message, args) { let text = args.text; + let output = `${os.tmpdir()}/${message.id}_tts.mp3`; text = rand.random(text, message); @@ -51,7 +53,7 @@ class TtsCommand extends Command { } // Write the binary audio content to a local file - fs.writeFile('tts.mp3', response.audioContent, 'binary', err => { + fs.writeFile(output, response.audioContent, 'binary', err => { if (err) { console.error('ERROR:', err); message.channel.send('An error has occured, the message is probably too long'); @@ -59,7 +61,7 @@ class TtsCommand extends Command { return; } console.log('Audio content written to file: tts.mp3'); - message.channel.send({ files: ['./tts.mp3'] }); + message.channel.send({ files: [output] }); }); }); diff --git a/commands/fun/tts/ttsvc.js b/commands/fun/tts/ttsvc.js index 651ff253..9cb14ce2 100644 --- a/commands/fun/tts/ttsvc.js +++ b/commands/fun/tts/ttsvc.js @@ -3,6 +3,7 @@ const textToSpeech = require('@google-cloud/text-to-speech'); const rand = require('../../../rand.js'); const gclient = new textToSpeech.TextToSpeechClient(); const fs = require('fs'); +const os = require('os'); class TtsvcCommand extends Command { constructor() { @@ -30,7 +31,8 @@ class TtsvcCommand extends Command { async exec(message, args) { let text = args.text; - + let output = `${os.tmpdir()}/${message.id}_tts.mp3`; + text = rand.random(text, message); // Construct the request @@ -50,20 +52,19 @@ class TtsvcCommand extends Command { } // Write the binary audio content to a local file - fs.writeFile('ttsvc.mp3', response.audioContent, 'binary', async err => { + fs.writeFile(output, response.audioContent, 'binary', async 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: ttsvc.mp3'); const voiceChannel = message.member.voice.channel; if (!voiceChannel) return message.say('Please enter a voice channel first.'); try { const connection = await voiceChannel.join(); - const dispatcher = connection.play('./ttsvc.mp3'); + const dispatcher = connection.play(output); dispatcher.once('finish', () => voiceChannel.leave()); dispatcher.once('error', () => voiceChannel.leave()); return null; From ec1e770eeefc7e62937ee9b7af4a9e94ba1b9492 Mon Sep 17 00:00:00 2001 From: Bruh moment Date: Sun, 2 Feb 2020 17:37:57 +0000 Subject: [PATCH 6/6] Update banword.js --- commands/admin/banword.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/admin/banword.js b/commands/admin/banword.js index ade44367..15aa9edb 100644 --- a/commands/admin/banword.js +++ b/commands/admin/banword.js @@ -37,7 +37,7 @@ class BannedWordsCommand extends Command { async exec(message, args) { if (args.removeall) { BannedWords.destroy({where: {serverID: message.guild.id}}); - return message.channel.send('The banned word have been reset.'); + return message.channel.send('The banned words have been reset.'); } if (!args.word) return message.channel.send('Please specify a word to ban!'); @@ -48,7 +48,7 @@ class BannedWordsCommand extends Command { if (!bannedWords) { const body = {word: args.word.toLowerCase(), serverID: message.guild.id}; await BannedWords.create(body); - return message.channel.send(`The word ${args.word.toLowerCase()} have been banned`); + return message.channel.send(`The word ${args.word.toLowerCase()} has been banned`); } else if (args.remove && bannedWords) { BannedWords.destroy({where: {word: args.word.toLowerCase(), serverID: message.guild.id}}); return message.channel.send(`The word ${args.word.toLowerCase()} is no longer banned`);