Skip to content

Changing a nickname of a member? #2116

Answered by mbround18
mbround18 asked this question in Q&A
Discussion options

You must be logged in to vote

In case anyone else needs it :) fyi you cant edit the owner of the servers nickname with a bot

#[command]
async fn command_name(_ctx: &Context, msg: &Message) -> CommandResult {
    let token = env::var("DISCORD_TOKEN").expect("token");
    let http = HttpBuilder::new(token).build();
    let mut payload = JsonMap::new();
    payload.insert(
        "nick".to_string(),
        Value::from("Banana Phone"),
    );

    http.edit_member(
        msg.guild_id.expect("Guild ID is not present!").0,
        msg.author.id.0,
        &payload,
        Some("Its Karl..."),
    )
    .await
    .expect("Failed to set nickname");
    
    Ok(())
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Radiicall
Comment options

Answer selected by mbround18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants