public async Task Create(CommandContext ctx, params string[] args) { await ctx.TriggerTypingAsync(); if (!await this.CheckPermission(_permissionService, typeof(EventCommands), nameof(EventCommands.Create), ctx.Member)) { await ctx.RespondAsync("You are not permitted to use this command."); return; } var timezone = await _calendarService.GetCalendarTimezoneAsync(ctx.Guild.Id); if (string.IsNullOrEmpty(timezone)) { await ctx.RespondAsync("Calendar not initialised. Run `init <timezone>` to initialise the calendar."); return; } Event evt; try { evt = EventParser.ParseNewEvent(args, timezone); } catch (DateTimeInPastException) { await ctx.RespondAsync("Cannot create an event that starts or ends in the past, or has a reminder that is in the past."); return; } catch (EventEndBeforeStartException) { await ctx.RespondAsync("Cannot create an event that ends before it starts."); return; } catch (EventParseException) { await ctx.RespondAsync("Failed to parse event data."); return; } Event savedEvent; try { savedEvent = await _eventService.CreateEventAsync(ctx.Guild.Id, evt); } catch (CalendarNotFoundException) { await ctx.RespondAsync("Calendar not initialised. Run `init <timezone>` to initialise the calendar."); return; } var defaultChannelId = await _calendarService.GetCalendarDefaultChannelAsync(ctx.Guild.Id); await _eventScheduler.ScheduleEvent(savedEvent, ctx.Client, defaultChannelId, ctx.Guild.Id); var embed = EventEmbedFactory.GetCreateEventEmbed(savedEvent); await ctx.RespondAsync("New event created.", embed : embed); }