Exemplo n.º 1
0
        private Task Client_Chat(MessageCreateEventArgs e)
        {
            DSharpPlus.Entities.DiscordMessage content = e.Message;
            if (!e.Channel.IsPrivate)
            {
                guildData dataGet = data[Utils.retrieveGuild(e.Guild.Id)];
                use     = dataGet.on;
                Channel = dataGet.disabledChannelID;
            }
            else
            {
                Channel = 0;
                use     = true;
            }

            if (!containPrefix(Config.CommandPrefixes, content.Content))
            {
                if (!debugMode || e.Channel.IsPrivate ? true : e.Guild.Id == ulong.Parse(Config.DebugGuildID))
                {
                    if (use == true)
                    {
                        if (e.Author != Discord.CurrentUser)
                        {
                            if (e.Channel.Id == Channel || Channel == 0)
                            {
                                //Refresh all of the games
                                foreach (Game game in games)
                                {
                                    game.UpdateChatGame(e);
                                }
                                bot = new ChatBot(e.Message.Author.Username, null);
                                content.RespondAsync(showOutput(content.Content));
                                bot = null;
                            }
                        }
                    }
                    Debug.Log("Chat: " + content.Author + " : " + content.Content, Discord);
                }
            }
            else if (containPrefix(Config.CommandPrefixes, content.Content) && e.Channel.IsPrivate)
            {
                content.RespondAsync("No commands are executable in private messaging!");
            }
            string json = JsonConvert.SerializeObject(data);

            File.WriteAllText("prefs.json", json);
            return(Task.CompletedTask);
        }