Пример #1
0
        /// <summary>
        /// Manually removes an event, automatically denying it and preventing it from running. It also deleted the associated proposal.
        /// </summary>
        /// <param name="EventID">The unique ID of the target Event.</param>
        /// <returns>A <c>Task</c> object, which can be awaited until the method completes successfully.</returns>

        public async Task RemoveEvent(int EventID)
        {
            CommunityEvent Event = GetEvent(EventID);

            if (Event.Status == EventStatus.Released)
            {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle("Event already released!")
                .WithDescription("You can't remove an event that has already been released!")
                .WithCurrentTimestamp()
                .SendEmbed(Context.Channel);
            }

            if (TimerService.TimerExists(Event.ReleaseTimer))
            {
                TimerService.RemoveTimer(Event.ReleaseTimer);
            }

            Event.Status = EventStatus.Removed;
            await UpdateEventProposal(Event.ID);

            CommunityEventsDB.SaveChanges();

            await BuildEmbed(EmojiEnum.Love)
            .WithTitle("Event was successfully removed!")
            .WithDescription($"The event \"{Event.Description}\" has been removed from the proposal system.")
            .WithCurrentTimestamp()
            .SendEmbed(Context.Channel);
        }
Пример #2
0
        /// <summary>
        /// A callback method to be called when an event suggestion is declined. It sets the status to denied and handles timer cleanup.
        /// </summary>
        /// <param name="EventID">The unique numerical ID for the target event.</param>
        /// <param name="Reason">The optional reason why the event was declined.</param>
        /// <returns>A <c>Task</c> object, which can be awaited until this method completes successfully.</returns>

        public async Task DeclineEventCallback(int EventID, string Reason = "")
        {
            CommunityEvent Event    = GetEvent(EventID);
            IUser          Proposer = DiscordSocketClient.GetUser(Event.ProposerID);

            if (Event == null)
            {
                return;
            }

            Event.ResolveReason = Reason;
            await UpdateEventProposal(Event.ID);

            if (TimerService.TimerExists(Event.ReleaseTimer))
            {
                TimerService.RemoveTimer(Event.ReleaseTimer);
            }

            await BuildEmbed(EmojiEnum.Annoyed)
            .WithTitle("Event has been declined!")
            .WithDescription($"Event #{Event.ID} has been declined.")
            .WithCurrentTimestamp()
            .SendDMAttachedEmbed(Context.Channel, BotConfiguration, Proposer,
                                 BuildEmbed(EmojiEnum.Love)
                                 .WithTitle("Your Event has been Declined!")
                                 .WithDescription(Event.Description)
                                 .AddField(Reason.Length > 0, "Reason: ", Reason));

            Event.Status = EventStatus.Denied;

            CommunityEventsDB.SaveChanges();
        }