-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
458 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
403 changes: 202 additions & 201 deletions
403
.yarn/releases/yarn-3.5.1.cjs → .yarn/releases/yarn-3.6.0.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 34 additions & 5 deletions
39
src/interactions/application-commands/slash-commands/fun/http-cat.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,48 @@ | ||
import type { ChatInputCommandInteraction } from 'discord.js' | ||
import type { AutocompleteInteraction, ChatInputCommandInteraction } from 'discord.js' | ||
import { ApplyOptions } from '../../../../utils/decorators' | ||
import { Command } from '../base' | ||
import type { CommandOptions } from '..' | ||
import { injectable } from 'inversify' | ||
|
||
const AVAILABLE_STATUS_CODES = [ | ||
100, 101, 102, | ||
100, 101, 102, 103, | ||
200, 201, 202, 203, 204, 206, 207, | ||
300, 301, 302, 303, 304, 305, 307, 308, | ||
400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 420, 421, 422, 423, | ||
424, 425, 426, 429, 431, 444, 450, 451, 497, 498, 499, | ||
500, 501, 502, 503, 504, 506, 507, 508, 509, 510, 511, 521, 523, 525, 599 | ||
500, 501, 502, 503, 504, 506, 507, 508, 509, 510, 511, 521, 522, 523, 525, 599 | ||
] | ||
|
||
@ApplyOptions<CommandOptions>({ | ||
command: { | ||
args: [ | ||
{ | ||
key: 'statuscode', | ||
name: 'statusCode', | ||
validate: (val: string) => AVAILABLE_STATUS_CODES.includes(parseInt(val)), | ||
required: false | ||
} | ||
] | ||
} | ||
}) | ||
@injectable() | ||
export default class HttpCatCommand extends Command { | ||
public async execute (interaction: ChatInputCommandInteraction): Promise<void> { | ||
await interaction.reply(`https://http.cat/${AVAILABLE_STATUS_CODES[Math.floor(Math.random() * AVAILABLE_STATUS_CODES.length)]}`) | ||
public async execute ( | ||
interaction: ChatInputCommandInteraction, | ||
{ statusCode }: { statusCode: number } | ||
): Promise<void> { | ||
statusCode ??= AVAILABLE_STATUS_CODES[Math.floor(Math.random() * AVAILABLE_STATUS_CODES.length)] | ||
await interaction.reply(`https://http.cat/${statusCode}`) | ||
} | ||
|
||
public override async autocomplete (interaction: AutocompleteInteraction): Promise<void> { | ||
const option = interaction.options.getFocused(true) | ||
if (option.name === 'statuscode') { | ||
const results = AVAILABLE_STATUS_CODES.map(String).filter(statusCode => statusCode.startsWith(option.value)) | ||
await interaction.respond(results.map(result => ({ name: result, value: result })).slice(0, 25)) | ||
return | ||
} | ||
|
||
await super.autocomplete(interaction) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 12 additions & 3 deletions
15
src/interactions/data/application-commands/slash-commands/fun/http-cat.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
import type { RESTPutAPIApplicationCommandsJSONBody } from 'discord.js' | ||
import { | ||
ApplicationCommandOptionType, | ||
type RESTPutAPIApplicationCommandsJSONBody | ||
} from 'discord.js' | ||
|
||
const httpCatCommand: RESTPutAPIApplicationCommandsJSONBody[number] = { | ||
name: 'httpcat', | ||
description: 'Posts a picture of a random HTTP cat', | ||
default_member_permissions: null | ||
description: 'Posts a picture of a HTTP cat', | ||
default_member_permissions: null, | ||
options: [{ | ||
name: 'statuscode', | ||
description: 'Status code to post a HTTP cat picture of', | ||
type: ApplicationCommandOptionType.Integer, | ||
autocomplete: true | ||
}] | ||
} | ||
|
||
export default httpCatCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.