public async Task Nickname(string nickname, params IGuildUser[] users) { var guild = Database.GetGuild(Context.Guild); var author = Context.Message.Author as IGuildUser; IGuildUser[] allUsers = users; if (allUsers.Length <= 0) { if (!author.GuildPermissions.ChangeNickname) { await RespondAsync($"{author.Mention} you do not have the ``Change Nickname`` permission. See ``{guild.Prefix}help nickname``"); return; } allUsers = new[] { author }; } if (!author.GuildPermissions.ManageNicknames) { await RespondAsync($"{author.Mention} you do not have the ``Manage Nicknames`` permission. See ``{guild.Prefix}help nickname``"); return; } var action = CommandUtility.Action(async u => await u.SetNickname(nickname)); await CommandUtility.ForEvery(Context, allUsers, action); }
public Task RoleDelete(params IRole[] roles) { return(CommandUtility.ForEvery(Context, roles, CommandUtility.Action( async delegate(IRole role) { await role.DeleteAsync(); }))); }
public Task Delete(params IGuildChannel[] channels) { return(CommandUtility.ForEvery(Context, channels, CommandUtility.Action( delegate(IGuildChannel channel) { return channel.DeleteAsync(); }))); }
public async Task Softban(params IGuildUser[] users) { var action = CommandUtility.Action(async u => { ulong id = u.Id; await u.BanAsync(7); // Prune 7 day's worth of messages await u.Guild.RemoveBanAsync(id); }); await CommandUtility.ForEvery(Context, users, action); }
public async Task RoleUnban(IRole role, params IGuildUser[] users) { var action = CommandUtility.Action( u => { var guildUser = Database.GetGuildUser(u); guildUser.UnbanRole(role); return(Task.CompletedTask); }); await Database.Save(); await CommandUtility.ForEvery(Context, users, action); }
public async Task RoleBan(IRole role, params IGuildUser[] users) { var action = CommandUtility.Action( async u => { await u.RemoveRolesAsync(role); var guildUser = Database.GetGuildUser(u); guildUser.BanRole(role); }); await Database.Save(); await CommandUtility.ForEvery(Context, users, action); }
protected async Task TempAction(string actionType, TimeSpan time, IEnumerable <IGuildUser> users, Func <IGuildUser, Task <AbstractTempAction> > action, Func <IGuildUser, AbstractTempAction, Task> postAction = null) { Check.NotNull(action); var start = DateTimeOffset.Now; var end = DateTimeOffset.Now + time; var commandAction = CommandUtility.Action(async delegate(IGuildUser user) { var tempAction = await action(user); tempAction.Start = start; tempAction.End = end; Database.TempActions.Add(tempAction); await Database.Save(); if (postAction != null) { await postAction(user, tempAction); } await tempAction.Apply(Client); }); await CommandUtility.ForEvery(Context, users, commandAction); }
public async Task Nuke(params IGuildUser[] users) { var action = CommandUtility.Action(async u => await u.RemoveRolesAsync()); await CommandUtility.ForEvery(Context, users, action); }
public async Task Add(IRole role, params IGuildUser[] users) { var action = CommandUtility.Action(async u => await u.AddRolesAsync(role)); await CommandUtility.ForEvery(Context, users, action); }
public async Task Deafen(params IGuildUser[] users) { var action = CommandUtility.Action(async u => await u.DeafenAsync()); await CommandUtility.ForEvery(Context, users, action); }
public async Task Ban(params IGuildUser[] users) { var action = CommandUtility.Action(u => u.BanAsync()); await CommandUtility.ForEvery(Context, users, action); }