Skip to content

Commit cfb1b60

Browse files
committed
Add .badmeme and /fun badmeme
1 parent 9ca9995 commit cfb1b60

File tree

6 files changed

+85
-42
lines changed

6 files changed

+85
-42
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Interaction } from 'detritus-client';
2+
3+
import { Formatter } from '../../../../utils';
4+
5+
import { BaseInteractionCommandOption } from '../../basecommand';
6+
7+
8+
export const COMMAND_NAME = 'badmeme';
9+
10+
export class BadMemeCommand extends BaseInteractionCommandOption {
11+
description = 'Show a Bad Meme';
12+
metadata = {
13+
id: Formatter.Commands.FunBadMeme.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.FunBadMeme.CommandArgs) {
18+
return Formatter.Commands.FunBadMeme.createMessage(context, args);
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Permissions } from 'detritus-client/lib/constants';
2+
3+
import { BaseSlashCommand } from '../../basecommand';
4+
5+
import { BadMemeCommand } from './badmeme';
6+
7+
8+
export default class FunGroupCommand extends BaseSlashCommand {
9+
description = '.';
10+
name = 'fun';
11+
12+
constructor() {
13+
super({
14+
permissions: [Permissions.ATTACH_FILES],
15+
options: [
16+
new BadMemeCommand(),
17+
],
18+
});
19+
}
20+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Command, CommandClient } from 'detritus-client';
2+
3+
import { CommandCategories } from '../../../constants';
4+
import { Formatter } from '../../../utils';
5+
6+
import { BaseCommand } from '../basecommand';
7+
8+
9+
export const COMMAND_NAME = 'badmeme';
10+
11+
export default class BadMemeCommand extends BaseCommand {
12+
constructor(client: CommandClient) {
13+
super(client, {
14+
name: COMMAND_NAME,
15+
16+
metadata: {
17+
category: CommandCategories.FUN,
18+
description: 'Show a Bad Meme',
19+
examples: [
20+
COMMAND_NAME,
21+
],
22+
id: Formatter.Commands.FunBadMeme.COMMAND_ID,
23+
usage: '',
24+
},
25+
});
26+
}
27+
28+
run(context: Command.Context, args: Formatter.Commands.FunBadMeme.CommandArgs) {
29+
return Formatter.Commands.FunBadMeme.createMessage(context, args);
30+
}
31+
}

src/commands/prefixed/search/badmeme.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/utils/formatter/commands/search.badmeme.ts renamed to src/utils/formatter/commands/fun.badmeme.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { RequestTypes } from 'detritus-client-rest';
55
import { searchImgur } from '../../../api';
66
import { RestResponsesRaw } from '../../../api/types';
77
import { DiscordEmojis, EmbedBrands, EmbedColors } from '../../../constants';
8-
import { DefaultParameters, Paginator, createUserEmbed, editOrReply, shuffleArray } from '../../../utils';
8+
import { DefaultParameters, Paginator, createUserEmbed, editOrReply, shuffleArray } from '../..';
99

1010

11-
export const COMMAND_ID = 'search.badmeme';
11+
export const COMMAND_ID = 'fun.badmeme';
1212

1313
export interface CommandArgs {
1414

@@ -23,9 +23,16 @@ export async function createMessage(
2323
const results = shuffleArray<RestResponsesRaw.SearchImgurResult>(await searchImgur(context, {query: 'meme'}));
2424
if (results.length) {
2525
const embed = (isFromInteraction) ? new Embed() : createUserEmbed(context.user);
26-
embed.setColor(EmbedColors.DEFAULT);
27-
embed.setThumbnail(results[0].thumbnail);
28-
return editOrReply(context, {embed});
26+
embed.setColor(EmbedColors.DARK_MESSAGE_BACKGROUND);
27+
embed.setImage(results[0].thumbnail);
28+
29+
const url = results[0].thumbnail;
30+
const filename = url.split('/').pop()!;
31+
embed.setImage(`attachment://${filename}`);
32+
return editOrReply(context, {
33+
embed,
34+
file: {filename, value: await context.rest.get(url)},
35+
});
2936
}
3037
return editOrReply(context, 'Couldn\'t find any bad memes');
3138
}

src/utils/formatter/commands/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as AudioConvert from './audio.convert';
22
import * as AudioIdentify from './audio.identify';
33

44
import * as FunAesthetics from './fun.aesthetics';
5+
import * as FunBadMeme from './fun.badmeme';
56
import * as FunEmoji from './fun.emoji';
67
import * as FunRegional from './fun.regional';
78
import * as FunTextwall from './fun.textwall';
@@ -73,7 +74,6 @@ import * as ReminderDelete from './reminder.delete';
7374
import * as ReminderListUser from './reminder.list.user';
7475

7576
import * as Search4Chan from './search.4chan';
76-
import * as SearchBadMeme from './search.badmeme';
7777
import * as SearchDiscordEmojis from './search.discord.emojis';
7878
import * as SearchGoogleImages from './search.google.images';
7979
import * as SearchGoogleWeb from './search.google.web';
@@ -116,6 +116,7 @@ export {
116116
AudioIdentify,
117117

118118
FunAesthetics,
119+
FunBadMeme,
119120
FunEmoji,
120121
FunRegional,
121122
FunTextwall,
@@ -186,7 +187,6 @@ export {
186187
ReminderListUser,
187188

188189
Search4Chan,
189-
SearchBadMeme,
190190
SearchDiscordEmojis,
191191
SearchGoogleImages,
192192
SearchGoogleWeb,

0 commit comments

Comments
 (0)