public static async Task NewTopSong(DiscordSocketClient discordSocketClient, SocketMessage message) { var r = new RoleAssignment(discordSocketClient); if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString()) && message.Content.Count() == 11) { var scoresaberId = r.GetScoresaberIdWithDiscordId(message.Author.Id.ToString()); var embedTask = await BeatSaberInfoExtension.GetNewTopSongWithScoresaberId(scoresaberId); await message.Channel.SendMessageAsync("", false, embedTask.Build()); } else { if (message.Content.Length <= 11) { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Search failed", "Search value is not long enough. it should be larger than 3 characters.", null, null) .Build()); return; } var username = message.Content.Substring(11); var id = await BeatSaberInfoExtension.GetPlayerIdsWithUsername(username); var embedTask = await BeatSaberInfoExtension.GetNewRecentSongWithScoresaberId(id); await message.Channel.SendMessageAsync("", false, embedTask.Build()); } }
private async Task <RestTextChannel> CreateChannels() { infoChannel = await discord.GetGuild(505485680344956928).CreateTextChannelAsync(randomEventModel.title + "-randomevent-info", null, new RequestOptions()); //await infoChannel.AddPermissionOverwriteAsync(discord.GetGuild(505485680344956928).Roles.FirstOrDefault(x => x.Id == 611102875241676811), new OverwritePermissions().Modify(readMessageHistory:Discord.PermValue.Allow, viewChannel: Discord.PermValue.Allow, sendMessages: Discord.PermValue.Deny)); await infoChannel.AddPermissionOverwriteAsync(discord.GetGuild(505485680344956928).Roles.FirstOrDefault(x => x.Id == 505485680344956928), new OverwritePermissions().Modify(readMessageHistory: Discord.PermValue.Allow, viewChannel: Discord.PermValue.Deny, useExternalEmojis: Discord.PermValue.Deny, sendMessages: Discord.PermValue.Deny)); generalChannel = await discord.GetGuild(505485680344956928).CreateTextChannelAsync(randomEventModel.title + "-randomevent-general", null, new RequestOptions()); await generalChannel.AddPermissionOverwriteAsync(discord.GetGuild(505485680344956928).Roles.FirstOrDefault(x => x.Id == 505485680344956928), new OverwritePermissions().Modify(readMessageHistory: Discord.PermValue.Deny, viewChannel: Discord.PermValue.Deny)); var eventleiders = randomEventModel.eventLeider.Split(" "); foreach (var eventleider in eventleiders) { var id = eventleider.Replace("<@!", "").Replace(">", ""); var user = discord.GetUser(ulong.Parse(id)); await infoChannel.AddPermissionOverwriteAsync(user, new OverwritePermissions().Modify(sendMessages: Discord.PermValue.Allow)); } var builder = EmbedBuilderExtension.NullEmbed(randomEventModel.title, randomEventModel.description, null, null); builder.AddField(new EmbedFieldBuilder { Name = "Datum", Value = randomEventModel.date.ToString() }); builder.AddField(new EmbedFieldBuilder { Name = "Locatie", Value = randomEventModel.locatie }); builder.AddField(new EmbedFieldBuilder { Name = "Eventleider(s)", Value = randomEventModel.eventLeider }); builder.Footer = new EmbedFooterBuilder { Text = "Groen vinkje = Ik neem deel aan \nBlauw vinkje = Ik ben geinteresseerd \nRode kruis = verwijder deze channel" }; await infoChannel.SendFileAsync("../../../Resources/Img/randomevent.jpg", "", false); var messageInChannel = await infoChannel.SendMessageAsync(null, false, builder.Build()); var deelnemersMessage = await infoChannel.SendMessageAsync(null, false, EmbedBuilderExtension.NullEmbed("Deelnemers", "", null, null).Build()); await messageInChannel.AddReactionAsync(Emote.Parse("<:green_check:671412276594475018>")); await messageInChannel.AddReactionAsync(Emote.Parse("<:blue_check:671413239992549387>")); await messageInChannel.AddReactionAsync(Emote.Parse("<:red_check:671413258468720650>")); var deelnemers = new Dictionary <ulong, string[]>(); //deelnemers.Add(deelnemersMessage.Id, new string[]{ "Testname", "Testname2" }); var f = messageInChannel.Id.ToString() + "0"; var generalFakeId = ulong.Parse(f); deelnemers.Add(deelnemersMessage.Id, new string[] { "Yeet" }); deelnemers.Add(generalFakeId, new string[] { generalChannel.Id.ToString() }); JsonExtension.InsertJsonData("../../../Resources/irleventdata.txt", messageInChannel.Id.ToString(), deelnemers); return(infoChannel); }
static public async Task IRLevent(DiscordSocketClient discordSocketClient, SocketMessage message) { if (message.HasCertainRoleInNBSG(discordSocketClient, 711342955776049194)) { var embedBuilder = EmbedBuilderExtension.NullEmbed("IRL Event handler", "Starting IRL Event handler...", null, null); var msg = await message.Channel.SendMessageAsync("", false, embedBuilder.Build()); var irlEventHandler = new IRLeventHandler(message, discordSocketClient, msg); } }
static public async Task LinkScoresaberWithDiscord(DiscordSocketClient discordSocketClient, SocketMessage message) { var r = new RoleAssignment(discordSocketClient); if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString())) { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Pog", $"Your Discord ID is already linked with your scoresaber, No worries {message.Author.Username}. If you want to unlink, type !bs unlink.").Build()); await message.Channel.SendMessageAsync("Your Discord ID is already linked with your scoresaber, No worries " + message.Author.Username); return; } else { var ScoresaberId = message.Content.Substring(9); ScoresaberId = Regex.Replace(ScoresaberId, "[^0-9]", ""); if (!ValidationExtension.IsDigitsOnly(ScoresaberId)) { await message.Channel.SendMessageAsync("Scoresaber ID is wrong"); return; } if (await ValidationExtension.IsDutch(ScoresaberId)) { var guildChannel = message.Channel as SocketGuildChannel; if (guildChannel.Guild.Id != 505485680344956928) { message.Channel.SendMessageAsync("It seems that you are Dutch and trying to link your account outside the Dutch Discord. A Dutch request needs to be validated. Consider joining the Dutch Beat Saber Discord. (https://discord.gg/cH7mTyq)"); } r.MakeRequest(message); } else { JsonExtension.InsertJsonData("../../../GlobalAccounts.txt", message.Author.Id.ToString(), ScoresaberId); await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Added user to the list", "Added " + message.Author.Id.ToString() + " with scoresaberID " + ScoresaberId + " to the global list", null, null).Build()); return; } } var moderationHelper = new GuildService(discordSocketClient, 505485680344956928); var user = message.Author; if (moderationHelper.UserHasRole(user, "Nieuwkomer")) { await moderationHelper.AddRole("Link my discord please", user); await moderationHelper.DeleteRole("Nieuwkomer", user); } }
static public async Task UnlinkScoresaberFromDiscord(DiscordSocketClient discordSocketClient, SocketMessage message) { var r = new RoleAssignment(discordSocketClient); if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString())) { return; } else { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Hmmmm?", "Your Discord does not seemed to be already linked. You can link a new scoresaber account with !bs link [ScoresaberID]").Build()); } }
public static async Task Songs(DiscordSocketClient discordSocketClient, SocketMessage message) { var builderList = await BeatSaberInfoExtension.GetSongs(message.Content.Substring(10)); if (builderList.Count > 4) { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Search term to wide", "I can not post more as 6 songs. " + "\n Try searching with a more specific word please. \n" + ":rage:", null, null).Build()); } else { foreach (var builder in builderList) { await message.Channel.SendMessageAsync("", false, builder.Build()); } } }
private void ModifyEmbed(RestUserMessage msg, String content) { msg.ModifyAsync(x => x.Embed = EmbedBuilderExtension.NullEmbed("IRL Event handler", content, null, null).Build()); }
public static async Task NewSearch(DiscordSocketClient discordSocketClient, SocketMessage message) { var r = new RoleAssignment(discordSocketClient); if (message.Content.Contains("@")) { var discordId = message.Content.Substring(11).Replace("<", "").Replace(">", "").Replace("@", "") .Replace("!", ""); if (r.CheckIfDiscordIdIsLinked(discordId)) { var scoresaberId = r.GetScoresaberIdWithDiscordId(discordId); var embedTask = new List <EmbedBuilder>(); try { embedTask = await BeatSaberInfoExtension.GetPlayerSearchInfoEmbed(scoresaberId, message); } catch (Exception ex) { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Error", ex.Message).Build()); } if (embedTask.Count() == 0) { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("No results", "Try linking your discord and scoresaber again with like this: https://scoresaber.com/u/76561198033166451").Build()); } foreach (var embedBuilder in embedTask) { await message.Channel.SendMessageAsync("", false, embedBuilder.Build()); } } else { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Not linked yet!", "Your discord is not linked yet. Type !bs link [Scoresaberlink] to link it.").Build()); } } else if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString()) && message.Content.Count() == 10) { var scoresaberId = r.GetScoresaberIdWithDiscordId(message.Author.Id.ToString()); var embedTask = await BeatSaberInfoExtension.GetPlayerSearchInfoEmbed(scoresaberId, message); foreach (var embedBuilder in embedTask) { await message.Channel.SendMessageAsync("", false, embedBuilder.Build()); } } else { if (message.Content.Substring(11).Count() == 0) { await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("User's discord not linked", "Your discord is not linked yet. Type !bs link [Scoresaberlink] to link it.", null, null).Build()); return; } foreach (var embed in await BeatSaberInfoExtension.GetPlayer(message.Content.Substring(11))) { var completedMessage = await message.Channel.SendMessageAsync("", false, embed.Build()); //await completedMessage.AddReactionAsync(new Emoji("⬅")); //await completedMessage.AddReactionAsync(new Emoji("➡")); } } }
public async Task HandleMessage(DiscordSocketClient discordSocketClient, SocketMessage message, Logger _logger, Program program) { if (message.Author.Username == "BeatSaber Bot") { return; } MessageDelete.DeleteMessageCheck(message, discordSocketClient); if (message.Content.Length <= 3) { return; } if (message.Content.Substring(0, 3).Contains("!bs")) { var messageCommand = message.Content.ToLower(); var typingState = message.Channel.EnterTypingState(new RequestOptions { Timeout = GlobalConfiguration.TypingTimeOut, }); Console.WriteLine(message.Content); if (messageCommand.Contains(" help")) { GenericCommands.Help(discordSocketClient, message); } else if (messageCommand.Contains(" rolecolor")) { DutchServerCommands.RoleColor(discordSocketClient, message); } else if (messageCommand.Contains(" topsong")) { GlobalScoresaberCommands.NewTopSong(discordSocketClient, message); } else if (messageCommand.Contains(" search")) { GlobalScoresaberCommands.NewSearch(discordSocketClient, message); } else if (messageCommand.Contains(" updateroles")) { DutchServerCommands.UpdateRoles(discordSocketClient, message); } else if (messageCommand.Contains(" linkednames")) { DutchServerCommands.LinkedNames(discordSocketClient, message); } else if (messageCommand.Contains(" notlinkednames")) { DutchServerCommands.NotLinkedNames(discordSocketClient, message); } else if (messageCommand.Contains(" recentsong")) { GlobalScoresaberCommands.NewRecentSong(discordSocketClient, message); } else if (messageCommand.Contains(" changecolor")) { DutchServerCommands.ChangeColor(discordSocketClient, message); } else if (messageCommand.Contains(" playing")) { GenericCommands.Playing(discordSocketClient, message); } else if (messageCommand.Contains(" invite")) { GenericCommands.Invite(discordSocketClient, message); } else if (messageCommand.Contains(" poll")) { GenericCommands.Poll(discordSocketClient, message); } else if (messageCommand.Contains(" compare")) { GlobalScoresaberCommands.Compare(discordSocketClient, message); } else if (messageCommand.Contains(" unlink")) { DutchServerCommands.LinkScoresaberWithDiscord(discordSocketClient, message); } else if (messageCommand.Contains(" link")) { DutchServerCommands.LinkScoresaberWithDiscord(discordSocketClient, message); } else if (messageCommand.Contains(" typing")) { GlobalScoresaberCommands.Typing(discordSocketClient, message); message.DeleteAsync(); } else if (messageCommand.Contains(" ranks")) { var builderList = await BeatSaberInfoExtension.GetRanks(); foreach (var builder in builderList) { await message.Channel.SendMessageAsync("", false, builder.Build()); } } else if (messageCommand.Contains(" senddm")) { GenericCommands.SendDM(discordSocketClient, message); } else if (messageCommand.Contains(" approvedutchuser")) { var guildUserSender = message.Author as SocketGuildUser; if (guildUserSender.IsDutchAdmin()) { var userId = message.Content.Substring(21).Replace("<@!", "").Replace(">", "").Trim(); var user = discordSocketClient.GetUser(ulong.Parse(userId)); var guildService = new GuildService(discordSocketClient, 505485680344956928); await guildService.AddRole("Koos Rankloos", user); await program.UserJoinedMessage(user); } await message.DeleteAsync(); } else if (messageCommand.Contains(" songs")) { await message.Channel.SendMessageAsync(null, false, EmbedBuilderExtension.NullEmbed("Ewh..", "This command is outdated. Blame silverhaze to remake it").Build()); //GlobalScoresaberCommands.Songs(discordSocketClient, message); } else if (messageCommand.Contains(" irlevent create")) { DutchServerCommands.IRLevent(discordSocketClient, message); } else if (messageCommand.Contains(" randomevent create")) { DutchServerCommands.RandomEvent(discordSocketClient, message); } else { var embedBuilder = EmbedBuilderExtension.NullEmbed("Oops", "There is no command like that, try something else", null, null); await message.Channel.SendMessageAsync(null, false, embedBuilder.Build()); } typingState.Dispose(); } }