public async Task Welcome(string _switch, ulong channelId, params string[] message) { if (Context.IsPrivate) { await Context.Channel.SendMessageAsync(":x: **You must in a guild to use that command!**"); return; } if (!(Context.User as IGuildUser).GuildPermissions.Administrator) { await Context.Channel.SendMessageAsync(":x: **You must be an administrator to use that command!**"); return; } switch (_switch.ToLower()) { case "on": { ServerDB server = await DBServerData.getStats(Context.Guild.Id); string _message = new Addons()._out(message); server.Welcome = _message; server.WelcomeChannel = channelId; await DBServerData.saveStats(server); await Context.Channel.SendMessageAsync($"Welcome message has been successfully turned on."); break; } case "off": { ServerDB server = await DBServerData.getStats(Context.Guild.Id); server.WelcomeChannel = 0; server.Welcome = ""; await DBServerData.saveStats(server); await Context.Channel.SendMessageAsync($"Welcome message has been successfully turned off."); return; } default: { await Context.Channel.SendMessageAsync(":x: **You can't use that command without arguments.**" + Environment.NewLine + "**To see the command information type d!help wm**"); break; } } }
public async Task wiki(params String[] name) { string output = new Addons()._out(name); Wikipedia w = new Wikipedia(); w.UseTLS = true; w.Limit = 1; w.What = What.Text; QueryResult response = w.Search(output); if (response.Search[0].Url.ToString() != "https://en.wikipedia.org/wiki/") { await Context.Channel.SendMessageAsync(response.Search[0].Url.ToString().Replace(' ', '_')); } else { await Context.Channel.SendMessageAsync(":x: **No articles were found.**"); } }
public async Task playSkip(params String[] url) { if (!(Context.User as IGuildUser).GuildPermissions.Administrator) { await Context.Channel.SendMessageAsync(":x: **You must be an administrator to use this command!**"); return; } string output = new Addons()._out(url); if (output == "") { return; } IVoiceChannel channel = null; channel = channel ?? (Context.User as IGuildUser)?.VoiceChannel; if (channel == null) { await Context.Channel.SendMessageAsync(":x: **You must be in a voice channel to use this command!**"); return; } var response = await Initialization.lavalinkManager.LoadTracksAsync(output, SearchMode.YouTube); if (response.Tracks.Length <= 0) { await Context.Channel.SendMessageAsync(":skull_crossbones: **No matches found**"); return; } VoteLavalinkPlayer player = Initialization.lavalinkManager.GetPlayer <VoteLavalinkPlayer>(Context.Guild.Id) ?? await Initialization.lavalinkManager.JoinAsync <VoteLavalinkPlayer>(channel.GuildId, channel.Id); if (response.PlaylistInfo.Name != null) { await player.PlayAsync(response.Tracks.First()); for (int i = response.Tracks.Length - 1; i > 0; i--) { await player.PlayAsync(response.Tracks[i]); } EmbedBuilder eb2 = new EmbedBuilder(); eb2.WithColor(40, 200, 150); eb2.WithAuthor("Playing the playlist", Context.User.GetAvatarUrl()); eb2.WithDescription($"**[{response.PlaylistInfo.Name}]({response.Tracks.First().Source})**"); eb2.AddField("Queued by", $"{Context.User.Username}#{Context.User.DiscriminatorValue}", true); eb2.AddField("Tracks in queue", response.Tracks.Length, true); eb2.WithThumbnailUrl($"http://img.youtube.com/vi/{response.Tracks.First().TrackIdentifier}/0.jpg"); await Context.Channel.SendMessageAsync("", false, eb2.Build()); return; } await player.PlayAsync(response.Tracks.First(), false); EmbedBuilder eb = new EmbedBuilder(); eb.WithColor(40, 200, 150); eb.WithAuthor("Now playing", Context.User.GetAvatarUrl()); eb.WithDescription($"**[{player.CurrentTrack.Title}]({player.CurrentTrack.Source})**"); eb.AddField("Channel", player.CurrentTrack.Author, true); eb.AddField("Queued by", $"{Context.User.Username}#{Context.User.DiscriminatorValue}", true); eb.AddField("Duration", player.CurrentTrack.Duration, true); eb.AddField("Position in queue", 0, true); eb.WithThumbnailUrl($"http://img.youtube.com/vi/{player.CurrentTrack.TrackIdentifier}/0.jpg"); await Context.Channel.SendMessageAsync("", false, eb.Build()); }
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 ServerInfo(params String[] guildName) { if (Context.IsPrivate == true) { if (guildName.Length <= 0) { EmbedBuilder eb1 = new EmbedBuilder(); eb1.WithAuthor("Error", Context.User.GetAvatarUrl()); eb1.WithColor(40, 200, 150); eb1.WithDescription("**Please use this command only in a server to get it's info, or get an info about another server here.**"); eb1.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.User.SendMessageAsync("", false, eb1.Build()); return; } } SocketGuild guild = Context.Guild; string output = new Addons()._out(guildName); if (guildName.Length >= 1 && guildName.ElementAt(0) == "roles") { output = output.Remove(0, 5); if (guildName.Length > 1) { output = output.Remove(0, 1); guild = Context.Client.Guilds.Where(x => x.Name == output).FirstOrDefault(); } EmbedBuilder eb1 = new EmbedBuilder(); eb1.WithAuthor($"{guild.Name} roles ({guild.Roles.Count})", guild.IconUrl); eb1.WithColor(40, 200, 150); string roles = ""; for (int i = 0; i < guild.Roles.Count; i++) { roles += guild.Roles.ElementAt(i); roles += Environment.NewLine; } eb1.WithDescription(roles); await Context.Channel.SendMessageAsync("", false, eb1.Build()); return; } if (output != null) { guild = Initialization._client.Guilds.Where(x => x.Name == output).FirstOrDefault(); } if (guild == null) { EmbedBuilder eb2 = new EmbedBuilder(); eb2.WithAuthor($"Error", Context.User.GetAvatarUrl()); eb2.WithColor(40, 200, 150); eb2.WithDescription($":x: **Can't find guild with name: {output}**"); eb2.WithThumbnailUrl(Settings.MainThumbnailUrl); await Context.Channel.SendMessageAsync("", false, eb2.Build()); } EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor($"{guild.Name}", guild.IconUrl); eb.WithColor(40, 200, 150); eb.AddField($"ID: {guild.Id}", $"[Server avatar]({guild.IconUrl})"); eb.AddField("Verification Level", $"{guild.VerificationLevel}", true); eb.AddField("Region", $"{guild.VoiceRegionId}", true); eb.AddField("Members", $"{guild.MemberCount} members", true); eb.AddField("Channels", $"{guild.Channels.Count}", true); eb.AddField("Server Owner", $"{guild.Owner.Username}#{guild.Owner.Discriminator} | ID: {guild.OwnerId}"); eb.AddField("Created at", $"{guild.CreatedAt.UtcDateTime}"); eb.AddField("Roles", $"{guild.Roles.Count} roles"); eb.WithFooter("Use d!server roles to show all roles.", guild.IconUrl); eb.WithThumbnailUrl($"{guild.IconUrl}"); await Context.Channel.SendMessageAsync("", false, eb.Build()); }
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 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!"); } }