Created
July 3, 2019 19:30
-
-
Save cerebrate/5302c683d0676b46f1997ce8bfb17d08 to your computer and use it in GitHub Desktop.
Role adding method that fails with HttpException
This file contains 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
[Command ("cornfield")] | |
[Summary ( "Banish a user to the cornfield")] | |
public Task InvokeBanishmentAsync ([Summary ("The user to be banished.")] SocketUser miscreant, | |
[Summary ("For how long are they to be banished.")] | |
TimeSpan period) | |
{ | |
_ = Task.Run (async () => | |
{ | |
if (miscreant.IsBot) | |
return ; | |
await this.Context.DataService.SetCornfield (miscreant.Id, period) ; | |
IRole roleTimeOut = this.Context.Guild.Roles.Single (r => r.Name == "Time Out") ; | |
IGuildUser guildUser = await this.Context.Guild.GetUserAsync (miscreant.Id) ; | |
await guildUser.AddRoleAsync (roleTimeOut) ; | |
await this.ReplyAsync ($"To the cornfield with you, {miscreant.Username}!") ; | |
}, | |
Program.TokenSource.Token) ; | |
return Task.CompletedTask ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment