コード例 #1
0
        public async Task ModifyDefaultChannel(CommandContext ctx, DiscordChannel channel)
        {
            await ctx.TriggerTypingAsync();

            if (!await this.CheckPermission(_permissionService, typeof(SettingsCommands), nameof(SettingsCommands.ModifyDefaultChannel), ctx.Member))
            {
                await ctx.RespondAsync("You are not permitted to use this command.");

                return;
            }

            ulong defaultChannel = 0;

            try
            {
                defaultChannel = await _calendarService.UpdateCalendarDefaultChannelAsync(ctx.Guild.Id, channel.Id);
            }
            catch (CalendarNotFoundException)
            {
                await ctx.RespondAsync("Calendar not initialised. Run `init <timezone>` to initialise the calendar.");

                return;
            }

            await RescheduleAllEvents(ctx, defaultChannel);

            await ctx.RespondAsync($"Updated default channel to {defaultChannel.AsChannelMention()}.");
        }