From d77f6232571833ad9dcba51313875d1ceeee0cf0 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 9 Jan 2020 23:38:03 +0100 Subject: [PATCH 1/3] Don't show "Is a bot?" if user is not a bot --- 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 b438542b..facb9855 100644 --- a/commands/utility/userInfo.js +++ b/commands/utility/userInfo.js @@ -48,7 +48,7 @@ class userInfoCommand extends Command { if (user.presence.activity) Embed.addField('Presence', user.presence.activity, true); // Is the user a bot? - if (user.bot) Embed.addField('Is a bot?', '✅', true); else if (!user.bot) Embed.addField('Is a bot?', '❌', true); + if (user.bot) Embed.addField('Is a bot?', '✅', true); // Show guild nickname if (member.nickname) Embed.addField('Nickname', member.nickname, true); From 6851daa978c9827bf2ffd903b64cccab62ba7f82 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 9 Jan 2020 23:38:37 +0100 Subject: [PATCH 2/3] Change activity every 30 minutes and choose from random user or owner --- event/listeners/ready.js | 69 +++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/event/listeners/ready.js b/event/listeners/ready.js index 802ae5e8..7f943bc2 100644 --- a/event/listeners/ready.js +++ b/event/listeners/ready.js @@ -33,44 +33,55 @@ class ReadyListener extends Listener { console.log(`${this.client.readyAt}`); //Bot status - if (Math.floor((Math.random() * 2) + 1) == 1) { - console.log('Status type: \x1b[32mWatching\x1b[0m'); + setStatus(this.client); + // Change status every 30 minutes + setInterval(async () => { + setStatus(this.client); + }, 1800000); - let status = watch[Math.floor((Math.random() * watch.length))]; - status = status.replace('${prefix}', prefix[0]); - - this.client.user.setActivity(`${status} | My prefix is: ${prefix[0]} `, { type: 'WATCHING' }); - } else { - console.log('Status type: \x1b[32mPlaying\x1b[0m'); + async function setStatus(client) { + let random = Math.floor((Math.random() * 3)); + if (random == 0) { // Random "Watching" status taken from json + console.log('Status type: \x1b[32mWatching\x1b[0m'); + + let status = watch[Math.floor((Math.random() * watch.length))]; + status = status.replace('${prefix}', prefix[0]); + + client.user.setActivity(`${status} | My prefix is: ${prefix[0]} `, { type: 'WATCHING' }); + } else if (random == 1) { // Random "Playing" status taken from json + console.log('Status type: \x1b[32mPlaying\x1b[0m'); + + let status = game[Math.floor((Math.random() * game.length))]; + status = status.replace('${prefix}', prefix[0]); + + client.user.setActivity(`${status} | My prefix is: ${prefix[0]}`, { type: 'PLAYING' }); + } else if (random == 2) { // Bot owner status + console.log('Status type: \x1b[32mCopying owner status\x1b[0m'); + let owner = client.users.get(client.ownerID); + // { type: owner.presence.activity.type, name: owner.presence.activity.name, url: owner.presence.activity.url } + client.user.setActivity(`${owner.presence.activity.name} | My prefix is: ${prefix[0]}`, owner.presence.activity); + } else { // Random user statuss + console.log('Status type: \x1b[32mCopying random user status\x1b[0m'); + let randomuser = client.users.random(); + // If the random user have no activity or is a bot pick a new user + while (randomuser.presence.activity == null || randomuser.presence.activity.type == 'CUSTOM_STATUS' || randomuser.bot) { + randomuser = client.users.random(); + } + // Get elapsed time from when the activity started + let diffMs = (new Date() - randomuser.presence.activity.timestamps.start); + let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); - let status = game[Math.floor((Math.random() * game.length))]; - status = status.replace('${prefix}', prefix[0]); - - this.client.user.setActivity(`${status} | My prefix is: ${prefix[0]}`, { type: 'PLAYING' }); + client.user.setActivity(`${randomuser.username} is ${randomuser.presence.activity.type.toLowerCase()} ${randomuser.presence.activity.name} for ${diffMins} minutes | My prefix is: ${prefix[0]}`, { type: randomuser.presence.activity.type, url: randomuser.presence.activity.url, name: randomuser.presence.activity.name }); + + } } + // If stats channel settings exist, send bot stats to it if (statsChannel) { const channel = this.client.channels.get(statsChannel); channel.send(`Ready to serve in ${channelSize} channels on ${guildSize} servers, for a total of ${userSize} users.\nThere is ${commandSize} command loaded\n${this.client.readyAt}`); } - /* - //Fetch messages in every channel ( so they can still enter starboard in case of reboot) - let array = []; - let channels = this.client.channels.array(); - for (const channel of channels.values()) { - array.push(channel.id); - } - - for (let i = 0; i < this.client.channels.size; i++) { - let channel = this.client.channels.get(array[i]); - if (channel.messages) { - channel.messages.fetch({ limit: 10 }) - .then(messages => console.log(`Received ${messages.size} messages`)) - .catch(err => console.error(err)); - } - } - */ // Expose stats if (exposeStats) { From fb4355d68e5fed52172f86c53354c158a2a39488 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 10 Jan 2020 00:38:42 +0100 Subject: [PATCH 3/3] Don't select owner activity if there is none --- event/listeners/ready.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/event/listeners/ready.js b/event/listeners/ready.js index 7f943bc2..a2006b06 100644 --- a/event/listeners/ready.js +++ b/event/listeners/ready.js @@ -40,6 +40,7 @@ class ReadyListener extends Listener { }, 1800000); async function setStatus(client) { + let owner = client.users.get(client.ownerID); let random = Math.floor((Math.random() * 3)); if (random == 0) { // Random "Watching" status taken from json console.log('Status type: \x1b[32mWatching\x1b[0m'); @@ -55,11 +56,15 @@ class ReadyListener extends Listener { status = status.replace('${prefix}', prefix[0]); client.user.setActivity(`${status} | My prefix is: ${prefix[0]}`, { type: 'PLAYING' }); - } else if (random == 2) { // Bot owner status + } else if (random == 2 && owner.presence.activity != null) { // Bot owner status console.log('Status type: \x1b[32mCopying owner status\x1b[0m'); - let owner = client.users.get(client.ownerID); - // { type: owner.presence.activity.type, name: owner.presence.activity.name, url: owner.presence.activity.url } - client.user.setActivity(`${owner.presence.activity.name} | My prefix is: ${prefix[0]}`, owner.presence.activity); + // Get elapsed time from when the activity started + let diffMins = 0; + if (owner.presence.activity.timestamps) { + let diffMs = (new Date() - owner.presence.activity.timestamps.start); + diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); + } + client.user.setActivity(`${owner.presence.activity.name}\nfor ${diffMins} minutes | My prefix is: ${prefix[0]}`, owner.presence.activity); } else { // Random user statuss console.log('Status type: \x1b[32mCopying random user status\x1b[0m'); let randomuser = client.users.random(); @@ -67,12 +72,15 @@ class ReadyListener extends Listener { while (randomuser.presence.activity == null || randomuser.presence.activity.type == 'CUSTOM_STATUS' || randomuser.bot) { randomuser = client.users.random(); } - // Get elapsed time from when the activity started - let diffMs = (new Date() - randomuser.presence.activity.timestamps.start); - let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); - client.user.setActivity(`${randomuser.username} is ${randomuser.presence.activity.type.toLowerCase()} ${randomuser.presence.activity.name} for ${diffMins} minutes | My prefix is: ${prefix[0]}`, { type: randomuser.presence.activity.type, url: randomuser.presence.activity.url, name: randomuser.presence.activity.name }); - + // Get elapsed time from when the activity started + let diffMins = 0; + if (randomuser.presence.activity.timestamps) { + let diffMs = (new Date() - randomuser.presence.activity.timestamps.start); + diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); + } + + client.user.setActivity(`${randomuser.username} is ${randomuser.presence.activity.type.toLowerCase()} ${randomuser.presence.activity.name}\nfor ${diffMins} minutes | My prefix is: ${prefix[0]}`, { type: randomuser.presence.activity.type, url: randomuser.presence.activity.url, name: randomuser.presence.activity.name }); } }