Ejemplo n.º 1
0
        public async Task Muppet()
        {
            if (Context.User.Id != Constants.OwnerId)
            {
                return;
            }

            List <ulong>  configExists      = new List <ulong>();
            List <ulong>  configDoesntExist = new List <ulong>();
            List <IGuild> guilds            = new List <IGuild>();

            var files = BotFiles.GetConfiguredServerFileNames();

            foreach (var shard in Program.client.Shards)
            {
                foreach (var guild in shard.Guilds)
                {
                    if (!guilds.Contains(guild))
                    {
                        guilds.Add(guild);
                    }
                }
            }

            await Context.Channel.SendMessageAsync("Checking " + guilds.Count + " Guilds.");

            foreach (var guild in guilds)
            {
                if (!files.Contains(guild.Id.ToString()))
                {
                    configDoesntExist.Add(guild.Id);
                }
            }

            var message = "```";

            foreach (var guild in configDoesntExist)
            {
                var g = await Context.Client.GetGuildAsync(guild);

                var o = await g.GetOwnerAsync();

                message += "Name: " + g.Name + " (" + g.Id + ") - Owner: " + o.Username + " (" + o.Id + ")\r\n";
            }

            message += "```";

            await Context.Channel.SendMessageAsync(message);
        }
Ejemplo n.º 2
0
        public async Task PurgeServers()
        {
            if (Context.User.Id != Constants.OwnerId)
            {
                return;
            }

            List <ulong>  toKeep   = new List <ulong>();
            List <ulong>  toDelete = new List <ulong>();
            List <IGuild> guilds   = new List <IGuild>();

            var files = BotFiles.GetConfiguredServerFileNames();

            foreach (var shard in Program.client.Shards)
            {
                foreach (var guild in shard.Guilds)
                {
                    if (!guilds.Contains(guild))
                    {
                        guilds.Add(guild);
                    }
                }
            }

            foreach (var guild in guilds)
            {
                if (files.Contains(guild.Id.ToString()))
                {
                    toKeep.Add(guild.Id);
                }
            }

            foreach (var file in files)
            {
                Console.WriteLine("File: " + file);
                if (!toKeep.Contains(ulong.Parse(file)))
                {
                    toDelete.Add(ulong.Parse(file));
                }
            }

            foreach (var server in toDelete)
            {
                File.Move(Constants.ConfigRootDirectory + Constants.GuildDirectory + @"\" + server + ".json", @"C:\temp\" + server + ".json");
            }
        }