Beispiel #1
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (Program.CurrentState == Program.State.Booting || Program.CurrentState == Program.State.Exiting || s.Author.IsBot)
            {
                return;
            }

            GuildSettings guildSet = GuildSettings.Load(s);

            if (!(s is SocketUserMessage msg) || (guildSet != null && guildSet.Ignore))
            {
                return;
            }

            CustomCommandContext context = new CustomCommandContext(_client, msg)
            {
                guildSettings = guildSet
            };

            string prefix = guildSet == null ? "" : guildSet.prefix == null || guildSet.prefix.Length < 1 ? defaultPrefix : guildSet.prefix;

            if (MessageIsApproved(msg, prefix, out int argPosition) && await GameMaster.VerifyChannel(context, guildSet))
            {
                switch (Program.CurrentState)
                {
                case Program.State.Paused:
                    if (s.Author.Id != 201875246091993088)
                    {
                        DUtils.DeleteMessage(await context.Channel.SendMessageAsync(
                                                 "Server under maintenance, please refer to the support server for more information."));
                        return;
                    }
                    break;

                case Program.State.Ready: break;

                case Program.State.Updating:
                    DUtils.DeleteMessage(await context.Channel.SendMessageAsync("Leaving for tea break soon. [Incoming Update]"));
                    break;
                }

                if (!RunUser(s.Author.Id))
                {
                    return;
                }

                _ = context.BotUser;
                _ = Task.Run(async() =>
                {
                    try
                    {
                        await _command.ExecuteAsync(context, argPosition, null);
                    }
                    catch (Exception e)
                    {
                        Log.LogS(e);
                    }
                });
            }
        }