Skip to content

Commit

Permalink
Improve errors when removing player from group or competition (#239)
Browse files Browse the repository at this point in the history
* Improve errors when removing player from group or competition

* Add variables to .env.example
  • Loading branch information
rorro authored Feb 6, 2024
1 parent f72a728 commit e1a0ade
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 27 deletions.
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ DISCORD_TOKEN=
# https://docs.wiseoldman.net/#rate-limits--api-keys
DISCORD_BOT_API_KEY=

DISCORD_DEV_GUILD_ID=
DISCORD_DEV_CLIENT_ID=
DISCORD_DEV_MODERATOR_ROLE_ID=
DISCORD_DEV_GROUP_LEADER_ROLE_ID=
DISCORD_DEV_API_CONSUMER_ROLE_ID=
DISCORD_DEV_PATREON_SUPPORTER_ROLE_ID=
DISCORD_DEV_PATREONT2_SUPPOERTER_ROLE_ID=

DISCORD_DEV_FLAG_CHANNEL_ID=
DISCORD_DEV_MODSLOGS_CHANNEL_ID=
DISCORD_DEV_PATREON_INFO_CHANNEL_ID=
DISCORD_DEV_FLAGGED_REVIEWS_CHANNEL_ID=

DISCORD_DEV_LOCAL=true


Expand Down
23 changes: 14 additions & 9 deletions src/commands/instances/moderation/RemoveFromCompetitionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ class RemoveFromCompetitionCommand extends Command {

const requester = interaction.guild?.members.cache.find(m => m.id === requesterId);

await removeFromCompetition(competitionId, username);

// Respond on the WOM discord chat with a success status
const response = new MessageEmbed()
.setColor(config.visuals.green)
.setDescription(`✅ ${username} has been successfully removed from the competition.`);

await interaction.editReply({ embeds: [response] });
try {
await removeFromCompetition(competitionId, username);

await interaction.editReply({ embeds: [response] });

sendModLog(
interaction.guild,
`Removed \`${username}\` from competition (ID: ${competitionId})`,
interaction.user,
requester?.user
);
sendModLog(
interaction.guild,
`Removed \`${username}\` from competition (ID: ${competitionId})`,
interaction.user,
requester?.user
);
} catch (e) {
response.setColor(config.visuals.red).setDescription(`${e.message}`);
await interaction.editReply({ embeds: [response] });
}
}
}

Expand Down
23 changes: 14 additions & 9 deletions src/commands/instances/moderation/RemoveFromGroupCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ class RemoveFromGroupCommand extends Command {

const requester = interaction.guild?.members.cache.find(m => m.id === requesterId);

await removeFromGroup(groupId, username);

// Respond on the WOM discord chat with a success status
const response = new MessageEmbed()
.setColor(config.visuals.green)
.setDescription(`✅ ${username} has been successfully removed from the group.`);

await interaction.editReply({ embeds: [response] });
try {
await removeFromGroup(groupId, username);

await interaction.editReply({ embeds: [response] });

sendModLog(
interaction.guild,
`Removed \`${username}\` from group (ID: ${groupId})`,
interaction.user,
requester?.user
);
sendModLog(
interaction.guild,
`Removed \`${username}\` from group (ID: ${groupId})`,
interaction.user,
requester?.user
);
} catch (e) {
response.setColor(config.visuals.red).setDescription(`${e.message}`);
await interaction.editReply({ embeds: [response] });
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ export default {
guildId: env.DISCORD_DEV_GUILD_ID || '679454777708380161',
clientId: env.DISCORD_DEV_CLIENT_ID || '719720369241718837',
roles: {
moderator: '705821689526747136',
groupLeader: '705826389474934845',
apiConsumer: '713452544164233296',
patreonSupporter: '1169327347032412300',
patreonSupporterT2: '1178310263154417735'
moderator: env.DISCORD_DEV_MODERATOR_ROLE_ID || '705821689526747136',
groupLeader: env.DISCORD_DEV_GROUP_LEADER_ROLE_ID || '705826389474934845',
apiConsumer: env.DISCORD_DEV_API_CONSUMER_ROLE_ID || '713452544164233296',
patreonSupporter: env.DISCORD_DEV_PATREON_SUPPORTER_ROLE_ID || '1169327347032412300',
patreonSupporterT2: env.DISCORD_DEV_PATREONT2_SUPPOERTER_ROLE_ID || '1178310263154417735'
},
channels: {
flags: '802680940835897384',
modLogs: '830199626630955039',
patreonInfo: '1173680059526152272',
flaggedPlayerReviews: '1086637095415722169'
flags: env.DISCORD_DEV_FLAG_CHANNEL_ID || '802680940835897384',
modLogs: env.DISCORD_DEV_MODSLOGS_CHANNEL_ID || '830199626630955039',
patreonInfo: env.DISCORD_DEV_PATREON_INFO_CHANNEL_ID || '1173680059526152272',
flaggedPlayerReviews: env.DISCORD_DEV_FLAGGED_REVIEWS_CHANNEL_ID || '1086637095415722169'
}
}
};

0 comments on commit e1a0ade

Please sign in to comment.