feat: handle join roles

This commit is contained in:
2024-07-07 12:28:03 -07:00
parent 34c6d2d189
commit 1d2ae0e5a1
4 changed files with 69 additions and 20 deletions

View File

@ -0,0 +1,34 @@
import { CommandHandler } from "../../../interfaces/CommandHandler";
import { errorHandler } from "../../../utils/errorHandler";
import { setConfig } from "../../data/setConfig";
/**
* Sets the role to be assigned when a member joins.
*/
export const handleJoinRole: CommandHandler = async (bot, interaction) => {
try {
const role = interaction.options.getRole("role", true);
const success = await setConfig(
bot,
interaction.guild.id,
"joinRole",
role.id
);
if (success) {
await interaction.editReply({
content: `Members will be given ${role.toString()} when they join..`
});
return;
}
await interaction.editReply({
content: "Failed to set the settings."
});
} catch (err) {
const id = await errorHandler(bot, "config join-role subcommand", err);
await interaction.editReply({
content: `Something went wrong. Please [join our support server](https://chat.naomi.lgbt) and provide this ID: \`${id}\``
});
}
};