예제 #1
0
        public void HandleChannelDeletion(SocketGuildChannel channel)
        {
            var child = guilds.Values.SelectMany(x => x.Tickets.Values.SelectMany(v => v.ActiveChildChannels.Values)).FirstOrDefault(g => g.ChannelId == channel.Id);

            if (child != null)
            {
                TicketManager.ForceDeleteChild(DiscordClient, child);
            }
        }
예제 #2
0
        public static Ticket CreateNewTicket(DiscordSocketClient client, GuildEngine guild, string Name)
        {
            var    ticketId = PopId(guild);
            Ticket ticket   = new Ticket(ticketId, guild.Id, Name);

            TicketManager.GetOrCreateCategoryChannel(client, ticket);
            guild.Tickets.Add(ticketId, ticket);
            return(ticket);
        }
예제 #3
0
        public void HandleChildReaction(TicketChild child, SocketReaction reaction, Discord.Rest.RestUserMessage message)
        {
            var user = reaction.User.Value as SocketGuildUser;

            if (child.State == TicketState.Locked && reaction.UserId == child.UserId)
            {
                if (!user.GuildPermissions.Administrator && !user.Roles.Any(g => TicketManager.GetGuild(child.ParentGuildId).PermittedRoles.Contains(g.Id)))
                {
                    message.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                    return;
                }
            }

            if (message.Id == child.MainMessageId)
            {
                switch (child.State)
                {
                case TicketState.Open:
                    TicketManager.ChangeChildState(TicketState.Locked, DiscordClient, user, child);
                    break;

                case TicketState.Locked:
                    TicketManager.ChangeChildState(TicketState.Open, DiscordClient, user, child);
                    break;
                }
            }

            else
            {
                switch (reaction.Emote.Name)
                {
                case "⛔":
                    TicketManager.DeleteChild(DiscordClient, child);
                    break;

                case "📑":
                    TicketManager.DeleteChildWithTranscript(DiscordClient, child);
                    break;

                case "🔓":
                    TicketManager.ChangeChildState(TicketState.Open, DiscordClient, user, child);
                    break;
                }
            }
        }
예제 #4
0
        public void HandleSetupMessage(GuildEngine guildE, SetupMessage setupMessage, SocketReaction reaction, Discord.Rest.RestUserMessage message)
        {
            var user   = reaction.User.Value as SocketGuildUser;
            var ticket = GetTicket(guildE.Id, setupMessage.TicketId);

            if (ticket == null)
            {
                return;
            }

            message.RemoveReactionAsync(reaction.Emote, user);

            if (ticket.ActiveChildChannels.Values.Any(x => x.UserId == user.Id))
            {
                return;
            }

            TicketManager.CreateNewChild(DiscordClient, user, ticket);
        }
예제 #5
0
        public void HandleMessageDeletion(ulong MessageId, ulong GuildId)
        {
            var guild = GetGuild(GuildId);

            if (guild != null)
            {
                SetupMessage setupMessage;
                guild.SetupMessages.TryGetValue(MessageId, out setupMessage);

                if (setupMessage != null)
                {
                    Ticket ticket;
                    guild.Tickets.TryGetValue(setupMessage.TicketId, out ticket);

                    if (ticket != null)
                    {
                        TicketManager.DeleteTicket(DiscordClient, ticket);
                    }
                }
            }
        }
예제 #6
0
        public static void RemoveTicket(DiscordSocketClient client, GuildEngine guild, Ticket ticket, bool clear = false)
        {
            TicketManager.DeleteTicket(client, ticket);

            var setmessage = GetSetupMessageByTicket(guild, ticket.Id);

            if (setmessage != null)
            {
                guild.SetupMessages.Remove(setmessage.MessageId);
            }

            if (clear)
            {
                return;
            }

            if (!guild.Tickets.ContainsKey(ticket.Id))
            {
                return;
            }

            guild.Tickets.Remove(ticket.Id);
        }