Remove Meme Poster Webhook

This commit is contained in:
Dragon Fire
2021-02-22 20:02:21 -05:00
parent 76697b1a8f
commit b0faaa5316
6 changed files with 1 additions and 78 deletions
-3
View File
@@ -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=
-1
View File
@@ -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`.
-12
View File
@@ -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();
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "129.9.1",
"version": "130.0.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
-11
View File
@@ -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);
-50
View File
@@ -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, `<https://www.reddit.com${post.permalink}>`);
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)];
}
};