-
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.
* Create blacklist.ts * Create blacklist.ts * Create blacklist.ts * Create blacklist.ts * feat: start with blacklist command * feat: command shortening * fix: ts errors * feat: move back to cjs * feat: add blacklist command * feat: add CI (#84) * Create commit-msg * Create pre-commit * Create .commitlintrc.json * Create .editorconfig * Create .eslintrc.json * Create .eslintignore * Create .gitattributes * Create tsconfig.eslint.json * Update package.json * Create .lintstagedrc.json * Create eslint.json * Create tsc.json * Create continuous-integration.yml * Update package.json * Create extensions.json * Create settings.json * feat: update lock file * feat: add eslint-plugin-prettier * fix: eslint errors * fix: more eslint errors * Create blacklist.ts * feat: start with blacklist command * feat: command shortening * fix: ts errors * feat: move back to cjs * feat: add blacklist command * fix: eslint errors * feat: NotBlacklisted * fix: eslint errors * feat: add NotBlacklisted precondition to commands * fix: ts errors * fix: ts errors * feat: add blacklisted check Co-authored-by: Jaron <jaron_zijlstra@outlook.com> Co-authored-by: Jaron <60853956+JaronZ@users.noreply.github.com>
- Loading branch information
1 parent
46201a7
commit e227f64
Showing
22 changed files
with
129 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {SlashCommandBuilder} from "@discordjs/builders"; | ||
import {ApplyOptions} from "@sapphire/decorators"; | ||
import type {ApplicationCommandRegistry, CommandOptions} from "@sapphire/framework"; | ||
import {CommandInteraction, MessageEmbed} from "discord.js"; | ||
import {Command} from "../lib/Command"; | ||
|
||
@ApplyOptions<CommandOptions>({ | ||
description: "blacklist" | ||
}) | ||
export class BlacklistCommand extends Command { | ||
public registerApplicationCommands(registry: ApplicationCommandRegistry) { | ||
registry.registerChatInputCommand( | ||
new SlashCommandBuilder() | ||
.setName(this.name) | ||
.setDescription(this.description) | ||
.addUserOption(input => input.setName("user").setDescription("the user to blacklist").setRequired(true)) | ||
.addStringOption(input => | ||
input.setName("reason").setDescription("reason why for being blacklisted").setRequired(true) | ||
), | ||
{ | ||
guildIds: ["863878432697614337"] | ||
} | ||
); | ||
} | ||
|
||
public async chatInputRun(interaction: CommandInteraction) { | ||
await interaction.deferReply(); | ||
|
||
const user = interaction.options.getUser("user", true); | ||
const reason = interaction.options.getString("reason", true); | ||
|
||
if (await this.container.prisma.blacklist.findUnique({where: {user: user.id}})) { | ||
return interaction.editReply({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("RED") | ||
.setTitle("User already blacklisted") | ||
.setDescription(`${user} is already blacklisted.`) | ||
] | ||
}); | ||
} | ||
|
||
await this.container.prisma.blacklist.create({ | ||
data: { | ||
user: user.id, | ||
reason, | ||
author: interaction.user.id | ||
} | ||
}); | ||
|
||
return interaction.editReply({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor("GREEN") | ||
.setTitle("User blacklisted") | ||
.setDescription(`${user} has been blacklisted`) | ||
] | ||
}); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {Command as SapphireCommand, PieceContext} from "@sapphire/framework"; | ||
|
||
export abstract class Command extends SapphireCommand { | ||
public constructor(context: PieceContext, options: SapphireCommand.Options) { | ||
super(context, { | ||
...options, | ||
preconditions: [...(options.preconditions ?? []), "NotBlacklisted"] | ||
}); | ||
} | ||
} |
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,20 @@ | ||
import {Precondition} from "@sapphire/framework"; | ||
import type {CommandInteraction} from "discord.js"; | ||
|
||
export class NotBlacklistedPrecondition extends Precondition { | ||
public async chatInputRun(interaction: CommandInteraction) { | ||
return (await this.container.prisma.blacklist.findUnique({ | ||
where: { | ||
user: interaction.user.id | ||
} | ||
})) | ||
? this.error({message: "You are blacklisted"}) | ||
: this.ok(); | ||
} | ||
} | ||
|
||
declare module "@sapphire/framework" { | ||
interface Preconditions { | ||
NotBlacklisted: never; | ||
} | ||
} |
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