-
Notifications
You must be signed in to change notification settings - Fork 24
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
1 parent
2c757d6
commit 5486ff6
Showing
2 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
type CommandInteraction, | ||
type PermissionsString, | ||
SlashCommandBuilder, | ||
SlashCommandStringOption, | ||
} from "discord.js"; | ||
|
||
import type { ApplicationCommand } from "../command.js"; | ||
import type { BotContext } from "../../context.js"; | ||
|
||
export default class GhostwriterCommand implements ApplicationCommand { | ||
name = "gw"; | ||
description = "Goethe sein Vater"; | ||
requiredPermissions: readonly PermissionsString[] = ["BanMembers"]; | ||
lastBlame: Date | null = null; | ||
get applicationCommand() { | ||
return new SlashCommandBuilder() | ||
.setName(this.name) | ||
.setDescription(this.description) | ||
.setDefaultMemberPermissions(0) | ||
.addStringOption( | ||
new SlashCommandStringOption() | ||
.setRequired(true) | ||
.setName("content") | ||
.setDescription("Inhalt"), | ||
) | ||
.addStringOption( | ||
new SlashCommandStringOption() | ||
.setRequired(false) | ||
.setName("reply") | ||
.setDescription("Antwort auf"), | ||
); | ||
} | ||
|
||
async handleInteraction(command: CommandInteraction, context: BotContext): Promise<void> { | ||
if (!command.isChatInputCommand()) { | ||
// TODO: Solve this on a type level | ||
return; | ||
} | ||
|
||
/*if (isMarcel(command.user)) { | ||
await command.reply({ content: "Ne alter, du machst wieder nur Scheiße", ephemeral: true }); | ||
const now = new Date(); | ||
if (this.lastBlame !== null && (now.getTime() - this.lastBlame.getTime()) < 1 * 1000 * 60 * 60) { | ||
return; | ||
} | ||
const { hauptchat } = context.textChannels; | ||
await hauptchat.send({ | ||
content: "**ICH BITTE UM AUFMERKSAMKEIT, ALLE MAL HERHÖREN** \nMarcel wollte wieder Marceldinge tun aber ich habe das erfolgreich verhindern können.\nVielen Dank für eure Aufmerksamkeit, weitermachen." | ||
}); | ||
this.lastBlame = new Date(); | ||
return; | ||
}*/ | ||
|
||
const content = command.options.getString("content", true); | ||
const reply = command.options.getString("reply", false); | ||
const { channel } = command; | ||
|
||
if (!channel?.isTextBased()) { | ||
return; | ||
} | ||
|
||
const replyMessage = reply ? await channel.messages.fetch(reply) : undefined; | ||
if (replyMessage) { | ||
await replyMessage.reply(content); | ||
} else { | ||
await channel.send(content); | ||
} | ||
await command.reply({ content: "Okay mein Ghoete", ephemeral: true }); | ||
} | ||
} |
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