예제 #1
0
        public async Task <RuntimeResult> CancelNextAsync()
        {
            var campaign = await _campaignService.GetByTextChannelId(Context.Channel.Id);

            if (campaign == null)
            {
                return(GameMasterResult.ErrorResult("you are not in a campaign text channel."));
            }

            var commandIssuer = Context.Guild.GetUser(Context.User.Id);

            if (campaign.GameMaster.User.DiscordId != Context.User.Id && !commandIssuer.GuildPermissions.Administrator)
            {
                return(GameMasterResult.ErrorResult("you do not have permission to cancel a session for this campaign. You must either be the Game Master of this campaign or a Server Administrator."));
            }

            try
            {
                await _sessionService.CancelNext(campaign.Id);
                await ReplyAsync("Next session cancelled successfully.");

                return(GameMasterResult.SuccessResult());
            }
            catch (Exception e)
            {
                return(GameMasterResult.ErrorResult(e.Message));
            }
        }