đ¯Award experience to server members
Awarding a member or a role through the built-in Guilded EXP system.
Award a specific member
// Detect when an interaction is created.
client.on('interactionCreate', async interaction => {
if (interaction instanceof CommandInteraction) {
const member = await interaction.member;
// Award the author of the message 1000 EXP.
// The amount of EXP is limited to 1000.
await member?.award(1000);
// OR
await client.rest.guilds.awardMember(interaction.guildID, member?.id, 1000);
}
})
Award multiple members
// Detect when an interaction is created.
client.on('interactionCreate', async interaction => {
if (interaction instanceof CommandInteraction) {
const member = await interaction.member;
// Award 2 members of the guild 1000 EXP.
// The amount of EXP is limited to 1000.
(await interaction.guild)?.bulkAwardXP({
amount: 1000,
userIDs: ["dOW30kPd", "ArbX9wnA"]
});
// OR
(await client.rest.guilds)?.bulkAwardXP(interaction.guildID, {
amount: 1000,
userIDs: ["dOW30kPd", "ArbX9wnA"]
});
}
})
Award a specific role
// Detect when an interaction is created.
client.on('interactionCreate', async interaction => {
if (interaction instanceof CommandInteraction) {
const member = await interaction.member;
const roleID = 35447832; // constant: your role ID that you want to award.
// Award the role that is declared as roleID.
await client.rest.guilds.awardRole(interaction.guildID, roleID, 1000);
}
})
Set the XP of a specific member
// Detect when an interaction is created.
client.on('interactionCreate', async interaction => {
const member = await interaction.member;
// Set the EXP of the author to 1000000000.
// The amount of EXP is limited to 1000000000 (Guilded API limitations).
await message.guild.setMemberXP(interaction.memberID, 1000000000);
})
Last updated