You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.1 KiB
56 lines
2.1 KiB
3 years ago
|
import {CommandContext, CommandOptionType, SlashCommand, SlashCreator} from "slash-create";
|
||
|
import {SavedWebhook} from "../../SavedWebhook.js";
|
||
|
import {Chance} from "chance";
|
||
|
|
||
|
const rand = Chance()
|
||
|
|
||
|
export class PullCommand extends SlashCommand {
|
||
|
readonly gameWebhook: SavedWebhook
|
||
|
|
||
|
constructor(creator: SlashCreator, gameWebhook: SavedWebhook) {
|
||
|
super(creator, {
|
||
|
name: "pull",
|
||
|
guildIDs: gameWebhook.state?.guild_id,
|
||
|
description: "Pulls one or more new heroines from the ether.",
|
||
|
options: [
|
||
|
{
|
||
|
name: "count",
|
||
|
description: "The number of heroines to pull.",
|
||
|
required: false,
|
||
|
max_value: 10,
|
||
|
min_value: 1,
|
||
|
type: CommandOptionType.NUMBER,
|
||
|
}
|
||
|
]
|
||
|
});
|
||
|
this.gameWebhook = gameWebhook
|
||
|
}
|
||
|
|
||
|
run(ctx: CommandContext): Promise<any> {
|
||
|
if (ctx.guildID !== this.gameWebhook.state?.guild_id) {
|
||
|
return ctx.send({
|
||
|
content: "Sorry, you can't do that in this guild.",
|
||
|
ephemeral: true,
|
||
|
})
|
||
|
}
|
||
|
if (ctx.channelID !== this.gameWebhook.state?.channel_id) {
|
||
|
return ctx.send({
|
||
|
content: `Sorry, you can't do that here. You have to do it in <#${this.gameWebhook.state?.channel_id}>.`,
|
||
|
ephemeral: true,
|
||
|
})
|
||
|
}
|
||
|
const count: number = ctx.options.count ?? 1
|
||
|
const results: string[] = []
|
||
|
for (let x = 0; x < count; x += 1) {
|
||
|
results.push(rand.weighted(["**Nicole**: D tier Predator Podcaster",
|
||
|
"**Herja**: C tier Viking Warrior",
|
||
|
"**Sharla**: B tier Skark Girl",
|
||
|
"**Melpomene**: A tier Muse of Tragedy",
|
||
|
"**Lady Bootstrap**: S tier Time Traveler"], [20, 15, 10, 5, 1]))
|
||
|
}
|
||
|
return ctx.send({
|
||
|
content: `_${ctx.user.mention}_, you pulled...\n \\* ${results.join("\n \\* ")}`,
|
||
|
ephemeral: false,
|
||
|
})
|
||
|
}
|
||
|
}
|