From b0faaa531676b83175e6c0817f7cf8b2999fc300 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 22 Feb 2021 20:02:21 -0500 Subject: [PATCH] Remove Meme Poster Webhook --- .env.example | 3 --- README.md | 1 - Xiao.js | 12 ---------- package.json | 2 +- structures/Client.js | 11 --------- structures/MemePoster.js | 50 ---------------------------------------- 6 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 structures/MemePoster.js diff --git a/.env.example b/.env.example index 9cf7a71e..f85de1af 100644 --- a/.env.example +++ b/.env.example @@ -7,9 +7,6 @@ XIAO_PREFIX= INVITE= XIAO_WEBHOOK_ID= XIAO_WEBHOOK_TOKEN= -POSTER_ID= -POSTER_TOKEN= -POSTER_TIME= REPORT_CHANNEL_ID= JOIN_LEAVE_CHANNEL_ID= diff --git a/README.md b/README.md index 97218c46..6309bc04 100644 --- a/README.md +++ b/README.md @@ -960,7 +960,6 @@ Some Xiao features aren't technically commands, but are part of Xiao nonetheless. - Leave messages are automatically sent to any channel that recieves welcome messages. These can be turned off with [an option](#options). -- In Xiao's home server, Xiao posts a random meme from Reddit every hour using a webhook. - Some commands will automatically run when a certain phrase is said in any message, regardless of if the command itself was called or not. These are: * Saying "no u" runs `no-u`. * Saying "(╯°□°)╯︵ ┻━┻" runs `unflip`. diff --git a/Xiao.js b/Xiao.js index ddb9fac2..e2734f89 100644 --- a/Xiao.js +++ b/Xiao.js @@ -77,18 +77,6 @@ client.on('ready', async () => { client.user.setActivity(text, { type: activity.type }); }, 60000); - // Set up meme poster interval - if (client.memePoster) { - client.setInterval(async () => { - try { - const post = await client.memePoster.fetchRandomPost(false); - await client.memePoster.post(post); - } catch (err) { - client.logger.error(err); - } - }, client.memePoster.postInterval); - } - // Import blacklist try { const results = client.importBlacklist(); diff --git a/package.json b/package.json index 0682a24f..fd1cccc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "129.9.1", + "version": "130.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/Client.js b/structures/Client.js index 9c02a3c1..486073b6 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -10,16 +10,11 @@ const Font = require('./Font'); const PhoneManager = require('./phone/PhoneManager'); const TimerManager = require('./remind/TimerManager'); const PokemonStore = require('./pokemon/PokemonStore'); -const MemePosterClient = require('./MemePoster'); const activities = require('../assets/json/activity'); const leaveMsgs = require('../assets/json/leave-messages'); -const subreddits = require('../assets/json/meme'); const { XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN, - POSTER_ID, - POSTER_TOKEN, - POSTER_TIME, REPORT_CHANNEL_ID, JOIN_LEAVE_CHANNEL_ID } = process.env; @@ -41,12 +36,6 @@ module.exports = class XiaoClient extends CommandoClient { this.timers = new TimerManager(this); this.blacklist = { guild: [], user: [] }; this.pokemon = new PokemonStore(); - this.memePoster = POSTER_ID && POSTER_TOKEN ? new MemePosterClient(POSTER_ID, POSTER_TOKEN, { - subreddits, - postTypes: ['image', 'rich:video'], - postInterval: POSTER_TIME, - disableMentions: 'everyone' - }) : null; this.games = new Collection(); this.dispatchers = new Map(); this.phone = new PhoneManager(this); diff --git a/structures/MemePoster.js b/structures/MemePoster.js deleted file mode 100644 index 4a627da5..00000000 --- a/structures/MemePoster.js +++ /dev/null @@ -1,50 +0,0 @@ -const { WebhookClient } = require('discord.js'); -const request = require('node-superfetch'); -const { embedURL } = require('../util/Util'); - -module.exports = class MemePosterClient extends WebhookClient { - constructor(id, token, options) { - super(id, token, options); - - this.subreddits = options.subreddits; - this.postTypes = options.postTypes; - this.postInterval = options.postInterval ? Number.parseFloat(options.postInterval) : 3.6e+6; - } - - post(post) { - const url = embedURL(post.title, ``); - return this.send(`**r/${post.subreddit}** ${url}\n${post.url}`); - } - - async fetchRandomPost(nsfw) { - const subreddit = this.randomSubreddit(); - const post = await this.fetchPost(subreddit, nsfw); - return { - subreddit, - title: post.title, - url: post.url, - permalink: post.permalink, - type: post.post_hint, - nsfw: post.over_18 || false - }; - } - - async fetchPost(subreddit, nsfw) { - const { body } = await request - .get(`https://www.reddit.com/r/${subreddit}/hot.json`) - .query({ limit: 100 }); - const posts = body.data.children.filter(post => { - if (!post.data) return false; - return this.postTypes.includes(post.data.post_hint) - && post.data.url - && post.data.title - && nsfw ? true : !post.data.over_18; - }); - if (!posts.length) return null; - return posts[Math.floor(Math.random() * posts.length)].data; - } - - randomSubreddit() { - return this.subreddits[Math.floor(Math.random() * this.subreddits.length)]; - } -};