Example #1
0
        public static void SendPlanInformation(this IDiscordRestApi discordRestApi, ulong discordId, ulong duserId, string priorityState, TimeSpan Remining)
        {
            try
            {
                RestGuildUser usr        = null;
                RestGuild     gld        = null;
                string        namefor    = "";
                string        priorityId = "";
                string        title      = "? Updated";
                if (priorityState == "User")
                {
                    usr        = discordRestApi.GetGuildUserAsync(discordId, duserId).Result;
                    namefor    = $"{usr?.Username}#{usr?.Discriminator}";
                    priorityId = $"{priorityState}-{usr.Id}";
                    title      = $"INDIVIDUAL PLAN IS UPDATED";
                }
                else if (priorityState == "Guild")
                {
                    gld        = discordRestApi.GetApi.GetGuildAsync(discordId).Result;
                    usr        = gld?.GetOwnerAsync().Result;
                    namefor    = $"{gld?.Name}";
                    priorityId = $"{priorityState}-{gld.Id}";
                    title      = $"PRO PLAN IS UPDATED";
                }

                DateTime dtx = new DateTime();
                dtx = dtx.Add(Remining);
                EmbedBuilder embed = new EmbedBuilder()
                {
                    Author = new EmbedAuthorBuilder()
                    {
                        IconUrl = discordRestApi.GetApi.CurrentUser.GetAvatarUrl(),
                        Name    = discordRestApi.GetApi.CurrentUser.Username
                    },
                    Color = Color.Green,
                    Title = title
                };
                embed.Description += $"Type: **{priorityState}**\n" +
                                     $"Name: {namefor}\n" +
                                     $"Expires In: **{dtx.Year - 1}**Years **{dtx.Month - 1}**Months **{dtx.Day - 1}**days **{dtx.Hour}**hours\n";

                embed.Description += "\n\n";
                try
                {
                    RestDMChannel   dm     = usr.GetOrCreateDMChannelAsync().Result;
                    Embed           bembed = embed.Build();
                    RestUserMessage msg    = dm.SendMessageAsync(string.Empty, false, bembed).Result;
                    dm.CloseAsync().Wait();
                }
                catch (Exception e)
                {
                }
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Example #2
0
        public static async Task UserLeft(SocketGuildUser arg)
        {
            await ConsoleHelper.Log($"{arg.Username} left the \"{arg.Guild.Name}\" server!", Discord.LogSeverity.Info);

            SocketTextChannel channel = (new List <SocketTextChannel>(arg.Guild.TextChannels)).FirstOrDefault(c => c.Name == Information.TextChannel);

            if (channel != null)
            {
                await channel.SendMessageAsync($"{Helper.GetName(arg)} left the server!", true);
            }

            RestDMChannel dm = await arg.CreateDMChannelAsync();

            await dm.SendMessageAsync("Why did you leave man?", true);
        }
Example #3
0
 public ComboBoxItem(string text, RestDMChannel value)
 {
     Text  = text;
     Value = value;
 }
        private async Task CheckInitThread(Cacheable <IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3)
        {
            var usr = await arg2.GetUserAsync(arg3.UserId);

            if (usr.IsBot)
            {
                return;
            }

            if (arg2.GetType() != typeof(SocketDMChannel))
            {
                if (closingState.Keys.Any(x => x.Key == arg2.Id))
                {
                    var o = closingState.First(x => x.Key.Key == arg2.Id);
                    var m = await arg2.GetMessageAsync(o.Key.Value);

                    if (arg3.Emote.Equals(new Emoji("❌")))
                    {
                        o.Value.Stop();
                        o.Value.Dispose();
                        closingState.Remove(o.Key);
                        await m.DeleteAsync();
                    }
                }
                else if (WelcomeMessages.Contains(arg3.MessageId))
                {
                    if (arg3.Emote.Equals(new Emoji("❌")))
                    {
                        var m = await arg2.GetMessageAsync(arg3.MessageId);

                        await m.DeleteAsync();
                    }
                    if (arg3.Emote.Equals(new Emoji("✅")))
                    {
                        var ticket = CurrentTickets.Find(x => x.TicketChannel == arg2.Id);
                        var m      = await arg2.GetMessageAsync(arg3.MessageId);

                        var dmchan = await client.GetUser(ticket.UserID).GetOrCreateDMChannelAsync();

                        var gusr = usr as SocketGuildUser;
                        await m.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);
                    }
                }
                return;
            }

            var msg = await client.Rest.GetDMChannelAsync(arg2.Id).Result.GetMessageAsync(arg1.Id);

            if (isValidSetup(msg))
            {
                //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());

                            await msg.DeleteAsync();

                            return;
                        }
                        else
                        {
                            await msg.DeleteAsync();

                            var tmpmsg = await arg2.SendMessageAsync("**Creating support ticket with the staff team...**");

                            RestDMChannel rChan = (RestDMChannel)await client.Rest.GetDMChannelAsync(arg2.Id);

                            var msgs = await rChan.GetMessagesAsync(arg1.Id, Direction.Before, 1).FlattenAsync();
                            await CreateNewTicket(arg2, usr, msgs.First().Content);

                            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
                {
                    await msg.DeleteAsync();
                }
            }
        }