Skip to content

Commit

Permalink
Verification groundwork
Browse files Browse the repository at this point in the history
- Add role for verifiers to config
- Update types accordingly
- Move verification from handler to lib
- Process button presses instead of dropping them
  • Loading branch information
SomeAspy committed Jul 7, 2023
1 parent 8cfca0d commit 549752f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"CollectionName": "database",
"MaxBadges": 5,
"PromptChannel": "ChannelID",
"VerifierRole": "554356800",
"Domains": [
"media.discordapp.net",
"cdn.discordapp.com",
Expand Down
39 changes: 35 additions & 4 deletions src/commands/manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../mongo.js';

import untypedConfig from '../../config/config.json' assert { type: 'json' };
import { fireVerification } from '../handler/verification.js';
import { fireVerification } from '../lib/verification.js';
import { isAllowedDomain } from '../lib/checkDomain.js';
import { Badge } from '../types/badge.js';

Expand Down Expand Up @@ -183,9 +183,40 @@ export async function execute(interaction: ChatInputCommandInteraction) {

export const buttons = [
{
id: 'manage.delete',
execute: async function (interaction: ButtonInteraction) {
await interaction.reply('Button clicked!');
id: 'verify.accept',
execute: async (interaction: ButtonInteraction) => {
if (interaction.inCachedGuild()) {
if (interaction.member.roles.cache.has(settings.VerifierRole)) {
await interaction.reply({
content: '`verify.accept`',
ephemeral: true,
});
} else {
await interaction.reply({
content: 'You cannot do that!',
ephemeral: true,
});
}
}
console.log(interaction);
},
},
{
id: 'verify.deny',
execute: async (interaction: ButtonInteraction) => {
if (interaction.inCachedGuild()) {
if (interaction.member.roles.cache.has(settings.VerifierRole)) {
await interaction.reply({
content: '`verify.deny`',
ephemeral: true,
});
} else {
await interaction.reply({
content: 'You cannot do that!',
ephemeral: true,
});
}
}
},
},
];
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ client.on(Events.InteractionCreate, async (interaction) => {
commands,
);
} else if (interaction.isButton()) {
// L13 - handler/button.ts - This should probably be async, but we will have to see
handleButton(interaction, client, commands);
} else if (interaction.isAutocomplete()) {
await handleAutocomplete(interaction, client, commands);
Expand Down
4 changes: 4 additions & 0 deletions src/handler/verification.ts → src/lib/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export async function fireVerification(data: ChatInputCommandInteraction) {
.setStyle(ButtonStyle.Danger)
.setEmoji('✖️');

/*
We may want to embed some data into the embed somewhere... ex. user ID, badge, etc.
*/

const embed = new EmbedBuilder()
.setAuthor({
name: user.username,
Expand Down
1 change: 1 addition & 0 deletions src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface Config {
CollectionName: string;
MaxBadges: number;
PromptChannel: string;
VerifierRole: string;
Domains: string[];
}

Expand Down

0 comments on commit 549752f

Please sign in to comment.