Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cerebrate/5302c683d0676b46f1997ce8bfb17d08 to your computer and use it in GitHub Desktop.
Save cerebrate/5302c683d0676b46f1997ce8bfb17d08 to your computer and use it in GitHub Desktop.
Role adding method that fails with HttpException
[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