Skip to content

Commit

Permalink
End of command guildelder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ntalcme committed Jan 8, 2025
1 parent d65f1be commit ed82e5b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Core/src/commands/guild/GuildElderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async function isEligible(player: Player, promotedPlayer: Player, response: Draf
*/
async function acceptGuildElder(player: Player, promotedPlayer: Player, response: DraftBotPacket[]): Promise<void> {
await player.reload();
// Do all necessary checks again just in case something changed during the menu
if (!await isEligible(player, promotedPlayer, response)) {
return;
}
Expand Down Expand Up @@ -97,7 +98,10 @@ export default class GuildElderCommand {
if (!await isEligible(player, promotedPlayer, response)) {
return;
}
const guildName = (await Guilds.getById(player.guildId)).name;

const collector = new ReactionCollectorGuildElder(
guildName,
promotedPlayer.keycloakId
);

Expand All @@ -112,6 +116,7 @@ export default class GuildElderCommand {
}));
}
BlockingUtils.unblockPlayer(player.id, BlockingConstants.REASONS.GUILD_ELDER);
BlockingUtils.unblockPlayer(promotedPlayer.id, BlockingConstants.REASONS.GUILD_ELDER);
};

const collectorPacket = new ReactionCollectorInstance(
Expand All @@ -124,6 +129,7 @@ export default class GuildElderCommand {
endCallback
)
.block(player.id, BlockingConstants.REASONS.GUILD_ELDER)
.block(promotedPlayer.id, BlockingConstants.REASONS.GUILD_ELDER)
.build();

response.push(collectorPacket);
Expand Down
3 changes: 2 additions & 1 deletion Discord/src/commands/guild/GuildElderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export async function createGuildElderCollector(packet: ReactionCollectorCreatio
.setDescription(
i18n.t("commands:guildElder.confirmDesc", {
lng: interaction.userLanguage,
elderPseudo: elderPlayer.attributes.gameUsername
elderPseudo: elderPlayer.attributes.gameUsername,
guildName: data.guildName
})
);

Expand Down
4 changes: 2 additions & 2 deletions Lang/fr/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"chiefError": "En tant que chef de la guilde, vous ne pouvez pas être l'aîné.",
"alreadyElder": "Le joueur est déjà aîné de votre guilde.",
"title": "{{pseudo}}, confirmez-vous votre choix ?",
"confirmDesc": ":question: {{elderPseudo}} deviendra l'aîné de la guilde `{guildName}`.",
"successElderAddTitle": "{{elderPseudo}} est le nouvel aîné de la guilde {guildName} !",
"confirmDesc": ":question: {{elderPseudo}} deviendra l'aîné de la guilde `{{guildName}}`.",
"successElderAddTitle": "{{elderPseudo}} est le nouvel aîné de la guilde {{guildName}} !",
"acceptedDesc": "L'aîné sert à aider le chef dans la gestion de la guilde. Il faut donc le choisir avec prudence ! Mais rassurez-vous, si vous n'êtes pas satisfait de votre aîné, vous pouvez le remplacer avec la commande {command:guildelder}, ou si vous avez une âme de dictateur, vous pouvez définitivement le supprimer avec {command:guildelderremove}.",
"canceledDesc": "L'aîné n'a pas été promu.",
"canceledTitle": "Annulation prise en compte.",
Expand Down
8 changes: 7 additions & 1 deletion Lib/src/packets/interaction/ReactionCollectorGuildElder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ import {
} from "./ReactionCollectorPacket";

export class ReactionCollectorGuildElderData extends ReactionCollectorData {
guildName!: string;

promotedKeycloakId!: string;
}

export class ReactionCollectorGuildElder extends ReactionCollector {
private readonly guildName: string;

private readonly promotedKeycloakId: string;

constructor(promotedKeycloakId: string) {
constructor(guildName: string, promotedKeycloakId: string) {
super();
this.guildName = guildName;
this.promotedKeycloakId = promotedKeycloakId;
}

Expand All @@ -27,6 +32,7 @@ export class ReactionCollectorGuildElder extends ReactionCollector {
this.buildReaction(ReactionCollectorRefuseReaction, {})
],
data: this.buildData(ReactionCollectorGuildElderData, {
guildName: this.guildName,
promotedKeycloakId: this.promotedKeycloakId
})
};
Expand Down

0 comments on commit ed82e5b

Please sign in to comment.