private async Task CheckNewThread(SocketMessage arg)
        {
            if (arg.Author.IsBot)
            {
                return;
            }
            if (arg.Channel.GetType() == typeof(SocketDMChannel))
            {
                if (BlockedUsers.Any(x => x == arg.Author.Id))
                {
                    return;
                }
                if (CurrentTickets.Any(x => x.DMChannelID == arg.Channel.Id))
                {
                    var ticket = CurrentTickets.Find(x => x.DMChannelID == arg.Channel.Id);
                    ticket.DMTyping.Typing = false;
                    if (ticket.DMTyping.TypingObject != null)
                    {
                        ticket.DMTyping.TypingObject.Dispose();
                    }
                    string msg    = $"**[Ticketer] {arg.Author}** - {arg.Content}";
                    var    tkchan = client.GetGuild(Global.SwissGuildId).GetTextChannel(ticket.TicketChannel);
                    await tkchan.SendMessageAsync(msg);

                    if (arg.Attachments.Count > 0)
                    {
                        foreach (var attc in arg.Attachments)
                        {
                            var bt = new WebClient().DownloadData(new Uri(attc.ProxyUrl));
                            File.WriteAllBytes(Environment.CurrentDirectory + $"{Path.DirectorySeparatorChar}{attc.Filename}", bt);
                            await tkchan.SendFileAsync(Environment.CurrentDirectory + $"{Path.DirectorySeparatorChar}{attc.Filename}", $"**[Ticketer]**");
                        }
                    }
                }
                else if (!Setups.ContainsKey(arg.Author.Id))
                {
                    var msg = await arg.Channel.SendMessageAsync("Hello " + arg.Author.Mention + ", if you want to open a support ticket please click the checkmark, otherwise to delete this message click the X");

                    await msg.AddReactionsAsync(new IEmote[] { new Emoji("✅"), new Emoji("❌") });

                    Setups.Add(arg.Channel.Id, new KeyValuePair <ulong, string>(msg.Id, arg.Content));
                }
            }
            else if (CurrentTickets.Any(x => x.TicketChannel == arg.Channel.Id))
            {
                //check snippets
                await SnippetHandler(arg);
            }
        }
        private async Task CheckNewThread(SocketMessage arg)
        {
            if (arg.Author.IsBot)
            {
                return;
            }
            if (arg.Channel.GetType() == typeof(SocketDMChannel))
            {
                if (BlockedUsers.Any(x => x == arg.Author.Id))
                {
                    return;
                }
                if (CurrentTickets.Any(x => x.DMChannelID == arg.Channel.Id))
                {
                    var ticket = CurrentTickets.Find(x => x.DMChannelID == arg.Channel.Id);
                    ticket.DmTyping.Typing = false;
                    if (ticket.DmTyping.TypingObject != null)
                    {
                        ticket.DmTyping.TypingObject.Dispose();
                    }
                    string msg = $"**[Ticketer] {arg.Author}** - {arg.Content}";
                    if (arg.Attachments.Count > 0)
                    {
                        foreach (var attc in arg.Attachments)
                        {
                            msg += $"\n**Attachment** - {attc.Url}";
                        }
                    }
                    await client.GetGuild(Global.SwissGuildId).GetTextChannel(ticket.TicketChannel).SendMessageAsync(msg);
                }
                else if (!Setups.ContainsKey(arg.Author.Id))
                {
                    var msg = await arg.Channel.SendMessageAsync("Hello " + arg.Author.Mention + ", if you want to open a support ticket please click the checkmark, otherwise to delete this message click the X");

                    await msg.AddReactionsAsync(new IEmote[] { new Emoji("✅"), new Emoji("❌") });

                    Setups.Add(arg.Channel.Id, new KeyValuePair <ulong, string>(msg.Id, arg.Content));
                }
            }
            else if (CurrentTickets.Any(x => x.TicketChannel == arg.Channel.Id))
            {
                //check snippets
                await SnippetHandler(arg);
            }
        }
Exemple #3
0
        private async Task CheckInitThread(Cacheable<IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
        {
            var usr = await arg2.GetUserAsync(arg3.UserId);
            if (usr.IsBot)
                return;

            if (Setups.ContainsKey(arg2.Id))
            {
                var msg = await arg2.GetMessageAsync(Setups[arg2.Id].Key);

                //checkmark
                if (arg3.Emote.Equals(new Emoji("✅")))
                {
                    if (client.GetGuild(Global.SwissGuildId).Users.Any(x => x.Id == usr.Id))
                    {
                        if (BlockedUsers.Any(x => x == usr.Id))
                        {
                            await arg2.SendMessageAsync("", false, new EmbedBuilder()
                            {
                                Title = "You are blocked!",
                                Description = "Looks like your blocked from creating support tickets :/",
                                Color = Color.Red
                            }.Build());
                            Setups.Remove(arg2.Id);
                            await msg.DeleteAsync();
                            return;
                        }
                        else
                        {
                            await msg.DeleteAsync();
                            var tmpmsg = await arg2.SendMessageAsync("**Creating support ticket with the staff team...**");
                            await CreateNewTicket(arg2, usr, Setups[arg2.Id].Value);
                            await tmpmsg.ModifyAsync(x => x.Embed = new EmbedBuilder()
                            {
                                Title = "Congrats! You are now talking with staff!",
                                Description = "Please note staff **Can** take moderation action for anything you say in a ticket. The same rules apply as the server.\n_This ticket may also be archived and used for training purposes._",
                                Color = Color.Green
                            }.Build());
                        }
                    }
                    else
                    {
                        await usr.SendMessageAsync("", false, new EmbedBuilder()
                        {
                            Title = "Sorry... :(",
                            Description = "The staff team does not accept tickets from users who are not in the server.",
                            Color = Color.Red
                        }.Build());
                    }

                }
                else if (arg3.Emote.Equals(new Emoji("❌"))) // xmark
                {
                    Setups.Remove(arg2.Id);
                    await msg.DeleteAsync();
                }
            }
            else if (closingState.Keys.Any(x => x.Key == arg2.Id))
            {
                var o = closingState.First(x => x.Key.Key == arg2.Id);
                var msg = await arg2.GetMessageAsync(o.Key.Value);

                if (arg3.Emote.Equals(new Emoji("❌")))
                {
                    o.Value.Stop();
                    o.Value.Dispose();
                    closingState.Remove(o.Key);
                    await msg.DeleteAsync();
                }
            }
            else if (WelcomeMessages.Contains(arg3.MessageId))
            {
                if (arg3.Emote.Equals(new Emoji("❌")))
                {
                    var msg = await arg2.GetMessageAsync(arg3.MessageId);
                    await msg.DeleteAsync();
                }
                if (arg3.Emote.Equals(new Emoji("✅")))
                {
                    var ticket = CurrentTickets.Find(x => x.TicketChannel == arg2.Id);
                    var msg = await arg2.GetMessageAsync(arg3.MessageId);
                    var dmchan = await client.GetUser(ticket.UserID).GetOrCreateDMChannelAsync();
                    var gusr = usr as SocketGuildUser;
                    await msg.DeleteAsync();
                    string tmsg = $"**[Staff] {(gusr.Nickname == null ? usr.ToString() : gusr.Nickname)}** - Hello! Swiss001 Support! How May I help you?";
                    await arg2.SendMessageAsync(tmsg);
                    await dmchan.SendMessageAsync(tmsg);
                }
            }
        }