public async Task UnbanCommandAsync(CommandContext ctx, [Description("User to unban. Can be an ID")] DiscordUser user, [Description("Reason for unban.")] [RemainingText] string reason = "unspecified") { try { await user.UnbanAsync(ctx.Guild, reason); } catch { await RespondBasicErrorAsync($"Failed to unban {user.Id}"); return; } var cfg = this._model.Find <GuildModeration>(ctx.Guild.Id); if (!(cfg is null)) { // Remove a temp ban if it exsists. if (cfg.UserBans.TryRemove(user.Id, out _)) { this._model.Update(cfg); await this._model.SaveChangesAsync(); } } await RespondBasicSuccessAsync($"Unbanned {user.Id}"); }
public async Task UnBan(CommandContext ctx, DiscordUser user, [RemainingText] string reason = "No reason given.") { if (!ctx.Member.HasPermission(Permissions.BanMembers)) { await ctx.RespondAsync("[You] Can't ban, can't unban. Sorry.").ConfigureAwait(false); return; } if ((await ctx.Guild.GetBansAsync()).Select(b => b.User.Id).Contains(user.Id)) { await user.UnbanAsync(ctx.Guild, reason); DiscordEmbedBuilder embed = new DiscordEmbedBuilder(EmbedHelper.CreateEmbed(ctx, "", $"Unbanned {user.Username}#{user.Discriminator} `({user.Id})`! ")).AddField("Reason:", reason); var infraction = (TimedInfraction)_eventService.Events.FirstOrDefault(e => ((TimedInfraction)e).Id == user.Id); if (infraction is not null) { _eventService.Events.TryRemove(infraction); } await ctx.RespondAsync(embed : embed); } else { DiscordEmbedBuilder embed = new DiscordEmbedBuilder(EmbedHelper.CreateEmbed(ctx, "", $"{user.Mention} is not banned!")) .WithColor(new DiscordColor("#d11515")); await ctx.RespondAsync(embed : embed); } }
public async Task Unban(CommandContext ctx, DiscordUser user) { if (ctx.Member.PermissionsIn(ctx.Channel) == DSharpPlus.Permissions.All) { await ctx.Channel.SendMessageAsync(embed : Vembed("Successfully unbanned " + user.Username)); await user.UnbanAsync(ctx.Guild).ConfigureAwait(false); } else { await ctx.Channel.SendMessageAsync("You do not have sufficient permissions to perform this command."); } }
public async Task UnbanAsync(ulong guildId, ulong userId) { try { DiscordClient shardClient = this.bot.ShardedClient.GetShard(guildId); DiscordUser discordUser = await shardClient.GetUserAsync(userId); DiscordGuild discordGuild = await shardClient.GetGuildAsync(guildId); await discordUser.UnbanAsync(discordGuild); } catch (Exception e) { this.logger.LogError("Error in unbanning user", e); } }
public async Task UnBan(CommandContext ctx, DiscordUser user, [RemainingText] string reason = "No reason given.") { if ((await ctx.Guild.GetBansAsync()).Any(ban => ban.User.Id == user.Id)) { await user.UnbanAsync(ctx.Guild, reason); var embed = new DiscordEmbedBuilder(EmbedHelper.CreateEmbed(ctx, "", $"Unanned `{user.Username}#{user.Discriminator} ({user.Id})`! ")).AddField("Reason:", reason); await ctx.RespondAsync(embed : embed); } else { var embed = new DiscordEmbedBuilder(EmbedHelper.CreateEmbed(ctx, "", $"{user.Mention} is not banned!")).WithColor(new DiscordColor("#d11515")); await ctx.RespondAsync(embed : embed); } }
public async Task Unban(CommandContext ctx, [Description("The user to unban.")] string userMention, [RemainingText, Description("The reason for unbanning the user.")] string reason = null) { ulong userId = Utils.GetId(userMention); DiscordUser user = await Program.discord.ShardClients.First().Value.GetUserAsync(userId); try { await user.UnbanAsync(ctx.Guild, reason); await ctx.RespondAsync($"Unbanned {user.Username}."); } catch { await ctx.RespondAsync("I can't unban that user. Maybe I don't have permission?"); } }
public async Task Unban(CommandContext ctx, DiscordUser target, string reason = "No reason provided.") { await target.UnbanAsync(ctx.Guild, $"[Unban by {ctx.User.Username}#{ctx.User.Discriminator}] {reason}"); await ctx.Channel.SendMessageAsync($"Succesfully unbanned **{target.Username}#{target.Discriminator}** (`{target.Id}`)"); }
public async Task unban(CommandContext ctx, DiscordUser user) { await user.UnbanAsync(ctx.Guild); await ctx.Channel.SendMessageAsync(user.Mention + " has been unbanned.").ConfigureAwait(false); }