Purge Command

commands.CreateCommand("purge") .Parameter("int") .Do(async (e) => { var role = e.Server.GetRole(249153151289131009); var mod = e.Server.FindRoles(role.Name).FirstOrDefault(); if (e.Message.User.HasRole(mod)) { int delNo = Int32.Parse(e.GetArg("int")) + 1; Message[] mDelete; mDelete = await e.Channel.DownloadMessages(delNo); await e.Channel.DeleteMessages(mDelete); if(delNo == 1) { await e.Channel.SendMessage(e.User.Mention + " purged " + "**" + e.GetArg("int") + "**" + " message."); } else { await e.Channel.SendMessage(e.User.Mention + " purged " + "**" + e.GetArg("int") + "**" + " messages."); } } else { await e.Channel.SendMessage("[" + e.User.Mention + "]" + " You do not have permission to do this."); } });
// V 0.1
Added permission checker.
Added if statement to determine whether to use plural or not.
Changed output message.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.