public async Task UserInfo(params String[] UserL) { if (Context.IsPrivate) { return; } string output = new Addons()._out(UserL); if (output != "") { if (output.IndexOf('@') == 1) { try { output = output.Remove(0, 2); output = output.Remove(output.Length - 1, 1); if (output.IndexOf('!') == 0) { output = output.Remove(0, 1); } SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Id == ulong.Parse(output)); if (j == null) { throw new Exception(); } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"{j.Username}#{j.DiscriminatorValue}", j.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512)); eb.WithColor(40, 200, 150); eb.WithThumbnailUrl(j.GetAvatarUrl()); eb.AddField("User ID", $"{j.Id}", true); eb.AddField("Status", $"{j.Status}", true); string nick = ""; if (j.Nickname == null) { nick = "None"; } else { nick = j.Nickname; } eb.AddField("Nickname", nick); eb.AddField("Registered at", $"{j.CreatedAt.UtcDateTime}"); eb.AddField("Joined at", $"{j.JoinedAt.Value.UtcDateTime}"); string roles = ""; foreach (var role in j.Roles) { if (role.Name != "@everyone") { roles += role.Name; roles += Environment.NewLine; } } eb.AddField($"Roles [{j.Roles.Count -1}]", roles); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Exception) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Can't find user with id {output} on the server.**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } } else { try { SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Username == output); if (j == null) { throw new Exception(); } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"{j.Username}#{j.DiscriminatorValue}", j.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512)); eb.WithColor(40, 200, 150); eb.WithThumbnailUrl(j.GetAvatarUrl()); eb.AddField("User ID", $"{j.Id}", true); eb.AddField("Status", $"{j.Status}", true); string nick = ""; if (j.Nickname == null) { nick = "None"; } else { nick = j.Nickname; } eb.AddField("Nickname", nick); eb.AddField("Registered at", $"{j.CreatedAt.UtcDateTime}"); eb.AddField("Joined at", $"{j.JoinedAt.Value.UtcDateTime}"); string roles = ""; foreach (var role in j.Roles) { if (role.Name != "@everyone") { roles += role.Name; roles += Environment.NewLine; } } eb.AddField($"Roles [{j.Roles.Count -1}]", roles); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Exception) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Can't find user with username \"{output}\" on the server.**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } } } else { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"{Context.User.Username}#{Context.User.DiscriminatorValue}", Context.User.GetAvatarUrl(), Context.User.GetAvatarUrl(ImageFormat.Auto, 512)); eb.WithColor(40, 200, 150); eb.WithThumbnailUrl(Context.User.GetAvatarUrl()); eb.AddField("User ID", $"{Context.User.Id}", true); eb.AddField("Status", $"{Context.User.Status}", true); string nick = ""; if (Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username).Nickname == null) { nick = "None"; } else { nick = Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username).Nickname; } eb.AddField("Nickname", nick); eb.AddField("Registered at", $"{Context.User.CreatedAt.UtcDateTime}"); eb.AddField("Joined at", $"{Context.Guild.CurrentUser.JoinedAt.Value.UtcDateTime}"); string roles = ""; foreach (var role in Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username).Roles) { if (role.Name != "@everyone") { roles += role.Name; roles += Environment.NewLine; } } eb.AddField($"Roles [{Context.Guild.CurrentUser.Roles.Count -1}]", roles); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } }
public async Task getPP(params String[] UserL) { string output = new Addons()._out(UserL); if (output != "") { if (output.IndexOf('@') == 1) { try { output = output.Remove(0, 2); output = output.Remove(output.Length - 1, 1); if (output.IndexOf('!') == 0) { output = output.Remove(0, 1); } SocketGuildUser j = null; var n = Initialization._client.Guilds.GetEnumerator(); n.MoveNext(); var g = n.Current; for (int i = 0; i < Initialization._client.Guilds.Count; i++) { g = n.Current; n.MoveNext(); if (j == null) { j = g.Users.FirstOrDefault(x => x.Id == ulong.Parse(output)); } } if (j == null) { throw new Exception(); } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Succesfull", Context.User.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512)); eb.WithColor(40, 200, 150); eb.AddField($"{j.Username}#{j.Discriminator}", $"[Avatar URL]({j.GetAvatarUrl(ImageFormat.Auto, 512)})", true); eb.WithImageUrl(j.GetAvatarUrl()); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Exception) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Can't find user with id {output} in all connected to the bot servers.**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } } else { try { var n = Initialization._client.Guilds.GetEnumerator(); n.MoveNext(); var g = n.Current; SocketGuildUser j = null; for (int i = 0; i < Initialization._client.Guilds.Count; i++) { g = n.Current; n.MoveNext(); if (j == null) { j = g.Users.FirstOrDefault(x => x.Username == output); } } if (j == null) { throw new Exception(); } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Succesfull", Context.User.GetAvatarUrl(), j.GetAvatarUrl(ImageFormat.Auto, 512)); eb.WithColor(40, 200, 150); eb.AddField($"{j.Username}#{j.Discriminator}", $"[Avatar URL]({j.GetAvatarUrl(ImageFormat.Auto, 512)})", true); eb.WithImageUrl(j.GetAvatarUrl()); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Exception) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Can't find user with username \"{output}\" in all connected to the bot servers.**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } } } else { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Succesfull", Context.User.GetAvatarUrl(), Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField($"{Context.User.Username}#{Context.User.Discriminator}", $"[Avatar URL]({Context.User.GetAvatarUrl(ImageFormat.Auto, 512)})", true); eb.WithImageUrl(Context.User.GetAvatarUrl()); await Context.Channel.SendMessageAsync("", false, eb.Build()); } }
public async Task ban(string reason, params String[] UserL) { var user = Context.Guild.Users.FirstOrDefault(x => x.Username == Context.User.Username); if (user.GuildPermissions.BanMembers == true) { string output = new Addons()._out(UserL); if (output != "") { if (output.IndexOf('@') == 1) { try { output = output.Remove(0, 2); output = output.Remove(output.Length - 1, 1); if (output.IndexOf('!') == 0) { output = output.Remove(0, 1); } SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Id == ulong.Parse(output)); if (j == null) { throw new Exception(); } if (j.Username == "Ducky Bot" && j.DiscriminatorValue == 5489 && j.IsBot == true) { await Context.Channel.SendMessageAsync("You can't ban Ducky Bot!"); return; } if (j == user) { await Context.Channel.SendMessageAsync("You can't ban yourself!"); return; } if (user.Hierarchy < j.Hierarchy) { await Context.Channel.SendMessageAsync("Your role is under the user role!"); return; } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Successful"); eb.WithColor(40, 200, 150); eb.WithThumbnailUrl(j.GetAvatarUrl()); eb.WithDescription($"**{j.Username} has been banned**"); eb.AddField("Reason", reason); eb.AddField("Banned by", $"{Context.User.Username}#{Context.User.DiscriminatorValue}"); await Context.Guild.AddBanAsync(j, 0, reason); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Discord.Net.HttpException) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Bot role is under the user role**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Exception) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Can't find user with id {output} in the server.**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } } else { try { SocketGuildUser j = Context.Guild.Users.FirstOrDefault(x => x.Username == output); if (j == null) { throw new Exception(); } if (user.Hierarchy < j.Hierarchy) { await Context.Channel.SendMessageAsync("Your role is under the user role!"); return; } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Successful"); eb.WithColor(40, 200, 150); eb.WithThumbnailUrl(j.GetAvatarUrl()); eb.WithDescription($"**{j.Username} has been banned**"); eb.AddField("Reason", reason); eb.AddField("Banned by", $"{Context.User.Username}#{Context.User.DiscriminatorValue}"); await Context.Guild.AddBanAsync(j, 0, reason); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Discord.Net.HttpException) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Bot role is under the user role**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } catch (Exception) { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.AddField("Exception details", $"**Can't find user with username \"{output}\" in the server.**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } } } else { EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb.WithColor(40, 200, 150); eb.WithDescription("**Please use correct reason and username**"); eb.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb.Build()); } } else { await Context.Channel.SendMessageAsync("You don't have \"Ban Members\" permission to use this command!"); } }