예제 #1
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();
        }
예제 #2
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);
        }
예제 #3
0
        public async Task IssueFinalWarn(IGuildUser User, TimeSpan MuteDuration, [Remainder] string Reason)
        {
            short PointsDeducted = ModerationConfiguration.FinalWarningPointsDeducted;

            if (FinalWarnsDB.IsUserFinalWarned(User))
            {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle("User is already final warned!")
                .WithDescription($"The target user, {User.GetUserInformation()}, already has an active final warn. If you wish to overwrite this final warn, first remove the already existing one.")
                .SendEmbed(Context.Channel);

                return;
            }

            DexterProfile DexterProfile = InfractionsDB.GetOrCreateProfile(User.Id);

            DexterProfile.InfractionAmount -= PointsDeducted;

            if (!TimerService.TimerExists(DexterProfile.CurrentPointTimer))
            {
                DexterProfile.CurrentPointTimer = await CreateEventTimer(IncrementPoints, new() { { "UserID", User.Id.ToString() } }, ModerationConfiguration.SecondsTillPointIncrement, TimerType.Expire);
            }


            ulong WarningLogID = 0;

            if (ModerationConfiguration.FinalWarningsManageRecords)
            {
                WarningLogID = (await(DiscordSocketClient.GetChannel(ModerationConfiguration.FinalWarningsChannelID) as ITextChannel).SendMessageAsync(
                                    $"**Final Warning Issued >>>** <@&{BotConfiguration.ModeratorRoleID}>\n" +
                                    $"**User**: {User.GetUserInformation()}\n" +
                                    $"**Issued on**: {DateTime.Now:MM/dd/yyyy}\n" +
                                    $"**Reason**: {Reason}")).Id;
            }

            FinalWarnsDB.SetOrCreateFinalWarn(PointsDeducted, Context.User as IGuildUser, User, MuteDuration, Reason, WarningLogID);

            await MuteUser(User, MuteDuration);

            try {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle($"🚨 You were issued a **FINAL WARNING** from {Context.Guild.Name}! 🚨")
                .WithDescription(Reason)
                .AddField("Points Deducted:", PointsDeducted, true)
                .AddField("Mute Duration:", MuteDuration.Humanize(), true)
                .WithCurrentTimestamp()
                .SendEmbed(await User.GetOrCreateDMChannelAsync());

                await BuildEmbed(EmojiEnum.Love)
                .WithTitle("Message sent successfully!")
                .WithDescription($"The target user, {User.GetUserInformation()}, has been informed of their current status.")
                .AddField("Mute Duration:", MuteDuration.Humanize(), true)
                .AddField("Points Deducted:", PointsDeducted, true)
                .AddField("Issued By:", Context.User.GetUserInformation())
                .AddField("Reason:", Reason)
                .WithCurrentTimestamp()
                .SendEmbed(Context.Channel);
            }
            catch (HttpException) {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle("Message failed!")
                .WithDescription($"The target user, {User.GetUserInformation()}, might have DMs disabled or might have blocked me... :c\nThe final warning has been recorded to the database regardless.")
                .SendEmbed(Context.Channel);
            }

            InfractionsDB.SaveChanges();
        }
예제 #4
0
        /// <summary>
        /// A callback method to be called when an event suggestion is approved. It sets the status to approved and handles expired events.
        /// </summary>
        /// <param name="EventID">The unique numerical ID for the target event.</param>
        /// <param name="Reason">The optional reason for approval of the event.</param>
        /// <returns>A <c>Task</c> object, which can be awaited until this method completes successfully.</returns>

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

            if (Event == null)
            {
                return;
            }

            if (Event.Status == EventStatus.Expired)
            {
                if (CommunityConfiguration.FailOnOverdueApproval)
                {
                    await BuildEmbed(EmojiEnum.Annoyed)
                    .WithTitle("This Event has already expired!")
                    .WithDescription("Expired events can't be approved (FailOnOverdueApproval configuration is activated)")
                    .WithCurrentTimestamp()
                    .SendEmbed(Context.Channel);

                    return;
                }
                else
                {
                    await BuildEmbed(EmojiEnum.Sign)
                    .WithTitle("This Event is overdue!")
                    .WithDescription("The event will be released immediately (FailOnOverDueApproval configuration is off)")
                    .WithCurrentTimestamp()
                    .SendEmbed(Context.Channel);

                    Event.Status = EventStatus.Approved;
                    await ReleaseEvent(EventID);

                    return;
                }
            }

            DateTimeOffset Release = DateTimeOffset.FromUnixTimeSeconds(Event.DateTimeRelease).ToOffset(TimeSpan.FromHours(BotConfiguration.StandardTimeZone));

            if (!TimerService.TimerExists(Event.ReleaseTimer))
            {
                Event.ReleaseTimer = await CreateEventTimer(ReleaseEventCallback,
                                                            new Dictionary <string, string> {
                    { "ID", Event.ID.ToString() }
                },
                                                            (int)Release.Subtract(DateTimeOffset.Now).TotalSeconds,
                                                            TimerType.Expire);
            }

            Event.ResolveReason = Reason;
            Event.Status        = EventStatus.Approved;
            await UpdateEventProposal(Event.ID);

            await BuildEmbed(EmojiEnum.Love)
            .WithTitle("Event approved for release!")
            .WithDescription($"Event #{Event.ID} will be released at {Release:ddd', 'MMM d 'at' hh:mm tt 'UTC'z} ({Release.Humanize()}).")
            .WithCurrentTimestamp()
            .SendDMAttachedEmbed(Context.Channel, BotConfiguration, Proposer,
                                 BuildEmbed(EmojiEnum.Love)
                                 .WithTitle("Your Event has been Approved!")
                                 .WithDescription(Event.Description)
                                 .AddField(Reason.Length > 0, "Reason: ", Reason)
                                 .AddField("Release Time:", $"{Release:ddd', 'MMM d 'at' hh:mm tt 'UTC'z}"));

            CommunityEventsDB.SaveChanges();
        }