Ejemplo n.º 1
0
        public static async Task ProcessExperienceAsync(ICommandContext context, Guild sguild)
        {
            if (sguild is null)
            {
                return;
            }

            using var Database = new SkuldDbContextFactory().CreateDbContext();

            if (!Database.Features.Any(x => x.Id == sguild.Id))
            {
                Database.Features.Add(new GuildFeatures
                {
                    Id = sguild.Id
                });
                await Database.SaveChangesAsync().ConfigureAwait(false);
            }

            GuildFeatures features = Database.Features.Find(sguild.Id);

            if (features.Experience)
            {
                await ExperienceService.HandleExperienceAsync(context);
            }
        }
Ejemplo n.º 2
0
        public static async Task HandleSideTasksAsync(ICommandContext context)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            Guild sguild = null;

            if (context.Guild != null)
            {
                sguild = await
                         Database.InsertOrGetGuildAsync(context.Guild)
                         .ConfigureAwait(false);
            }

            if (sguild != null)
            {
                if (!Database.Features.Any(x => x.Id == sguild.Id))
                {
                    Database.Features.Add(new GuildFeatures
                    {
                        Id = sguild.Id
                    });
                    await Database.SaveChangesAsync().ConfigureAwait(false);
                }

                GuildFeatures features = Database.Features.Find(sguild.Id);
                if (features.Experience)
                {
                    _ = Task.Run(() => ExperienceService.HandleExperienceAsync(context));
                }

                if (!Database.Modules.Any(x => x.Id == sguild.Id))
                {
                    Database.Modules.Add(new GuildModules
                    {
                        Id = sguild.Id
                    });
                    await Database.SaveChangesAsync().ConfigureAwait(false);
                }

                GuildModules modules;
                if (!Database.Modules.Any(x => x.Id == sguild.Id))
                {
                    Database.Modules.Add(new GuildModules
                    {
                        Id = sguild.Id
                    });
                    await Database.SaveChangesAsync().ConfigureAwait(false);
                }

                modules = Database.Modules.Find(sguild.Id);

                if (modules.Custom)
                {
                    _ = Task.Run(() => CustomCommandService.HandleCustomCommandAsync(context, SkuldApp.Configuration));
                }
            }
        }