From c76c05aa3bdb5a18650e5b1a096e777c17f09891 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 5 May 2020 21:11:12 -0400 Subject: [PATCH] Make Activities and Leave Messages part of client --- Xiao.js | 10 ++++------ package.json | 2 +- structures/Client.js | 6 +++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Xiao.js b/Xiao.js index d6372c41..b6f4b0e0 100644 --- a/Xiao.js +++ b/Xiao.js @@ -10,8 +10,6 @@ const client = new Client({ disabledEvents: ['TYPING_START'] }); const { formatNumber } = require('./util/Util'); -const activities = require('./assets/json/activity'); -const leaveMsgs = require('./assets/json/leave-messages'); client.registry .registerDefaultTypes() @@ -50,14 +48,14 @@ client.registry client.on('ready', () => { client.logger.info(`[READY] Logged in as ${client.user.tag}! ID: ${client.user.id}`); - activities.push( + client.activities.push( { text: () => `${formatNumber(client.guilds.cache.size)} servers`, type: 'WATCHING' }, { text: () => `with ${formatNumber(client.registry.commands.size)} commands`, type: 'PLAYING' }, { text: () => `${formatNumber(client.users.cache.size)} users`, type: 'WATCHING' }, { text: () => `${formatNumber(client.channels.cache.size)} channels`, type: 'WATCHING' } ); client.setInterval(() => { - const activity = activities[Math.floor(Math.random() * activities.length)]; + const activity = client.activities[Math.floor(Math.random() * client.activities.length)]; const text = typeof activity.text === 'function' ? activity.text() : activity.text; client.user.setActivity(text, { type: activity.type }); }, 60000); @@ -87,8 +85,8 @@ client.on('guildMemberRemove', async member => { if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return null; if (channel.topic && channel.topic.includes('')) return null; try { - const leaveMsg = leaveMsgs[Math.floor(Math.random() * leaveMsgs.length)]; - await channel.send(leaveMsg.replace(/{{user}}/gi, `**${member.user.tag}**`)); + const leaveMessage = client.leaveMessages[Math.floor(Math.random() * client.leaveMessages.length)]; + await channel.send(leaveMessage.replace(/{{user}}/gi, `**${member.user.tag}**`)); return null; } catch { return null; diff --git a/package.json b/package.json index b1a3ecc5..3ea532ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.5.7", + "version": "114.5.8", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/Client.js b/structures/Client.js index 27f10356..a3096032 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -4,6 +4,8 @@ const Collection = require('@discordjs/collection'); const winston = require('winston'); const PokemonStore = require('./pokemon/PokemonStore'); const MemePoster = require('./MemePoster'); +const activities = require('../assets/json/activity'); +const leaveMsgs = require('../assets/json/leave-messages'); const { XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN } = process.env; module.exports = class XiaoClient extends CommandoClient { @@ -17,10 +19,12 @@ module.exports = class XiaoClient extends CommandoClient { winston.format.printf(log => `[${log.timestamp}] [${log.level.toUpperCase()}]: ${log.message}`) ) }); - this.webhook = new WebhookClient(XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN, { disableEveryone: true }); + this.webhook = new WebhookClient(XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN, { disableMentions: 'everyone' }); this.pokemon = new PokemonStore(); this.memePoster = new MemePoster(this); this.games = new Collection(); this.phone = new Collection(); + this.activities = activities; + this.leaveMessages = leaveMsgs; } };