• Adds a specified role to a user within a specific guild.

    Parameters

    • token: string
    • guildId: string

      The ID of the guild where the user and role are located.

    • userId: string

      The ID of the user to whom the role will be added.

    • roleId: string

      The ID of the role to be added to the user.

    Returns Promise<void>

    A promise that resolves to void when the role is successfully added.

    Throws

    Will throw an error if there is a problem adding the role.

    Example

    const token = 'your_discord_token_here';
    const guildId = 'your_guild_id_here';
    const userId = 'your_user_id_here';
    const roleId = 'your_role_id_here';

    const run = async () => {
    try {
    await addRoleToUser(token, guildId, userId, roleId);
    console.log('Role added successfully.');
    } catch (error) {
    console.error(`Error: ${error.message}`);
    }
    }

    run();

Generated using TypeDoc