mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 17:04:15 +02:00
feat(arabot): add a check if the user is restricted when trying to gain access to the server
This commit is contained in:
parent
1f92bf5d68
commit
98b9ac6fde
@ -21,8 +21,14 @@ import {
|
|||||||
InteractionHandler,
|
InteractionHandler,
|
||||||
InteractionHandlerTypes,
|
InteractionHandlerTypes,
|
||||||
} from '@sapphire/framework';
|
} from '@sapphire/framework';
|
||||||
import type { ButtonInteraction, GuildMember, TextChannel } from 'discord.js';
|
import {
|
||||||
|
ButtonInteraction,
|
||||||
|
GuildMember,
|
||||||
|
MessageFlagsBitField,
|
||||||
|
TextChannel,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '#utils/ids';
|
import IDs from '#utils/ids';
|
||||||
|
import { checkActive } from '#utils/database/moderation/restriction';
|
||||||
|
|
||||||
export class WelcomeButtonHandler extends InteractionHandler {
|
export class WelcomeButtonHandler extends InteractionHandler {
|
||||||
public constructor(
|
public constructor(
|
||||||
@ -54,7 +60,7 @@ export class WelcomeButtonHandler extends InteractionHandler {
|
|||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content:
|
content:
|
||||||
'There was an error giving you the role, please try again later or contact ModMail to be let into this server.',
|
'There was an error giving you the role, please try again later or contact ModMail to be let into this server.',
|
||||||
ephemeral: true,
|
flags: MessageFlagsBitField.Flags.Ephemeral,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,6 +68,16 @@ export class WelcomeButtonHandler extends InteractionHandler {
|
|||||||
try {
|
try {
|
||||||
member = member as GuildMember;
|
member = member as GuildMember;
|
||||||
|
|
||||||
|
// Checks if the user is currently restricted
|
||||||
|
if (await checkActive(member.id)) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: `You are currently restricted from this server! Contact the moderators by sending a DM to <@${IDs.modMail}>.`,
|
||||||
|
flags: MessageFlagsBitField.Flags.Ephemeral,
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Give non-vegan role
|
// Give non-vegan role
|
||||||
if (!member.voice.channel) {
|
if (!member.voice.channel) {
|
||||||
await member.roles.add(IDs.roles.nonvegan.nonvegan);
|
await member.roles.add(IDs.roles.nonvegan.nonvegan);
|
||||||
@ -78,13 +94,13 @@ export class WelcomeButtonHandler extends InteractionHandler {
|
|||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content:
|
content:
|
||||||
"You're currently in a verification, you'll have to leave the verification or get verified before being able to access the server again.",
|
"You're currently in a verification, you'll have to leave the verification or get verified before being able to access the server again.",
|
||||||
ephemeral: true,
|
flags: MessageFlagsBitField.Flags.Ephemeral,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content:
|
content:
|
||||||
'There was an error giving you the role, please try again later or contact ModMail to be let into this server.',
|
'There was an error giving you the role, please try again later or contact ModMail to be let into this server.',
|
||||||
ephemeral: true,
|
flags: MessageFlagsBitField.Flags.Ephemeral,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,7 @@ const devIDs = {
|
|||||||
private: '999431679527628818',
|
private: '999431679527628818',
|
||||||
restricted: '999431679812845654',
|
restricted: '999431679812845654',
|
||||||
},
|
},
|
||||||
|
modMail: '575252669443211264',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default devIDs;
|
export default devIDs;
|
||||||
|
@ -143,6 +143,7 @@ let IDs = {
|
|||||||
private: '992581296901599302',
|
private: '992581296901599302',
|
||||||
restricted: '809765577236283472',
|
restricted: '809765577236283472',
|
||||||
},
|
},
|
||||||
|
modMail: '575252669443211264',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if the bot is in development mode
|
// Check if the bot is in development mode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user