Exemple #1
0
        public async Task InitGuild(IGuild guild)
        {
            if (Languages.ContainsKey(guild.Id)) // If somehow InitGuild is called 2 times for the same guild we ignore it
            {
                return;
            }
            string guildIdStr = guild.Id.ToString();

            if (await R.Db(dbName).Table("Guilds").GetAll(guildIdStr).Count().Eq(0).RunAsync <bool>(conn))
            {
                await R.Db(dbName).Table("Guilds").Insert(R.HashMap("id", guildIdStr)
                                                          .With("Prefix", "s.")
                                                          .With("Language", "en")
                                                          .With("Availability", defaultAvailability)
                                                          ).RunAsync(conn);
            }
            dynamic json = await R.Db(dbName).Table("Guilds").Get(guildIdStr).RunAsync(conn);

            Languages.Add(guild.Id, (string)json.Language);
            Prefixs.Add(guild.Id, (string)json.Prefix);
            string availability = (string)json.Availability;

            if (availability == null)
            {
                Availability.Add(guild.Id, defaultAvailability);
            }
            else
            {
                string newAvailability = availability;
                while (newAvailability.Length < defaultAvailability.Length)
                {
                    newAvailability += "1";
                }
                Availability.Add(guild.Id, newAvailability);
            }
            string anonymize = (string)json.Anonymize;

            if (anonymize != null)
            {
                Anonymize.Add(guild.Id, bool.Parse(anonymize));
            }
            else
            {
                Anonymize.Add(guild.Id, false);
            }
            string anime = (string)json.animeSubscription;

            if (anime != null && anime != "0")
            {
                AnimeSubscription.Add((await guild.GetTextChannelAsync(ulong.Parse(anime)), null));
            }
            string nhentai = (string)json.nhentaiSubscription;

            if (nhentai != null && nhentai != "0")
            {
                NHentaiSubscription.Add((await guild.GetTextChannelAsync(ulong.Parse(nhentai)), Subscription.SubscriptionTags.ParseSubscriptionTags(json.nhentaiSubscriptionTags.ToObject <string[]>(), false)));
            }
        }
Exemple #2
0
        public async Task InitGuild(ulong guildId)
        {
            if (Languages.ContainsKey(guildId)) // If somehow InitGuild is called 2 times for the same guild we ignore it
            {
                return;
            }
            string guildIdStr = guildId.ToString();

            if (await R.Db(dbName).Table("Guilds").GetAll(guildIdStr).Count().Eq(0).RunAsync <bool>(conn))
            {
                await R.Db(dbName).Table("Guilds").Insert(R.HashMap("id", guildIdStr)
                                                          .With("Prefix", "s.")
                                                          .With("Language", "en")
                                                          .With("Availability", defaultAvailability)
                                                          ).RunAsync(conn);
            }
            dynamic json = await R.Db(dbName).Table("Guilds").Get(guildIdStr).RunAsync(conn);

            Languages.Add(guildId, (string)json.Language);
            Prefixs.Add(guildId, (string)json.Prefix);
            string availability = (string)json.Availability;

            if (availability == null)
            {
                Availability.Add(guildId, defaultAvailability);
            }
            else
            {
                string newAvailability = availability;
                while (newAvailability.Length < defaultAvailability.Length)
                {
                    newAvailability += "1";
                }
                Availability.Add(guildId, newAvailability);
            }
        }