Skip to content

Commit

Permalink
use defered reply (#85)
Browse files Browse the repository at this point in the history
# Swap bot reply to a deferred reply

Change the reply for creating roles to a deferred reply to prevent the
replies from timing out.
Made quality of life change to the function signature to add arg and
typing

# Link to github card
closes #84 

# Changes
* Replace the `reply` with a `deferReply` and an `editReply`
* Change function signature and add typing
  • Loading branch information
nathen418 authored Dec 27, 2022
2 parents beadc45 + ce714f9 commit aabe656
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions commands/owner/createRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,31 @@ export default {
requiredPermissions: ["MANAGE_GUILD", "MANAGE_ROLES"],
ownerOnly: true,

callback: async ({ interaction }) => {
callback: async ({ client, interaction: msgInt }) => {
console.log(chalk.green("Creating roles..."));
console.log(
chalk.red("------------------------------------------------------")
);
if (interaction.guild === null) {
if (msgInt.guild === null) {
return;
}
await msgInt.deferReply({ ephemeral: true });

// Create the roles
await createRoles(interaction.guild, classModel);
await createRoles(interaction.guild, staffModel);
await createRoles(interaction.guild, yearModel);
interaction.reply({
await createRoles(msgInt.guild, classModel);
await createRoles(msgInt.guild, staffModel);
await createRoles(msgInt.guild, yearModel);
msgInt.editReply({
content: "Roles created!",
ephemeral: true,
});

// Log the command usage
console.log(
chalk.blue(
`${chalk.green(`[COMMAND]`)} ${chalk.yellow(
interaction.user.tag
)} used the ${chalk.green(`/yearPoll`)} command in ${chalk.yellow(
interaction.guild?.name
msgInt.user.tag
)} used the ${chalk.green(`/createRoles`)} command in ${chalk.yellow(
msgInt.guild?.name
)}`
)
);
Expand Down

0 comments on commit aabe656

Please sign in to comment.