Beispiel #1
0
        public override async Task <TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
        {
            if (EmoteUtils.TryParse(input, out var result))
            {
                return(TypeReaderResult.FromSuccess(result));
            }

            return(TypeReaderResult.FromError(CommandError.ParseFailed, $"Unable to parse emote `{input}`."));
        }
Beispiel #2
0
        private static async Task ModifyXP(Func <ulong, ulong> xpModifier, SocketGuildUser user, SocketUserMessage message = null)
        {
            var server       = user.Guild;
            var serverMemory = MemorySystem.memory[server];
            var userMemory   = serverMemory[user];
            var xpUserData   = userMemory.GetData <XPSystem, XPServerUserData>();

            uint prevLvl = XPToLevel(xpUserData.xp);

            xpUserData.xp = xpModifier(xpUserData.xp);

            uint newLvl = XPToLevel(xpUserData.xp);

            if (message != null)
            {
                if (newLvl > prevLvl)
                {
                    try {
                        await message.AddReactionAsync(EmoteUtils.Parse("🌟"));
                    }
                    catch (Exception e) {
                        await MopBot.HandleException(e);
                    }
                }

                /*var mentionChannel = (ITextChannel)(serverMemory.GetData<ChannelSystem,ChannelServerData>().GetChannelByRole(ChannelRole.BotArea) ?? channel);
                 * string text = $"{user.Name()} has just reached level {newLvl}! :star:";
                 *
                 * var xpServerData = serverMemory.GetData<XPSystem,XPServerData>();
                 *
                 * if(xpServerData.levelRewards.TryGetValue(newLvl,out ulong[] roleIds)) {
                 *      var oldAccessLevel = user.GetAccessLevel();
                 *      var oldCommandList = CommandService.commands.Where(h => oldAccessLevel>=h.minAccessLevel);
                 *      var roles = roleIds.Select(id => server.GetRole(id));
                 *
                 *      text += $"\r\nThe following roles are now available to them:```{string.Join("\r\n",roles.Select(role => role.Name))}```";
                 *
                 *      await user.AddRolesAsync(roles);
                 *
                 *      var newAccessLevel = user.GetAccessLevel(roleIds);
                 *      var newCommandList = CommandService.commands.Where(h => newAccessLevel>=h.minAccessLevel);
                 *      var newCommandsOnly = newCommandList.Where(h => !oldCommandList.Contains(h)).ToArray();
                 *
                 *      if(newCommandsOnly.Length>0) {
                 *              text += $"\r\nThe following commands are now available to them:```{string.Join("\r\n",newCommandsOnly.Select(h => $"{string.Join("/",h.aliases)}-{h.description}"))}```";
                 *      }
                 * }
                 *
                 * await mentionChannel.SendMessageAsync(text);*/
            }
        }
        public bool TryGetEmote(EmoteType emoteType, out IEmote emote)
        {
            emote = null;

            return(emotes != null && emotes.TryGetValue(emoteType, out string emoteStr) && EmoteUtils.TryParse(emoteStr, out emote));
        }