1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { Command, CommandoMessage } from 'discord.js-commando';
import SubredditCommandBase from '../../models/commands/Subreddit.js'
import { shorten, formatNumber } from '../../utils/Util.js'
import { MessageEmbed } from 'discord.js';
module.exports = class SubredditFun extends SubredditCommandBase {
constructor(client) {
super(client, {
name: 'subreddit',
aliases: ['r/', 'sub', 'reddit'],
patterns: [/^r\/(.+)/i],
group: 'fun',
memberName: 'subreddit',
description: 'Replies with a random post from a specified subreddit.',
args: [
{
key: 'sSub',
prompt: 'Which subreddit would you like to get a post from?',
type: 'string',
parse: subreddit => encodeURIComponent(subreddit)
}
],
examples: ['uwu!say hi'],
throttling: {
usages: 5,
duration: 30
},
userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY']
});
}
generateText(post, subreddit, icon) {
const embed = new MessageEmbed()
.setColor(0xFFCC4D)
.setAuthor(`r/${subreddit}`, icon, `https://www.reddit.com/r/${subreddit}/`)
.setTitle(shorten(post.title, 256))
.setImage(post.post_hint === 'image' ? post.url : null)
.setURL(`https://www.reddit.com${post.permalink}`)
.setTimestamp(post.created_utc * 1000)
.setFooter(`⬆ ${formatNumber(post.score)}`);
if (post.thumbnail && post.thumbnail !== 'self' && post.post_hint !== 'image') {
embed.setThumbnail(post.thumbnail);
}
return embed;
}
};
|