I am trying to get my discord bot to assign a role to a user when they input the command '!stream' I am very new to programming in c# and discord.net especially. Right now I have the code that should be assigning the role inside of a message received method. This probably isn't the best way to do it but I'm not super sure a better way right now. Anyways, here is the code:
IGuildUser user = (IGuildUser)arg.Author;
IRole role = ((IGuildChannel)arg.Channel).Guild.GetRole(theRoleID);
if (arg.Content == "!stream") {
await (user as IGuildUser).AddRoleAsync(role);
}
I have made sure both user, and role is getting the correct user and correct role. Its also running the if statement because I had output inside of it. The only thing that doesn't seem to be working is the actual assignment. Any help is greatly appreciated. Thanks!
