From ef625e30ea7dc877dc3f2069f39d22c8682de03c Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 21:40:16 +0100 Subject: [PATCH 01/19] remove "all" --- commands/admin/autoresponse.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/commands/admin/autoresponse.js b/commands/admin/autoresponse.js index f2d2c273..2c6e8b68 100644 --- a/commands/admin/autoresponse.js +++ b/commands/admin/autoresponse.js @@ -13,10 +13,6 @@ class autoresponseCommand extends Command { prompt: { start: 'Do you want to **enable** or **disable** auto response?', } - }, - { - id: 'all', - type: 'string' } ], clientPermissions: ['SEND_MESSAGES'], @@ -24,8 +20,8 @@ class autoresponseCommand extends Command { channelRestriction: 'guild', description: { content: 'enable/disable autoresponse', - usage: '[enable/disable] (optional) [all]', - examples: ['enable all'] + usage: '[enable/disable]', + examples: ['enable'] } }); } From 190c19d271c87ba5bb72cd696474b58ffbc67b03 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 21:50:16 +0100 Subject: [PATCH 02/19] Quotation feature --- commands/admin/quotation.js | 45 ++++++++++ event/listeners/message.js | 83 +++++++++++++++---- .../20200305204757-create-quotation-stat.js | 30 +++++++ models/quotationstat.js | 11 +++ 4 files changed, 152 insertions(+), 17 deletions(-) create mode 100644 commands/admin/quotation.js create mode 100644 migrations/20200305204757-create-quotation-stat.js create mode 100644 models/quotationstat.js diff --git a/commands/admin/quotation.js b/commands/admin/quotation.js new file mode 100644 index 00000000..0a35f34e --- /dev/null +++ b/commands/admin/quotation.js @@ -0,0 +1,45 @@ +const { Command } = require('discord-akairo'); +const quotationStat = require('../../models').quotationStat; + +class quotationCommand extends Command { + constructor() { + super('quotation', { + aliases: ['quotation'], + category: 'admin', + args: [ + { + id: 'stat', + type: 'string', + prompt: { + start: 'Do you want to **enable** or **disable** quotation?', + } + } + ], + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['MANAGE_MESSAGES'], + channelRestriction: 'guild', + description: { + content: 'enable/disable quotation', + usage: '[enable/disable]', + examples: ['enable'] + } + }); + } + + async exec(message, args) { + if (args.stat.toLowerCase() == 'enable' || args.stat.toLowerCase() == 'disable') { + const quotationstat = await quotationStat.findOne({where: {serverID: message.guild.id}}); + + if (!quotationstat) { + const body = {serverID: message.guild.id, stat: args.stat}; + quotationStat.create(body); + return message.channel.send(`Quotation has been ${args.stat}d`); + } else { + const body = {serverID: message.guild.id, stat: args.stat}; + quotationStat.update(body, {where: {serverID: message.guild.id}}); + return message.channel.send(`Quotation has been ${args.stat}d`); + } + } + } +} +module.exports = quotationCommand; \ No newline at end of file diff --git a/event/listeners/message.js b/event/listeners/message.js index dd643a25..268432c1 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -6,6 +6,7 @@ const autoResponse = require('../../models').autoresponse; const autoResponseStat = require('../../models').autoresponseStat; const BannedWords = require('../../models').bannedWords; const WhitelistWord = require('../../models').whitelistWord; +const quotationStat = require('../../models').quotationStat; class messageListener extends Listener { constructor() { @@ -25,6 +26,11 @@ class messageListener extends Listener { if (message.author.bot) return; + /* Banned words section + * + * This section contains code about the banned words features + * + */ // Banned words const bannedWords = await BannedWords.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '').replace(/[\u0250-\ue007]/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); @@ -55,8 +61,14 @@ class messageListener extends Listener { return message.delete({reason: `Deleted message: ${message.content}`}); } else { + /* Autoresponse feature & tag + * + * This section contains autoresponse and tag feature + * + */ + // auto responses - const autoresponseStat = await autoResponseStat.findOne({where: {serverID: message.guild.id}}); + const autoresponseStat = await autoResponseStat.findOne({where: {serverID: message.guild.id, stat: 'enable'}}); if (autoresponseStat) { // Infinit haha very yes if (message.content.toLowerCase().startsWith('haha very') && message.content.toLowerCase().endsWith('yes')) { @@ -68,28 +80,25 @@ class messageListener extends Listener { return message.channel.send('haha very yes'); } - // If autoresponse is enable send the response - if (autoresponseStat.get('stat') == 'enable' && autoresponseStat.get('serverID') == message.guild.id) { // Reply with images as attachement - const autoresponse = await autoResponse.findOne({where: {trigger: message.content.toLowerCase()}}); + const autoresponse = await autoResponse.findOne({where: {trigger: message.content.toLowerCase()}}); - if (autoresponse) { - autoResponse.findOne({where: {trigger: message.content.toLowerCase()}}); - let trigger = autoresponse.get('trigger'); - let type = autoresponse.get('type'); - let content = autoresponse.get('response'); + if (autoresponse) { + autoResponse.findOne({where: {trigger: message.content.toLowerCase()}}); + let trigger = autoresponse.get('trigger'); + let type = autoresponse.get('type'); + let content = autoresponse.get('response'); - if (trigger == message.content.toLowerCase() && type == 'text') { - return message.channel.send(content); - } else if (trigger == message.content.toLowerCase() && type == 'react') { - return message.react(content); - } else if (trigger == message.content.toLowerCase() && type == 'image') { - return message.channel.send({files: [content]}); - } + if (trigger == message.content.toLowerCase() && type == 'text') { + return message.channel.send(content); + } else if (trigger == message.content.toLowerCase() && type == 'react') { + return message.react(content); + } else if (trigger == message.content.toLowerCase() && type == 'image') { + return message.channel.send({files: [content]}); } - } } + // User autoresponse const tag = await Tag.findOne({where: {trigger: message.content.toLowerCase(), serverID: message.guild.id}}); if (tag) { @@ -222,6 +231,46 @@ class messageListener extends Listener { } } + + /* Quotation feature + * + * This section will contain the code for the quotation feature, it will detect link for it and send it as embed + * + */ + const quotationstat = await quotationStat.findOne({where: {serverID: message.guild.id, stat: 'enable'}}); + + if (quotationstat && message.content.includes('discordapp.com/channels/')) { + let url = message.content.split('/'); + let guildID = url[4]; + let channelID = url[5]; + let messageID = url[6]; + + + // Verify if the guild, channel and message exist + let guild = this.client.guilds.resolve(guildID); + if (!guild) return; + let channel = this.client.channels.resolve(channelID); + if (!channel) return; + let quote = await channel.messages.fetch(messageID) + .catch(() => { + return; + }); + if (!quote) return; + + let Embed = this.client.util.embed() + .setColor(quote.member.displayHexColor) + .setAuthor(quote.author.username, quote.author.displayAvatarURL()) + .addField('Jump to', `[message](https://discordapp.com/channels/${message.guild.id}/${channelID}/${messageID})`, true) + .addField('In channel', quote.channel, true) + .addField('Quoted by', message.author, true) + .setDescription(quote.content) + .setTimestamp(); + + if (guild.id != message.guild.id) Embed.addField('In guild', guild.name, true); + + return message.channel.send(Embed); + } + } } } diff --git a/migrations/20200305204757-create-quotation-stat.js b/migrations/20200305204757-create-quotation-stat.js new file mode 100644 index 00000000..481bdf6b --- /dev/null +++ b/migrations/20200305204757-create-quotation-stat.js @@ -0,0 +1,30 @@ +'use strict'; +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('quotationStats', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + serverID: { + type: Sequelize.BIGINT + }, + stat: { + type: Sequelize.STRING + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('quotationStats'); + } +}; \ No newline at end of file diff --git a/models/quotationstat.js b/models/quotationstat.js new file mode 100644 index 00000000..33148166 --- /dev/null +++ b/models/quotationstat.js @@ -0,0 +1,11 @@ +'use strict'; +module.exports = (sequelize, DataTypes) => { + const quotationStat = sequelize.define('quotationStat', { + serverID: DataTypes.BIGINT, + stat: DataTypes.STRING + }, {}); + quotationStat.associate = function(models) { + // associations can be defined here + }; + return quotationStat; +}; \ No newline at end of file From 4b4b31d80d25a19a1b7327b85e1252e5b2ee32fb Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 21:55:12 +0100 Subject: [PATCH 03/19] Delete the quotation message --- event/listeners/message.js | 1 + 1 file changed, 1 insertion(+) diff --git a/event/listeners/message.js b/event/listeners/message.js index 268432c1..56975a5e 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -268,6 +268,7 @@ class messageListener extends Listener { if (guild.id != message.guild.id) Embed.addField('In guild', guild.name, true); + message.delete(); return message.channel.send(Embed); } From 016068d8da129a17c4841342b598f3c107aed58e Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 22:02:42 +0100 Subject: [PATCH 04/19] If the quoted message contain an image shows it --- event/listeners/message.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/event/listeners/message.js b/event/listeners/message.js index 56975a5e..58fa9a23 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -267,6 +267,8 @@ class messageListener extends Listener { .setTimestamp(); if (guild.id != message.guild.id) Embed.addField('In guild', guild.name, true); + let Attachment = (quote.attachments).array(); + if (Attachment[0]) Embed.setImage(Attachment[0].url); message.delete(); return message.channel.send(Embed); From 68dcc1875c2be27c315c2f8f39bc0884083847f5 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 22:26:53 +0100 Subject: [PATCH 05/19] Set quoted message as timestamp --- event/listeners/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index 58fa9a23..2b3b3c8c 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -264,7 +264,7 @@ class messageListener extends Listener { .addField('In channel', quote.channel, true) .addField('Quoted by', message.author, true) .setDescription(quote.content) - .setTimestamp(); + .setTimestamp(quote.createdTimestamp); if (guild.id != message.guild.id) Embed.addField('In guild', guild.name, true); let Attachment = (quote.attachments).array(); From b60057e1102ce2467369163b597fc16b7580bbb8 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 22:42:16 +0100 Subject: [PATCH 06/19] delete message only if it can send message --- event/listeners/message.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index 2b3b3c8c..d2dde9f5 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -270,8 +270,10 @@ class messageListener extends Listener { let Attachment = (quote.attachments).array(); if (Attachment[0]) Embed.setImage(Attachment[0].url); - message.delete(); - return message.channel.send(Embed); + return message.channel.send(Embed) + .then(() => { + message.delete(); + }); } } From 0ad53eac4b077b1067b57e22a9eb85d99e9ae7e0 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 22:43:11 +0100 Subject: [PATCH 07/19] use channel name --- event/listeners/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index d2dde9f5..e564973e 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -261,7 +261,7 @@ class messageListener extends Listener { .setColor(quote.member.displayHexColor) .setAuthor(quote.author.username, quote.author.displayAvatarURL()) .addField('Jump to', `[message](https://discordapp.com/channels/${message.guild.id}/${channelID}/${messageID})`, true) - .addField('In channel', quote.channel, true) + .addField('In channel', quote.channel.name, true) .addField('Quoted by', message.author, true) .setDescription(quote.content) .setTimestamp(quote.createdTimestamp); From d64285b3df61f9b5165b0743cd7d299976eb8365 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 22:54:08 +0100 Subject: [PATCH 08/19] disable quotation because i made it like ass --- event/listeners/message.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/event/listeners/message.js b/event/listeners/message.js index e564973e..8ab1f5b7 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -237,6 +237,7 @@ class messageListener extends Listener { * This section will contain the code for the quotation feature, it will detect link for it and send it as embed * */ + /* const quotationstat = await quotationStat.findOne({where: {serverID: message.guild.id, stat: 'enable'}}); if (quotationstat && message.content.includes('discordapp.com/channels/')) { @@ -275,6 +276,7 @@ class messageListener extends Listener { message.delete(); }); } + */ } } From c4f4a2a99547c0ac55b5e5478a1597bea5182eaf Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 5 Mar 2020 22:55:54 +0100 Subject: [PATCH 09/19] Actually nvm it was discord fault --- event/listeners/message.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index 8ab1f5b7..3ef3467a 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -237,7 +237,6 @@ class messageListener extends Listener { * This section will contain the code for the quotation feature, it will detect link for it and send it as embed * */ - /* const quotationstat = await quotationStat.findOne({where: {serverID: message.guild.id, stat: 'enable'}}); if (quotationstat && message.content.includes('discordapp.com/channels/')) { @@ -276,8 +275,6 @@ class messageListener extends Listener { message.delete(); }); } - */ - } } } From 183b01f5f0ab7d1ff5c43c3847295ab52e71390c Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 6 Mar 2020 15:14:27 +0100 Subject: [PATCH 10/19] webm --- commands/utility/download.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/utility/download.js b/commands/utility/download.js index b247f298..a0460db5 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -88,6 +88,8 @@ class DownloadCommand extends Command { fs.renameSync(`${os.tmpdir()}/${fileName}`, `${os.tmpdir()}/${fileName}.${ext}`); } else if (fs.existsSync(`${os.tmpdir()}/${fileName}.mkv`)) { // If it can't find the video assume it got merged and end with mkv fs.renameSync(`${os.tmpdir()}/${fileName}.mkv`, `${os.tmpdir()}/${fileName}.mp4`); // Discord play mkv just fine but it need to end with mp4 + } else if (fs.existsSync(`${os.tmpdir()}/${fileName}.webm`)) { // Same as mkv + ext = 'webm'; } let file = fs.statSync(`${os.tmpdir()}/${fileName}.${ext}`); From c8938a1689124d35b20fa923955bad0996d366f5 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 00:16:39 +0100 Subject: [PATCH 11/19] fixed activity --- commands/utility/userInfo.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commands/utility/userInfo.js b/commands/utility/userInfo.js index 22aa5dc6..cc1448a4 100644 --- a/commands/utility/userInfo.js +++ b/commands/utility/userInfo.js @@ -47,8 +47,7 @@ class userInfoCommand extends Command { Embed.addField('​', '​'); // Show user status - if (user.presence.activity) Embed.addField('Presence', user.presence.activities[0], true); - + if (user.presence.activities) Embed.addField('Presence', user.presence.activities[0], true); // Is the user a bot? if (user.bot) Embed.addField('Is a bot?', '✅', true); From c03b3ccadd49ae342de75b7bb49520632895a04f Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 00:17:44 +0100 Subject: [PATCH 12/19] don't show undefined --- commands/utility/userInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/utility/userInfo.js b/commands/utility/userInfo.js index cc1448a4..9b0e500d 100644 --- a/commands/utility/userInfo.js +++ b/commands/utility/userInfo.js @@ -47,7 +47,7 @@ class userInfoCommand extends Command { Embed.addField('​', '​'); // Show user status - if (user.presence.activities) Embed.addField('Presence', user.presence.activities[0], true); + if (user.presence.activities[0]) Embed.addField('Presence', user.presence.activities[0], true); // Is the user a bot? if (user.bot) Embed.addField('Is a bot?', '✅', true); From 84eb7923748c0d887413763152abf79bd5e08eff Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 13:15:06 +0100 Subject: [PATCH 13/19] fix hex color --- event/listeners/message.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index 3ef3467a..dc2d8dee 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -258,7 +258,6 @@ class messageListener extends Listener { if (!quote) return; let Embed = this.client.util.embed() - .setColor(quote.member.displayHexColor) .setAuthor(quote.author.username, quote.author.displayAvatarURL()) .addField('Jump to', `[message](https://discordapp.com/channels/${message.guild.id}/${channelID}/${messageID})`, true) .addField('In channel', quote.channel.name, true) @@ -266,6 +265,8 @@ class messageListener extends Listener { .setDescription(quote.content) .setTimestamp(quote.createdTimestamp); + if (quote.member) Embed.setColor(quote.member.displayHexColor); + if (guild.id != message.guild.id) Embed.addField('In guild', guild.name, true); let Attachment = (quote.attachments).array(); if (Attachment[0]) Embed.setImage(Attachment[0].url); From 5aba35502b36c183c9c64d4dc4fd032ba2098a00 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 13:42:47 +0100 Subject: [PATCH 14/19] Fix guild create and delete --- event/listeners/guildCreate.js | 5 +++-- event/listeners/guildDelete.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/event/listeners/guildCreate.js b/event/listeners/guildCreate.js index 7e440003..ae4b4a6c 100644 --- a/event/listeners/guildCreate.js +++ b/event/listeners/guildCreate.js @@ -13,6 +13,7 @@ class guildCreateListener extends Listener { async exec(guild) { console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`); const channel = this.client.channels.resolve(statsChannel); + let botCount = guild.members.cache.filter(member => member.user.bot).size; const addEmbed = this.client.util.embed() .setColor('#52e80d') .setTitle('New boiz in town') @@ -21,8 +22,8 @@ class guildCreateListener extends Listener { .addField('Guild name', guild.name, true) .addField('Guild ID', guild.id, true) .addField('Total number of members', guild.memberCount, true) - .addField('Number of users', guild.members.filter(member => !member.user.bot).size, true) - .addField('Number of bots', guild.members.filter(member => member.user.bot).size, true) + .addField('Number of users', guild.memberCount - botCount, true) + .addField('Number of bots', botCount, true) .addField('Owner', guild.owner.user.username, true) .addField('Owner ID', guild.owner.id, true) .setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`) diff --git a/event/listeners/guildDelete.js b/event/listeners/guildDelete.js index 209cd324..3ce18bcb 100644 --- a/event/listeners/guildDelete.js +++ b/event/listeners/guildDelete.js @@ -14,6 +14,8 @@ class guildCreateListener extends Listener { console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`); const channel = this.client.channels.resolve(statsChannel); + let botCount = guild.members.cache.filter(member => member.user.bot).size; + const kickEmbed = this.client.util.embed() .setColor('#FF0000') .setTitle('Some mofo just removed me from there guild :(') @@ -22,8 +24,8 @@ class guildCreateListener extends Listener { .addField('Guild name', guild.name, true) .addField('Guild ID', guild.id, true) .addField('Total number of members', guild.memberCount, true) - .addField('Number of users', guild.members.filter(member => !member.user.bot).size, true) - .addField('Number of bots', guild.members.filter(member => member.user.bot).size, true) + .addField('Number of users', guild.memberCount - botCount, true) + .addField('Number of bots', botCount, true) .addField('Owner', guild.owner.user.username, true) .addField('Owner ID', guild.owner.id, true) .setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`) From 3ad46b7950e03fbb934b55d8991b1b0665207b62 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 17:59:09 +0100 Subject: [PATCH 15/19] Changed guild to member --- event/listeners/guildMemberRemove.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/event/listeners/guildMemberRemove.js b/event/listeners/guildMemberRemove.js index 967f18ea..e798a5ac 100644 --- a/event/listeners/guildMemberRemove.js +++ b/event/listeners/guildMemberRemove.js @@ -10,8 +10,8 @@ class guildMemberRemoveListener extends Listener { }); } - async exec(guild) { - const leave = await leaveChannel.findOne({where: {guildID: guild.guild.id}}); + async exec(member) { + const leave = await leaveChannel.findOne({where: {guildID: member.guild.id}}); if (leave) { const channel = this.client.channels.resolve(leave.get('channelID')); @@ -19,8 +19,8 @@ class guildMemberRemoveListener extends Listener { let invite = new RegExp(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g); - let username = guild.user.username; - let user = guild.user; + let username = member.user.username; + let user = member.user; if (username.match(invite)) { username = username.replace(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g, '[REDACTED]'); user = username; @@ -28,7 +28,7 @@ class guildMemberRemoveListener extends Listener { byeMessage = byeMessage.replace(/\[member\]/, username); byeMessage = byeMessage.replace(/\[memberPing\]/, user); - byeMessage = byeMessage.replace(/\[server\]/, guild.guild.name); + byeMessage = byeMessage.replace(/\[server\]/, member.guild.name); let attach; if (byeMessage.includes('[attach:')) { From 90d29dd2100aad47750eb27abf20ff19279777ff Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 17:59:23 +0100 Subject: [PATCH 16/19] changed guild to member and added role functionality --- event/listeners/guildMemberAdd.js | 38 +++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/event/listeners/guildMemberAdd.js b/event/listeners/guildMemberAdd.js index 570e57d6..8c04bbcd 100644 --- a/event/listeners/guildMemberAdd.js +++ b/event/listeners/guildMemberAdd.js @@ -10,13 +10,13 @@ class guildMemberAddListener extends Listener { }); } - async exec(guild) { - if (guild.guild.id == 240843640375607296) { - guild.setNickname('fart piss'); + async exec(member) { + if (member.guild.id == 240843640375607296) { + member.setNickname('fart piss'); } - const join = await joinChannel.findOne({where: {guildID: guild.guild.id}}); + const join = await joinChannel.findOne({where: {guildID: member.guild.id}}); if (join) { const channel = this.client.channels.resolve(join.get('channelID')); @@ -26,17 +26,18 @@ class guildMemberAddListener extends Listener { let invite = new RegExp(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g); - let username = guild.user.username; - let user = guild.user; + let username = member.user.username; + let user = member.user; if (username.match(invite)) { username = username.replace(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g, '[REDACTED]'); user = username; } - welcomeMessage = welcomeMessage.replace(/\[member\]/, username); - welcomeMessage = welcomeMessage.replace(/\[memberPing\]/, user); - welcomeMessage = welcomeMessage.replace(/\[server\]/, guild.guild.name); - + welcomeMessage = welcomeMessage.replace(/\[member\]/g, username); + welcomeMessage = welcomeMessage.replace(/\[memberPing\]/g, user); + welcomeMessage = welcomeMessage.replace(/\[server\]/g, member.guild.name); + + // add attachment let attach; if (welcomeMessage.includes('[attach:')) { attach = welcomeMessage.split(/(\[attach:.*?])/); @@ -48,6 +49,23 @@ class guildMemberAddListener extends Listener { } welcomeMessage = welcomeMessage.replace(/(\[attach:.*?])/, ''); } + + // Give a role + let role; + if (welcomeMessage.includes('[role:')) { + role = welcomeMessage.split(/(\[role:.*?])/); + for (let i = 0, l = role.length; i < l; i++) { + if (role[i].includes('[role:')) { + role = role[i].replace('[role:', '').slice(0, -1); + i = role.length; + } + } + + const rank = member.guild.roles.cache.find(rank => rank.name === role); + member.roles.add(rank); + + welcomeMessage = welcomeMessage.replace(/(\[role:.*?])/, ''); + } welcomeMessage = rand.random(welcomeMessage); From 5840d6392a0e9b8c3cc7d633c448459421605454 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 18:03:54 +0100 Subject: [PATCH 17/19] more detail for presence --- commands/utility/userInfo.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/utility/userInfo.js b/commands/utility/userInfo.js index 9b0e500d..5c49cbe8 100644 --- a/commands/utility/userInfo.js +++ b/commands/utility/userInfo.js @@ -30,8 +30,6 @@ class userInfoCommand extends Command { let member = message.guild.member(user); - console.log(member); - const Embed = this.client.util.embed() .setColor(member.displayHexColor) .setAuthor(`${user.tag} (${user.id})`, user.displayAvatarURL()) @@ -47,7 +45,11 @@ class userInfoCommand extends Command { Embed.addField('​', '​'); // Show user status - if (user.presence.activities[0]) Embed.addField('Presence', user.presence.activities[0], true); + if (user.presence.activities[0]) { + Embed.addField('Presence', user.presence.activities[0], true); + if (user.presence.activities[0].details) Embed.addField('​', user.presence.activities[0].details, true); + if (user.presence.activities[0].state) Embed.addField('​', user.presence.activities[0].state, true); + } // Is the user a bot? if (user.bot) Embed.addField('Is a bot?', '✅', true); From b85784706ee4ecf10200a71b1e82a028081f36dd Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 18:07:42 +0100 Subject: [PATCH 18/19] remove role thing --- event/listeners/guildMemberAdd.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/event/listeners/guildMemberAdd.js b/event/listeners/guildMemberAdd.js index 8c04bbcd..23ae19c6 100644 --- a/event/listeners/guildMemberAdd.js +++ b/event/listeners/guildMemberAdd.js @@ -49,23 +49,6 @@ class guildMemberAddListener extends Listener { } welcomeMessage = welcomeMessage.replace(/(\[attach:.*?])/, ''); } - - // Give a role - let role; - if (welcomeMessage.includes('[role:')) { - role = welcomeMessage.split(/(\[role:.*?])/); - for (let i = 0, l = role.length; i < l; i++) { - if (role[i].includes('[role:')) { - role = role[i].replace('[role:', '').slice(0, -1); - i = role.length; - } - } - - const rank = member.guild.roles.cache.find(rank => rank.name === role); - member.roles.add(rank); - - welcomeMessage = welcomeMessage.replace(/(\[role:.*?])/, ''); - } welcomeMessage = rand.random(welcomeMessage); From a811f8f749270fe42fe581f1820ddd494feb11e4 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Wed, 11 Mar 2020 00:54:51 +0100 Subject: [PATCH 19/19] enable to use --size without link --- commands/fun/audio2image.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/fun/audio2image.js b/commands/fun/audio2image.js index 86273328..68c7101b 100644 --- a/commands/fun/audio2image.js +++ b/commands/fun/audio2image.js @@ -11,15 +11,15 @@ class audio2imageCommand extends Command { category: 'fun', clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'], args: [ - { - id: 'link', - type: 'string', - }, { id: 'video_size', match: 'option', flag: '--size', default: '640x480' + }, + { + id: 'link', + type: 'string', } ], description: {