示例#1
0
        public BotSettings()
        {
            Console.WriteLine("Bot Setting Commands Loaded");
            if (!File.Exists("guildSettings.json"))
            {
                Console.Write("Guild Settings Config File Not Found. Creating One...");
                GuildSettings item = new GuildSettings();
                item.UseAutoRoles       = false;
                item.UseGlobalPrefix    = true;
                item.UseLevelRoles      = false;
                item.UseLevels          = false;
                item.UseSelfRoles       = false;
                item.AllowRolesPurchase = false;
                item.UseAutoRoles       = false;
                item.LevelRoles         = new Dictionary <string, int>();
                item.Prefixes           = new List <string>();
                item.SelfRoles          = new Dictionary <string, int>();
                item.Prefixes.Add(">");
                // this line... is a test line.

                GuildSettings = new Dictionary <string, GuildSettings>();
                GuildSettings.Add("default", item);

                string output = JsonConvert.SerializeObject(GuildSettings);
                File.WriteAllTextAsync("guildSettings.json", output);
                Console.WriteLine(" Done!");
            }
            var json = "";

            using (var fs = File.OpenRead("guildSettings.json"))
                using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
                    json = sr.ReadToEnd();

            GuildSettings = JsonConvert.DeserializeObject <Dictionary <string, GuildSettings> >(json);
        }
示例#2
0
            public async Task GetPrefixes(CommandContext ctx)
            {
                await ctx.TriggerTypingAsync();

                var guild = ctx.Guild.Id.ToString();

                if (!GuildSettings.ContainsKey(guild))
                {
                    await ctx.RespondAsync("No guild settings found.");
                }
                else
                {
                    var server = GuildSettings[guild];
                    DiscordEmbedBuilder embed = new DiscordEmbedBuilder
                    {
                        Description = $"{ctx.Guild.Name} Settings."
                    };
                    embed.AddField("Prefix(es)", server.Prefixes.ToString());
                    embed.AddField("Use Global Prefix", server.UseGlobalPrefix.ToString(), true);
                    embed.AddField("Self Roles Enabled", server.UseSelfRoles.ToString(), true);
                    embed.AddField("Level Roles Enabled", server.UseLevelRoles.ToString(), true);
                    embed.AddField("Self Role Buy", server.AllowRolesPurchase.ToString(), true);
                    await ctx.RespondAsync(embed);
                }
            }
示例#3
0
            public async Task RemovePrefix(CommandContext ctx, string prefix)
            {
                await ctx.TriggerTypingAsync();

                GuildSettings.Remove(prefix);
                await ctx.RespondAsync($"Removed `{prefix}` as a command prefix.");
            }
示例#4
0
        public async Task GetPrefixes(CommandContext ctx)
        {
            // store the Guild ID as a string.
            string guild = ctx.Guild.Id.ToString();

            // if this server doesnt have a settings for whatever reason, let them know... why am i not creating it?
            if (!GuildSettings.ContainsKey(guild))
            {
                await ctx.RespondAsync("No guild settings found.");
            }
            else
            {
                // we have server settings... why does this give so much info? it should only show only prefix(es)
                GuildSettings       server = GuildSettings[guild];
                DiscordEmbedBuilder embed  = new DiscordEmbedBuilder
                {
                    Description = $"{ctx.Guild.Name} Prefixes."
                };
                int count = 1;
                // for each prefix, list it in the embed as a field. Show a count.
                foreach (string item in server.Prefixes)
                {
                    embed.AddField($"Prefix {count}", item, true);
                    count++;
                }
                await ctx.RespondAsync(embed);
            }
        }
示例#5
0
        private Task Event_GuildAvailable(DiscordClient d, GuildCreateEventArgs e)
        {
            string gId = e.Guild.Id.ToString();

            // this guild doesnt have settings, make a skel set for them.
            if (!BotSettings.GuildSettings.ContainsKey(gId))
            {
                Console.WriteLine("making config");
                GuildSettings item = new GuildSettings();
                item.UseAutoRoles       = false;
                item.UseGlobalPrefix    = true;
                item.UseLevelRoles      = false;
                item.UseLevels          = false;
                item.UseSelfRoles       = false;
                item.AllowRolesPurchase = false;
                item.UseAutoRoles       = false;
                item.LevelRoles         = new Dictionary <string, int>();
                item.Prefixes           = new List <string>();
                item.SelfRoles          = new Dictionary <string, int>();
                // this line... is a test line.
                BotSettings.GuildSettings.Add(gId, item);
            }

            if (e.Guild.Id == 376937422010974209)
            {
            }
            // let's log the name of the guild that was just
            // sent to our client
            d.Logger.LogInformation(BotEventId, $"Guild available: {e.Guild.Name}");

            // since this method is not async, let's return
            // a completed task, so that no additional work
            // is done
            return(Task.CompletedTask);
        }
示例#6
0
 public BotSettings()
 {
     Console.WriteLine("Bot Setting Commands Loaded");
     if (!(GuildSettings is null))
     {
         // guild settings have already been set... stop resetting it.
         return;
     }
     // Check for guild settings file. If it doesnt exist, create it.
     if (!File.Exists(s_fileName))
     {
         // Since we need to creat it, we're going to set some default stuff.
         Console.Write("Guild Settings Config File Not Found. Creating One...");
         GuildSettings item = new GuildSettings
         {
             UseAutoRoles       = false,
             UseGlobalPrefix    = true,
             UseLevelRoles      = false,
             UseLevels          = false,
             UseSelfRoles       = false,
             AllowRolesPurchase = false
         };
         item.UseAutoRoles = false;
         item.LevelRoles   = new Dictionary <int, List <string> >();
         item.Prefixes     = new List <string>();
         item.SelfRoles    = new Dictionary <string, Dictionary <string, int> >();
         item.Prefixes.Add(">");
         // this line... is a test line.
         GuildSettings = new Dictionary <string, GuildSettings>
         {
             { "default", item }
         };
         // Now that we have the initial stuff in memory, write it to file.
         string output = JsonConvert.SerializeObject(GuildSettings);
         File.WriteAllTextAsync(s_fileName, output);
         // in form the console reader that we're done making the initial config.
         Console.WriteLine(" Done!");
     }
     else
     {
         // load the config file to memory.
         string json = "";
         using (FileStream fs = File.OpenRead(s_fileName))
             using (StreamReader sr = new StreamReader(fs, new UTF8Encoding(false)))
                 json = sr.ReadToEnd();
         GuildSettings = JsonConvert.DeserializeObject <Dictionary <string, GuildSettings> >(json);
     }
     _cancelToken = new CancellationTokenSource();
     _            = StartTimer(_cancelToken.Token);
 }
示例#7
0
        public async Task BaseItem(CommandContext ctx)
        {
            GuildSettings       guild = GuildSettings[ctx.Guild.Id.ToString()];
            DiscordEmbedBuilder embed = StartEmbed(ctx.Guild.Name + " Server settings.");

            embed.AddField("On/Off Items", "_ _");
            embed.AddField("Global Prefix", (guild.UseGlobalPrefix ? "On" : "Off"), true);
            embed.AddField("Self Roles", (guild.UseSelfRoles ? "On" : "Off"), true);
            embed.AddField("Level Roles", (guild.UseLevelRoles ? "On" : "Off"), true);
            embed.AddField("Auto Roles", (guild.UseAutoRoles ? "On" : "Off"), true);
            embed.AddField("Levels", (guild.UseLevels ? "On" : "Off"), true);
            embed.AddField("Welcome Msg", (guild.UseWelcome ? "On" : "Off"), true);
            embed.AddField("Counts", "_ _");
            embed.AddField("Prefixes", guild.Prefixes.Count.ToString(), true);
            embed.AddField("Self Groups", guild.SelfRoles.Count.ToString(), true);
            embed.AddField("Levels", guild.LevelRoles.Count.ToString(), true);
            await ctx.RespondAsync(embed);
        }