public override async Task Reset() { Battle = new ColossoBattle(); foreach (var k in PlayerMessages.Keys) { await k.DeleteAsync(); } PlayerMessages.Clear(); if (EnemyMessage == null) { await Initialize(); } else { await EnemyMessage.ModifyAsync(c => { c.Content = GetEnemyMessageString(); c.Embed = null; }); await EnemyMessage.RemoveAllReactionsAsync(); _ = EnemyMessage.AddReactionsAsync(new IEmote[] { Emote.Parse("<:Fight:536919792813211648>"), Emote.Parse("<:Battle:536954571256365096>") }); wasJustReset = true; } if (StatusMessage != null) { _ = StatusMessage.DeleteAsync(); StatusMessage = null; } SetNextEnemy(); if (autoTurn != null) { autoTurn.Dispose(); } if (resetIfNotActive != null) { resetIfNotActive.Dispose(); } autoTurn = new Timer() { Interval = 25000, AutoReset = false, Enabled = false }; autoTurn.Elapsed += TurnTimeElapsed; resetIfNotActive = new Timer() { Interval = 120000, AutoReset = false, Enabled = false }; resetIfNotActive.Elapsed += BattleWasNotStartetInTime; Console.WriteLine("Battle was reset."); }
public async Task ToggleLoggingDeleted() { if (!Utilities.HasAdmin(Context.Message.Author as SocketGuildUser)) { await ReplyAsync("You do not have administrator access"); return; } IUserMessage message = await ReplyAsync("Setting..."); ModerationFunctions.CheckDirectories(Context.Guild); LogSettings settings = null; settings = SettingFunctions.LoadLogSettings(Context.Guild, true); settings.logDeletes = !settings.logDeletes; JsonSerializer serializer = new JsonSerializer(); serializer.NullValueHandling = NullValueHandling.Include; settings.SaveLogSettings(Context.Guild); if (settings.logDeletes) { await message.ModifyAsync(msg => msg.Content = "Deleted messages will now be logged in the logging channel"); } else { await message.ModifyAsync(msg => msg.Content = "Deleted messages won't be logged now"); } }
private async Task HelperHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { if (!message?.Embeds?.Any(embed => embed.Title == OracleResources.AskOracleHelperTitle) ?? false) { return; } await Task.Run(async() => { await message.RemoveAllReactionsAsync(); if (reaction.Emote.Name == oneEmoji) { await message.ModifyAsync(msg => { msg.Content = AskTheOracleWithChance(90, OracleResources.AlmostCertain); msg.Embed = null; }); } if (reaction.Emote.Name == twoEmoji) { await message.ModifyAsync(msg => { msg.Content = AskTheOracleWithChance(75, OracleResources.Likely); msg.Embed = null; }); } if (reaction.Emote.Name == threeEmoji) { await message.ModifyAsync(msg => { msg.Content = AskTheOracleWithChance(50, OracleResources.FiftyFifty); msg.Embed = null; }); } if (reaction.Emote.Name == fourEmoji) { await message.ModifyAsync(msg => { msg.Content = AskTheOracleWithChance(25, OracleResources.Unlikely); msg.Embed = null; }); } if (reaction.Emote.Name == fiveEmoji) { await message.ModifyAsync(msg => { msg.Content = AskTheOracleWithChance(10, OracleResources.SmallChance); msg.Embed = null; }); } }); return; }
private async Task CreatureReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { var CreatureHelperEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureHelper) ?? false); if (CreatureHelperEmbed != null) { CreatureEnvironment environment = StarforgedUtilites.CreatureEnvironmentFromEmote(reaction.Emote.Name); if (reaction.Emote.IsSameAs(randomEmoji)) { string lookupValue = Services.GetRequiredService <OracleService>().RandomRow("Creature Environment").Description; environment = StarforgedUtilites.GetAnyEnvironment(lookupValue); } if (environment == CreatureEnvironment.None) { return; } var newCreature = Creature.GenerateNewCreature(Services, channel.Id, environment); Task.WaitAll(message.RemoveAllReactionsAsync()); await message.ModifyAsync(msg => { msg.Content = string.Empty; msg.Embed = newCreature.GetEmbedBuilder().Build(); }).ConfigureAwait(false); await Task.Run(async() => { if (message.Reactions.Count > 0) { await Task.Delay(1500); //wait just in case we are still adding more reactions. Impatient users deserve to wait!!! await message.RemoveAllReactionsAsync(); } await message.AddReactionAsync(revealAspectEmoji).ConfigureAwait(false); }).ConfigureAwait(false); return; } var creatureEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureTitle) ?? false); if (creatureEmbed == null) { return; } var creature = Creature.FromEmbed(creatureEmbed, Services, channel.Id); if (reaction.Emote.IsSameAs(revealAspectEmoji)) { creature.AddRandomAspect(); } await message.ModifyAsync(msg => msg.Embed = creature.GetEmbedBuilder().Build()).ConfigureAwait(false); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); return; }
public async Task OnReactionRemoved(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { if (!(channel is SocketGuildChannel socketGuildChannel)) { return; } var raidInfo = raidStorageService.GetRaid(socketGuildChannel.Guild.Id, channel.Id, message.Id); if (raidInfo == null || raidInfo.IsExpired) { return; } IUserMessage raidMessage = await message.GetOrDownloadAsync(); if (reaction.Emote.Equals(Emojis.ThumbsUp)) { if (raidInfo.Players.TryGetValue(reaction.UserId, out var player)) { logger.LogInformation($"Player '{player}' removed {nameof(UnicodeEmojis.ThumbsUp)} on raid {raidInfo.Message.Id}"); raidInfo.Players.Remove(reaction.UserId); await raidMessage.ModifyAsync(t => t.Embed = ToEmbed(raidInfo)); } } else if (Emojis.KeycapDigits.Contains(reaction.Emote)) { var count = ExtraPlayerKeycapDigitToCount(reaction.Emote.Name); if (raidInfo.ExtraPlayers.Remove((reaction.UserId, count))) { await raidMessage.ModifyAsync(t => t.Embed = ToEmbed(raidInfo)); } } }
public async Task ResetServer() { IUserMessage message = await ReplyAsync("Reseting..."); DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id); if (server != null) { server.Users = new List <ServerUser>(); foreach (SocketGuildUser user in server.Guild.Users) { if (server.Users.Find(x => x.userID == user.Id) == null) { server.Users.Add(new ServerUser(user)); } } } else { await message.ModifyAsync(x => x.Content = "I dont think i did it right."); } server.SaveData(); server.LoadData(); await message.ModifyAsync(x => x.Content = "L-Like this?"); }
public async Task Evaluate(ICommandContext context, string script) { using (context.Channel.EnterTypingState()) { IUserMessage working = await context.Channel.SendMessageAsync("**Evaluating**, just a sec...") .ConfigureAwait(false); var globals = new ScriptGlobals { handler = _handler, client = _client, context = context, dbContext = _dbContext }; script = script.Trim('`'); try { object eval = await CSharpScript .EvaluateAsync(script, _options, globals, cancellationToken : _token.Token) .ConfigureAwait(false); await working.ModifyAsync(x => x.Content = eval.ToString()).ConfigureAwait(false); } catch (Exception e) { await working.ModifyAsync(x => x.Content = $"**Script Failed**\n{e.Message}").ConfigureAwait(false); } } }
/// <summary> /// Do NOT run on main thread or syncronously /// </summary> /// <param name="song"></param> /// <param name="message"></param> /// <returns></returns> public async Task UpdateSaidDownloading(Music.ISong song, IUserMessage message) { TimeSpan timeSpan = new TimeSpan(0, 0, 1, 0); var seconds = timeSpan.Seconds; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.Elapsed.Seconds < seconds) { if (song.FileExists()) { try { if (song.HasTitle()) { await message.ModifyAsync(n => n.Content = "Now playing `" + song.title + "`"); } else { await message.ModifyAsync(n => n.Content = "Now playing `" + song.url + "`"); } } catch (Exception) { } return; } await Task.Delay(5000); } }
public async Task PreviousPageAsync(ReactionHandlerContext context) { if (curPage != 0) { await message.ModifyAsync(x => x.Embed = pages[--curPage]); } }
public async Task EditMessage(ICommandContext context, ulong messageId, string text) { var msgs = await context.Channel.GetMessagesAsync().FlattenAsync() .ConfigureAwait(false); IUserMessage msg = (IUserMessage)msgs.FirstOrDefault(x => x.Id == messageId && x.Author.Id == context.Client.CurrentUser.Id && x is IUserMessage); if (msg == null) { return; } var rep = new ReplacementBuilder() .WithDefault(context) .Build(); if (CREmbed.TryParse(text, out var crembed)) { rep.Replace(crembed); await msg.ModifyAsync(x => { x.Embed = crembed.ToEmbed().Build(); x.Content = crembed.PlainText?.SanitizeMentions() ?? ""; }).ConfigureAwait(false); } else { await msg.ModifyAsync(x => x.Content = text.SanitizeMentions()) .ConfigureAwait(false); } }
private static async void PlayDealerHand(IUserMessage message, SocketGuildChannel guildChannel, SocketReaction reaction) { // No active game, no handling if (activeGame == null) { return; } // Show dealer's second card await message.ModifyAsync(x => x.Embed = GetEmbedBuilder(true).Build()); while (!activeGame.DealerIsStanding) { activeGame.DealCardToDealer(); await message.ModifyAsync(x => x.Embed = GetEmbedBuilder(true).Build()); } // Payout if (activeGame.UserWon) { User user = await UserService.GetUser(guildChannel.Guild.Id, reaction.UserId); int payout = activeGame.Payout(); Log.Write("User (" + activeGame.UserId.ToString() + ") won " + payout.ToString() + " nuts with a game of Black Jack", "Bot - Blackjack"); user.UpdateTotalKupoNuts(payout); } // Game finished - Perform last build, remove reactions, and clear active game await message.ModifyAsync(x => x.Embed = GetEmbedBuilder(true, true).Build()); await message.RemoveAllReactionsAsync(); activeGame = null; }
public async Task SetLogChannel() { IUserMessage message = await ReplyAsync("Setting..."); LogSettings settings = Context.Guild.LoadFromFile <LogSettings>(true); if (settings == null) { await ReplyAsync("Settings is null"); return; } if (Context.Client.GetChannel(settings.logChannel) == Context.Channel) { await message.ModifyAsync(msg => msg.Content = "This channel already is the logging channel"); return; } else { settings.logChannel = Context.Channel.Id; } settings.SaveToFile(Context.Guild); await message.ModifyAsync(msg => msg.Content = "Set log channel to this channel"); }
public async Task SetPubLogChannel(string setNull = null) { IUserMessage message = await ReplyAsync("Setting..."); LogSettings settings = Context.Guild.LoadFromFile <LogSettings>(true); if (!setNull.IsNullOrEmpty() && (setNull.ToLower() == "none" || setNull.ToLower() == "null")) { settings.pubLogChannel = null; settings.SaveToFile(Context.Guild); await message.ModifyAsync(msg => msg.Content = "Set public log channel to null"); return; } if (Context.Client.GetChannel(settings.pubLogChannel ?? 0) == Context.Channel) { await message.ModifyAsync(msg => msg.Content = "This channel already is the logging channel"); return; } else { settings.pubLogChannel = Context.Channel.Id; } settings.SaveToFile(Context.Guild); await message.ModifyAsync(msg => msg.Content = "Set public log channel to this channel"); }
public async Task DanceCommand() { bool SetLeft = true; int Loops = 0; IUserMessage Message = await Context.Channel.SendMessageAsync(@"\o\"); while (Loops < 10) { if (SetLeft) { await Message.ModifyAsync(x => { x.Content = @"\o\"; }); SetLeft = false; } else { await Message.ModifyAsync(x => { x.Content = @"/o/"; }); SetLeft = true; } Loops++; } }
public async Task Purge(int ID) { IUserMessage msg = await Context.Channel.SendMessageAsync("Fetching Data..."); try { PokeAPI.Pokemon p = await DataFetcher.GetApiObject <PokeAPI.Pokemon>(ID); EmbedBuilder builder = new EmbedBuilder() { Title = "Pokemon Request by ID", Color = Color.DarkGreen, ThumbnailUrl = p.Sprites.FrontMale }; builder.Description = $"{FormatHelper.Capatalize(p.Name)} the {FormatHelper.Capatalize((await DataFetcher.GetApiObject<PokemonSpecies>(ID)).Genera[2].Name)}"; EmbedFieldBuilder field = new EmbedFieldBuilder() { Name = "Base Stats", IsInline = true }; foreach (PokemonStats stat in p.Stats) { field.Value += $"{FormatHelper.Capatalize(stat.Stat.Name)}: {stat.BaseValue.ToString()}\n"; } builder.AddField(field); await msg.ModifyAsync(x => { x.Content = ""; x.Embed = builder.Build(); }); } catch { await msg.ModifyAsync(x => x.Content = "Could find pokemon with ID: " + ID); } }
public async Task ToggleInviteWarn() { if (!((SocketGuildUser)Context.User).HasAdmin()) { await ReplyAsync("You do have administrator permissions"); return; } Console.WriteLine(DateTime.Now.ToShortTimeString() + " Toggling invite warn"); IUserMessage message = await ReplyAsync("Trying to toggle"); ModerationFunctions.CheckDirectories(Context.Guild); ModerationSettings settings = null; JsonSerializer serializer = new JsonSerializer(); serializer.NullValueHandling = NullValueHandling.Include; try { StreamReader sr = new StreamReader(@"/home/bob_the_daniel/Data/" + Context.Guild.OwnerId + "/moderationSettings.txt"); JsonTextReader reader = new JsonTextReader(sr); settings = serializer.Deserialize <ModerationSettings>(reader); } catch (Exception error) { await message.ModifyAsync(msg => msg.Content = "an error has occurred loading settings " + error.Message); Console.WriteLine(DateTime.Now.ToShortTimeString() + "an error has occurred loading settings " + error.Message); } if (settings == null) { settings = new ModerationSettings(); Console.WriteLine(DateTime.Now.ToShortTimeString() + " Creating new mod settings"); } settings.invitesAllowed = !settings.invitesAllowed; Console.WriteLine(DateTime.Now.ToShortTimeString() + " setting invites to " + settings.invitesAllowed); /*using (StreamWriter file = File.CreateText(@"/home/bob_the_daniel/Data/" + Context.Guild.OwnerId + "/moderationSettings.text")) { * JsonSerializer newserializer = new JsonSerializer(); * newserializer.Serialize(file, settings); * }*/ using (StreamWriter sw = new StreamWriter(@"/home/bob_the_daniel/Data/" + Context.Guild.OwnerId + "/moderationSettings.txt")) using (JsonTextWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(sw, settings); } if (File.Exists("/home/bob_the_daniel/Data/" + Context.Guild.OwnerId + "/moderationSettings")) { Console.WriteLine(DateTime.Now.ToShortTimeString() + " mod settings saved"); } else { Console.WriteLine(DateTime.Now.ToShortTimeString() + " mod settings not found after creation?!"); } await message.ModifyAsync(msg => msg.Content = "set invites allowed to " + settings.invitesAllowed.ToString().ToLower()); }
private void RunSafari(EmbedBuilder embed, IUserMessage msg, Card newCard, SafariImage pokeImage, ICharacterInfo character, ITextChannel trashChannel) { _ = Task.Run(async() => { try { await Task.Delay(TimeSpan.FromMinutes(5)); var usersReacted = await msg.GetReactionUsersAsync(ClaimEmote, 300).FlattenAsync(); var users = usersReacted.ToList(); IUser winner = null; using (var db = new Database.UserContext(_config)) { var watch = Stopwatch.StartNew(); while (winner == null) { if (watch.ElapsedMilliseconds > 60000) { throw new Exception("Timeout"); } if (users.Count < 1) { embed.Description = $"Na polowanie nie stawił się żaden łowca!"; await msg.ModifyAsync(x => x.Embed = embed.Build()); return; } var selected = Fun.GetOneRandomFrom(users); var dUser = await db.GetCachedFullUserAsync(selected.Id); if (dUser != null) { if (!dUser.IsBlacklisted) { winner = selected; } } else { users.Remove(selected); } } } var exe = GetSafariExe(embed, msg, newCard, pokeImage, character, trashChannel, winner); await _executor.TryAdd(exe, TimeSpan.FromSeconds(1)); await msg.RemoveAllReactionsAsync(); } catch (Exception ex) { _logger.Log($"In Safari: {ex}"); await msg.ModifyAsync(x => x.Embed = "Karta uciekła!".ToEmbedMessage(EMType.Error).Build()); await msg.RemoveAllReactionsAsync(); } }); }
public async Task DynastyMembership(SocketReaction reaction, IUserMessage msg) { (Dynasty dan, DynastyMember manager) = await DynastyCommands.GetDynasty(player); if (manager.PlayerId == data) { await reaction.Channel.SendMessageAsync("You may not perform these actions on yourself"); return; } DynastyMember target = dan.GetMember(data); if (manager.rank > 3 || manager.rank > target.rank) { await reaction.Channel.SendMessageAsync("You do not have the authority for this."); return; } switch (reaction.Emote.ToString()) { case EUI.greaterthan: if (target.rank < 2) { await reaction.Channel.SendMessageAsync("You may not promote this member further"); } else { target.rank--; await dan.Save(); DUtils.DeleteMessage(await reaction.Channel.SendMessageAsync( $"{target.name} was promoted to {dan.rankNames[target.rank]}")); _ = msg.ModifyAsync(m => m.Embed = DynastyCommands.DynastyMemberEmbed( dan, manager, target, out _).WithColor(player.userSettings.Color).Build()); } break; case EUI.lowerthan: if (target.rank > dan.rankNames.Length - 1) { await reaction.Channel.SendMessageAsync("You may not demote this member further"); } else { target.rank++; await dan.Save(); DUtils.DeleteMessage(await reaction.Channel.SendMessageAsync( $"{target.name} was demoted to {dan.rankNames[target.rank]}")); _ = msg.ModifyAsync(m => m.Embed = DynastyCommands.DynastyMemberEmbed( dan, manager, target, out _).WithColor(player.userSettings.Color).Build()); } break; case EUI.cancel: break; } }
public async Task SetProgress(float progress) { var fillCount = (int)(Math.Clamp(progress, 0, 1) * 50); var filler = string.Join("", Enumerable.Repeat('#', fillCount)); var spaces = string.Join("", Enumerable.Repeat('-', 50 - fillCount)); await _message.ModifyAsync(a => a.Content = $"{_prefix} `|{filler}{spaces}|` ({progress * 100:F1}%)"); }
private async Task Open(InventoryWrapper inventory, LootBox variety, int count) { StringBuilder text = new StringBuilder(); IUserMessage message = null; if (count > 1) { string m = string.Concat(Enumerable.Repeat(variety.Emote.ToString() + "\n", count)); message = await ReplyAsync(m); await Task.Delay(1000); } for (int i = 0; i < count; i++) { var box = variety.Open(Context.Bot, 0); if (count == 1) { message = await ReplyAsync(variety.Emote.ToString()); await Task.Delay(1000); StringBuilder animation = new StringBuilder(); foreach (var(rarity, emoji) in box) { animation.Append($"{rarity.LeftBracket}❔{rarity.RightBracket}"); } await message.ModifyAsync(m => m.Content = animation.ToString()); await Task.Delay(1000); animation.Clear(); } foreach (var(rarity, emoji) in box) { var trans = Transaction.FromLootbox(marketId: 0, buyer: inventory.UserId, variety.Name); inventory.Add(new Models.Emoji { Owner = Context.User.Id, Transactions = new List <TransactionInfo>() { Context.Bot.Clerk.Queue(trans).Receive() }, Unicode = emoji }, true); text.Append($"{rarity.LeftBracket}{emoji}{rarity.RightBracket}"); } text.AppendLine(); } inventory.Save(); await message.ModifyAsync(m => m.Content = text.ToString()); }
internal async Task HandleRenameRequestAsync(RenameRequest req, IEmote emote, IUser approver, IUserMessage message) { if (emote.Name != _acceptEmote.Name && emote.Name != _denyEmote.Name) return; if (IsStaffMember(approver as IGuildUser) == false) { var m = await message.Channel.SendMessageAsync($"{approver.Mention} you cannot approve/deny this name change."); _deleteService.ScheduleDeletion(m, 5); return; } bool accepted = emote.Name == _acceptEmote.Name; if (req != null) { if (!accepted) { await message.ModifyAsync(x => x.Embed = Embeds.RequestRename(req.GuildUser, req.Type, req.NewName, accepted, approver.Mention)); _renameRequests.Remove(req); return; } if (req.Type == "discord" || req.Type == "both") { string newDiscordName = ""; if (req.GuildUser.Nickname != null) { int indexOfBracket = req.GuildUser.Nickname.IndexOf("]"); if (indexOfBracket == -1) newDiscordName = req.NewName; else newDiscordName = req.GuildUser.Nickname.Substring(0, indexOfBracket + 1) + " " + req.NewName; } else newDiscordName = req.NewName; await req.GuildUser.ModifyAsync(x => { x.Nickname = newDiscordName; }).ConfigureAwait(false); } if (req.Type == "spreadsheet" || req.Type == "both") { int row = _dsn.GetRowNumber(req.GuildUser.Id); if (row != -1) { string sectionToEdit = $"Player Data!C{row}"; _dsn.MakeRequest(sectionToEdit, new List<object>() { req.NewName }); return; } } await message.ModifyAsync(x => x.Embed = Embeds.RequestRename(req.GuildUser, req.Type, req.NewName, accepted, approver.Mention)); _renameRequests.Remove(req); } }
public async Task First() { await _msg.RemoveReactionAsync(new Emoji(SFirst), _user); if (_currentPage == 0) { return; } await _msg.ModifyAsync(m => m.Embed = GetPage((int)(_currentPage = 0))); }
protected override async Task CloseMessageAsync(IUserMessage message, InteractivityResult <TValue> result) { if (result.IsCancelled && CancelledPage != null) { await message.ModifyAsync(x => { x.Content = CancelledPage.Text; x.Embed = CancelledPage.Embed; }); } if (result.IsTimeouted && TimeoutedPage != null) { await message.ModifyAsync(x => { x.Content = TimeoutedPage.Text; x.Embed = TimeoutedPage.Embed; }); } }
public static async Task TeamInviteMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList) { switch (emote.Name.ToLower()) { case "check": if (user.GetTeam() == null) { if (user.InviteMessages.ContainsKey(message.Id)) { var otherUser = UserHandler.GetUser(user.InviteMessages[message.Id]); if (otherUser.GetTeam() != null) { user.InviteMessages.Remove(message.Id); user.RemoveAllReactionMessages(10); otherUser.GetTeam().AddMember(user); await message.RemoveAllReactionsAsync(); //FOR FUTURE USE- When bot has no permissions, this can be used to remove bot-only reactions //await message.RemoveReactionAsync(await MessageHandler.GetEmoji(736480922152730665), message.Author); await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = ""; }); await MessageHandler.TeamMenuEmojis(message, user); //Update the menu of the person who sent the invite foreach (KeyValuePair <ulong, int> kvp in otherUser.ReactionMessages) { if (kvp.Value == 7) { IMessage teamMess = await message.Channel.GetMessageAsync(kvp.Key); if (teamMess is IUserMessage) { IUserMessage userTeamMess = (IUserMessage)teamMess; await userTeamMess.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(otherUser); m.Content = ""; }); } } } } } } break; case "redx": user.InviteMessages.Remove(message.Id); user.RemoveAllReactionMessages(10); await message.ModifyAsync(m => { m.Content = "Invite Declined."; }); break; default: break; } }
public async Task Dice() { var rawEmojis = new[] { "one", "two", "three", "four", "five", "six" }; var rotatingNumbers = new[] { "<a:rotating_numbers_1ms:722399064704024596>", "<a:rotating_numbers_10ms:722399064737710121>", "<a:rotating_numbers_50ms:722399237413011466>", }; var unicodeEmojis = new List <string>(); Random randomGen = new Random(); foreach (var rawEmoji in rawEmojis) { var emoji = GEmojiSharp.Emoji.Get(rawEmoji); unicodeEmojis.Add(emoji.Raw); } IUserMessage message = null; foreach (var rot in rotatingNumbers) { var text = $"Ein zufälliger Algorithmus würfelt.... :game_die: {rot}"; if (message == null) { message = await Context.Channel.SendMessageAsync(text); await Task.Delay(TimeSpan.FromSeconds(2.5)); continue; } await message.ModifyAsync(x => x.Content = text); await Task.Delay(TimeSpan.FromSeconds(2.5)); } int random = randomGen.Next(0, 6); await message.ModifyAsync(msg => msg.Content = $"Ein zufälliger Algorithmus würfelt.... :game_die: {unicodeEmojis[random]}\nDie Würfel sind gefallen!"); logger.LogInformation($"{Context.User} hat die Zahl {random + 1} gewürfelt!"); }
public static async Task PvPMainMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList) { switch (emote.Name.ToLower()) { case "back1": user.RemoveAllReactionMessages(11); user.RemoveAllReactionMessages(1); await message.RemoveAllReactionsAsync(); await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.MainMenu(user); m.Content = ""; }); await MessageHandler.MenuEmojis(message); user.ReactionMessages.Add(message.Id, 1); break; case "singlebattle": user.RemoveAllReactionMessages(12); user.RemoveAllReactionMessages(11); user.RemoveAllReactionMessages(1); CombatCreationTool lobby = user.GetOrCreatePvPLobby("single", user.UserId); await message.RemoveAllReactionsAsync(); string url = MessageHandler.GetImageURL(ImageGenerator.PvPSoloLobby(lobby)).Result; await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.PvPLobby(lobby, url, user); m.Content = ""; }); await MessageHandler.PvPLobbyEmojis(message, user); user.ReactionMessages.Add(message.Id, 12); break; case "doublebattle": await MessageHandler.NotImplemented(idList, "double battle"); break; case "ffa": await MessageHandler.NotImplemented(idList, "free for all"); break; case "custombattle": await MessageHandler.NotImplemented(idList, "custom battle"); break; default: break; } }
private Task messageEventHandler(SocketMessage parameterMessage) { if (parameterMessage.Author.Id != User || parameterMessage.Channel.Id != _channel) { return(Task.CompletedTask); } var _ = Task.Run(async() => { try { var any = parameterMessage.Content.Split().Intersect(_dictionary.Keys); var enumerable = any as string[] ?? any.ToArray(); Task post; if (enumerable.Any()) { var outputString = _dictionary[enumerable.FirstOrDefault()].Item1; var outputEmbed = _dictionary[enumerable.FirstOrDefault()].Item2; if (outputEmbed != null) { post = _messageToEdit.ModifyAsync(x => { x.Content = outputString; x.Embed = outputEmbed().Build(); }); } else { post = _messageToEdit.ModifyAsync(x => x.Content = outputString); } _followUpService.RemoveFollowUp(this); await post.ConfigureAwait(false); } else if (DateTime.Now.Subtract(_creationTime) > TimeSpan.FromMinutes(2)) { post = _messageToEdit.ModifyAsync(x => x.Content = "Command timed out."); _followUpService.RemoveFollowUp(this); await post.ConfigureAwait(false); } } catch (Exception ex) { Log.Warning(ex, ex.Message); } }); return(Task.CompletedTask); }
private async Task CreatureReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { var CreatureHelperEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureHelper) ?? false); if (CreatureHelperEmbed != null) { CreatureEnvironment environment = StarforgedUtilites.CreatureEnvironmentFromEmote(reaction.Emote.Name); if (reaction.Emote.Name == randomEmoji.Name) { string lookupValue = Services.GetRequiredService <OracleService>().RandomRow("Creature Environment").Description; environment = StarforgedUtilites.GetAnyEnvironment(lookupValue); } if (environment == CreatureEnvironment.None) { return; } var newCreature = Creature.GenerateCreature(Services, channel.Id, environment); Task.WaitAll(message.RemoveAllReactionsAsync()); await message.ModifyAsync(msg => { msg.Content = string.Empty; msg.Embed = newCreature.GetEmbedBuilder().Build(); }).ConfigureAwait(false); await message.AddReactionAsync(revealAspectEmoji).ConfigureAwait(false); return; } var creatureEmbed = message.Embeds.FirstOrDefault(embed => embed?.Title?.Contains(CreatureResources.CreatureTitle) ?? false); if (creatureEmbed == null) { return; } var creature = Creature.FromEmbed(creatureEmbed, Services, channel.Id); if (reaction.Emote.Name == revealAspectEmoji.Name) { creature.RevealedAspectsToShow++; } await message.ModifyAsync(msg => msg.Embed = creature.GetEmbedBuilder().Build()).ConfigureAwait(false); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); return; }
public async Task AcronymCmd() { #region Preparation //Stage 1 IUserMessage msg = await Context.Channel.SendMessageAsync("Welcome to the Acronym Game! In 10 seconds i will give 6 letters for you to make an acronym (You can do this with multiple people!)"); string acroLetters = _lib.GetRandomLetters(6); await Task.Delay(TimeSpan.FromSeconds(10)); //Stage 2 await msg.ModifyAsync(x => x.Content = $":timer: *You have 1 minute to make an acronym with the following letters!* **{acroLetters}** *(Only 10 submissions will be included)*"); await Task.Delay(TimeSpan.FromSeconds(5)); IUserMessage msg2 = await Context.Channel.SendMessageAsync("To submit an acronym, send your message starting with '*'. After that, just write your acronym.\nhttps://cdn.discordapp.com/attachments/412350471584481291/473955216518021130/unknown.png"); await Task.Delay(TimeSpan.FromMinutes(1)); await msg2.DeleteAsync(); #endregion //Stage 3 var messages = await Context.Channel.GetMessagesAsync(10).FlattenAsync(); IMessage[] messagesObj = messages.Where(x => x.Content.StartsWith("*")).ToArray(); //Get Message Count int messageCount = messagesObj.Count(); int winnerNum = new Random().Next(-1, messageCount + 1); int otherShit = 0; foreach (var message in messagesObj) { if (message == null) { continue; } if (winnerNum == otherShit) { if (message.Author.IsBot) { continue; } await msg.ModifyAsync(x => x.Content = $"{message.Author.Mention} has won the the acronym with '{message.Content}'"); await ReplyAsync("Game End! Before you start another game, please delete the previous submissions, as they would be included in the next game."); return; } otherShit++; } }
public static async Task CreateTeamMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList) { switch (emote.Name.ToLower()) { case "back1": user.RemoveAllReactionMessages(9); user.RemoveAllReactionMessages(1); await message.RemoveAllReactionsAsync(); await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.MainMenu(user); m.Content = ""; }); await MessageHandler.MenuEmojis(message); user.ReactionMessages.Add(message.Id, 1); break; case "team": Team t = new Team(true); t.AddMember(user); TownHandler.GetTown(user.Char.CurrentGuildId).Teams.Add(t); if (user.ExpectedInput == 5) { user.ExpectedInput = -1; user.ExpectedInputLocation = 0; } user.RemoveAllReactionMessages(9); user.RemoveAllReactionMessages(7); await message.RemoveAllReactionsAsync(); await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = ""; }); await MessageHandler.TeamMenuEmojis(message, user); break; case "invite": await message.ModifyAsync(m => { m.Content = "**Tag someone in the team you want to join. The team must be open.**"; }); user.ExpectedInput = 5; user.ExpectedInputLocation = message.Channel.Id; break; default: break; } }