Created
June 1, 2021 04:13
-
-
Save LostLuma/308b23bcf46265daca1042a95ee2ac7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adds a `/pronouns` slash command to the server | |
// Configure the roles you would like to use here | |
// The record maps choice name -> Discord role ID | |
const PRONOUN_ROLES: Record<string, string> = { | |
'she/her': '823327679855591454', | |
'he/him': '823327736277106698', | |
'they/them': '823328487549042688' | |
}; | |
const group = discord.interactions.commands.registerGroup({ | |
name: 'pronouns', | |
description: 'Choose which pronoun roles you have in the server.' | |
}); | |
group.register( | |
{ | |
name: 'add', | |
description: 'Add a pronoun role to yourself.', | |
ackBehavior: discord.interactions.commands.AckBehavior.MANUAL, | |
options: (opts) => ({ | |
pronoun: opts.string({ | |
required: true, | |
description: 'The pronoun role to add.', | |
choices: Object.keys(PRONOUN_ROLES) | |
}) | |
}) | |
}, | |
async (interaction, { pronoun }) => { | |
const roleId = PRONOUN_ROLES[pronoun]; | |
if (!roleId) { | |
await interaction.respondEphemeral( | |
'Something unexpected went wrong. Please contact Blob Mail.' | |
); | |
return; | |
} | |
await interaction.member.addRole(roleId); | |
await interaction.respondEphemeral( | |
`You've been given the \`${pronoun}\` pronoun role.` | |
); | |
} | |
); | |
group.register( | |
{ | |
name: 'remove', | |
description: 'Remove a pronoun role from yourself.', | |
ackBehavior: discord.interactions.commands.AckBehavior.MANUAL, | |
options: (opts) => ({ | |
pronoun: opts.string({ | |
required: true, | |
description: 'The pronoun role to remove.', | |
choices: Object.keys(PRONOUN_ROLES) | |
}) | |
}) | |
}, | |
async (interaction, { pronoun }) => { | |
const roleId = PRONOUN_ROLES[pronoun]; | |
if (!roleId) { | |
await interaction.respondEphemeral( | |
'Something unexpected went wrong. Please contact Blob Mail.' | |
); | |
return; | |
} | |
await interaction.member.removeRole(roleId); | |
await interaction.respondEphemeral( | |
`Your \`${pronoun}\` pronoun role has been removed.` | |
); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for this script!