Skip to content

Commit

Permalink
Toggle notifications button implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
GleammerRay committed Apr 18, 2024
1 parent 4fcc54b commit 8a803e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/interlinked.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ const serverListComponents = '[' +
'"id":null,' +
'"name":"👥"' +
'}' +
'},' +
'{' +
'"type":2,' +
'"custom_id":"pub",' +
'"label":"Toggle notifications",' +
'"style":2,' +
'"emoji":{' +
'"id":null,' +
'"name":"🔔"' +
'}' +
'}' +
']' +
'}' +
Expand Down Expand Up @@ -946,6 +956,14 @@ export class InterlinkedGuild {
}
return await this.#rest.createInteractionResponse(interaction, `{"type":4,"data":{"flags":${1 << 6},"content":"You will no longer be pinged. :sleeping:"}}`);
}

toggleUserPingRole(interaction) {
if (interaction.member.roles.indexOf(this.#pingRole) == -1) {
return this.addUserPingRole(interaction);
} else {
return this.removeUserPingRole(interaction);
}
}

_sendAllVariables(interaction) {
var _adminRole = null;
Expand Down Expand Up @@ -1430,6 +1448,12 @@ export class InterlinkedDiscord {
this.save();
return value;
}

async toggleUserPingRole(interaction) {
var value = await this.getOrSetGuild(interaction.guild_id).toggleUserPingRole(interaction);
this.save();
return value;
}

sendVariable(interaction) {
return this.getOrSetGuild(interaction.guild_id).sendVariable(interaction);
Expand Down Expand Up @@ -1797,6 +1821,8 @@ export class Interlinked {
return this.#discord.onListPlayersButton(interaction, this.#servers);
case 'list_players refresh':
return this.#discord.onListPlayersButton(interaction, this.#servers);
case 'pub':
return this.#discord.toggleUserPingRole(interaction);
case 'undefined':
return;
}
Expand Down

0 comments on commit 8a803e4

Please sign in to comment.