-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to command abstraction and support loading components fr…
…om subdirectories
- Loading branch information
1 parent
0ce42c0
commit 6f6c1e0
Showing
5 changed files
with
196 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as Discord from "discord.js"; | ||
|
||
import { strict as assert } from "assert"; | ||
|
||
import { M } from "../../utils.js"; | ||
import { colors } from "../../common.js"; | ||
import { BotComponent } from "../../bot-component.js"; | ||
import { Wheatley } from "../../wheatley.js"; | ||
import { TextBasedCommand, TextBasedCommandBuilder } from "../../command.js"; | ||
|
||
/** | ||
* Implements !mute | ||
*/ | ||
export default class Mute extends BotComponent { | ||
static override get is_freestanding() { | ||
return true; | ||
} | ||
|
||
constructor(wheatley: Wheatley) { | ||
super(wheatley); | ||
|
||
this.add_command( | ||
new TextBasedCommandBuilder("wmute") | ||
.set_description("wmute") | ||
.add_user_option({ | ||
title: "user", | ||
description: "User to mute", | ||
required: true, | ||
}) | ||
.add_string_option({ | ||
title: "duration", | ||
description: "Duration", | ||
regex: /(?:perm\b|\d+\s*[mhdwMy])/, | ||
required: true, | ||
}) | ||
.add_string_option({ | ||
title: "reason", | ||
description: "Reason", | ||
required: true, | ||
}) | ||
.set_handler(this.handler.bind(this)), | ||
); | ||
} | ||
|
||
async handler(command: TextBasedCommand, user: Discord.User, time: string, reason: string) { | ||
await command.reply(JSON.stringify([user.displayName, time, reason])); | ||
} | ||
} |
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