예제 #1
0
        public async Task InitializeLeaderboard()
        {
            using (Context.Channel.EnterTypingState())
            {
                try
                {
                    _logger.LogInformation("Executing init");
                    if (Context.Guild?.Id == null)
                    {
                        await ReplyAsync("Doesn't seem like this is written inside a server.");

                        return;
                    }

                    var leaderboard = await _leaderboardService.GetForServer(Context.Guild.Id.ToString());

                    if (leaderboard != null)
                    {
                        await ReplyAsync("Seems like a leaderboard is already setup on this server");

                        return;
                    }

                    leaderboard = new Leaderboard {
                        ServerId  = Context.Guild.Id.ToString(),
                        ChannelId = Context.Channel.Id.ToString()
                    };
                    await _leaderboardService.Create(leaderboard);
                    await ReplyAsync("Initialized leaderboard for this server. Users can join by using the `join` command.");
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "init failed");
                }
            }
        }
예제 #2
0
        public ActionResult <Record> Create([FromBody] RecordMinimal recordMinimal)
        {
            var record = _leaderboardService.Create(recordMinimal);

            return(CreatedAtRoute("GetRecord", new { id = record.Id.ToString() }, record));
        }