private async Task HandleCustomCommandAddAsync(string key, string value)
        {
            CustomCommand cc = _db.CustomCommands.FirstOrDefault(x => x.Command == key);

            if (cc != null)
            {
                await Context.Channel.SendMessageAsync($"Custom Command: {key} already exists").ConfigureAwait(false);
            }
            else
            {
                // TODO: ADD Validation so that it can't overlap with real commands.
                if (_commandHandler.ContainsCommand(key))
                {
                    return;
                }

                cc = new CustomCommand
                {
                    Command     = key,
                    ReturnValue = value
                };
                _db.Add(cc);
                await _db.SaveChangesAsync();

                await Context.Channel.SendMessageAsync($"Custom Command: {key} was created.").ConfigureAwait(false);
            }
        }
示例#2
0
        public async Task HandleManualPeakCommandAsync(string platform, string user, int season, int peak)
        {
            ManualPeakOverride manual = _db.ManualPeakOverrides.Find(platform, user, season);

            if (manual is null)
            {
                manual = new ManualPeakOverride
                {
                    Platform = platform,
                    User     = user,
                    Season   = season,
                    Peak     = peak
                };

                _db.Add(manual);
                await _db.SaveChangesAsync().ConfigureAwait(false);

                await Context.Channel.SendMessageAsync("Added manual peak");
            }
            else
            {
                manual.Peak             = peak;
                _db.Entry(manual).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                await _db.SaveChangesAsync().ConfigureAwait(false);

                await Context.Channel.SendMessageAsync("Modified manual peak");
            }
        }