Esempio n. 1
0
        public async Task Emote([Remainder, Summary("")] string emote)
        {
            if (string.IsNullOrEmpty(emote))
            {
                throw new ArgumentException("is null or empty", nameof(emote));
            }

            bool e = GuildEmote.TryParse(emote, out Emote emo);

            if (!e || emo is null)
            {
                return;
            }

            await ReplyImage(emote.Replace(":", "", System.StringComparison.Ordinal), emo.Url);
        }
            public async Task CreateRoleCard(params string[] args)
            {
                //await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                //{
                //    Title = "Sorry bud",
                //    Description = $"This has been disabled bucko",
                //    Color = Color.Red
                //}.Build());
                //return;
                if (!HasExecutePermission)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "Waaiitt a minute.. who are you?",
                        Description = $"Looks like you dont have permission to execute this command. if this is wrong yell at quin>",
                        Color       = Color.Red
                    }.Build());

                    return;
                }

                if (args.Length == 0)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "What? where?",
                        Description = $"Looks like you didnt provide a channel :/ do so please!",
                        Color       = Color.Red
                    }.Build());

                    return;
                }
                if (args.Length == 1)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "What should i add?!",
                        Description = $"Uhhhhh. epic swissbot here, you need to tell me the roles you want to add plus there emoji/description ok bye <3",
                        Color       = Color.Red
                    }.Build());

                    return;
                }
                var channel     = Context.Message.MentionedChannels.First();
                var redargs     = args.Skip(1).ToArray();
                var tmpRolecard = new RoleCard();

                tmpRolecard.ChannelID    = channel.Id;
                tmpRolecard.RoleEmojiIDs = new List <RoleCard.RoleEmoteDesc>();
                if (redargs.Any(x => x.Contains(",")))//multiple
                {
                    int c   = 0;
                    var msg = Context.Channel.SendMessageAsync("this message is here to test the emotes... (dont delete)").Result;

                    foreach (var item in string.Join(' ', redargs).Split(", "))
                    {
                        if (Context.Message.MentionedRoles.Count <= c)
                        {
                            await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                            {
                                Title       = "What is that?",
                                Description = "The Role you provided is invalid :/",
                                Color       = Color.Red
                            }.Build());

                            return;
                        }
                        IRole role = Context.Message.MentionedRoles.ToArray()[c];
                        c++;
                        string emote       = item.Split(' ')[1];
                        string description = string.Join(' ', item.Split(' ').Skip(2));

                        if (GuildEmote.TryParse(emote, out var outemote))
                        {
                            tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc()
                            {
                                Description = description, Emote = emote, RoleID = role.Id
                            });
                            try
                            {
                                await msg.AddReactionAsync(outemote);
                            }
                            catch (Exception ex)
                            {
                                await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                                {
                                    Title       = "What is that?",
                                    Description = "The emote you provided is invalid or is broken :/",
                                    Color       = Color.Red
                                }.Build());

                                await msg.DeleteAsync();

                                return;
                            }
                            //Global.SaveRoleCard();
                            //await UpdateRoleCard();
                        }
                        else
                        {
                            var m = new Emoji(emote);
                            try
                            {
                                await msg.AddReactionAsync(m);

                                tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc()
                                {
                                    Description = description, Emote = m.Name, RoleID = role.Id
                                });
                                //Global.SaveRoleCard();
                                //await UpdateRoleCard();
                            }
                            catch (Exception ex)
                            {
                                await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                                {
                                    Title       = "What is that?",
                                    Description = "The emote you provided is invalid or is broken :/",
                                    Color       = Color.Red
                                }.Build());

                                await msg.DeleteAsync();

                                return;
                            }
                        }
                    }

                    await msg.ModifyAsync(x => x.Content = "Ok good you used valid emotes <3 card will be created very shortly. ps il delete this in 5 seconds lol");

                    new Timer()
                    {
                        AutoReset = false, Interval = 5000, Enabled = true
                    }.Elapsed += (object s, ElapsedEventArgs a) =>
                    {
                        msg.DeleteAsync().Wait();
                    };
                    await DeployCard(tmpRolecard);
                }
                else//single
                {
                    IRole  role        = Context.Message.MentionedRoles.First();
                    string emote       = redargs[1];
                    string description = string.Join(' ', redargs.Skip(2));

                    if (Emote.TryParse(emote, out var outemote))
                    {
                        tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc()
                        {
                            Description = description, Emote = emote, RoleID = role.Id
                        });
                        //Global.SaveRoleCard();
                        //await UpdateRoleCard();
                    }
                    else
                    {
                        var m = new Emoji(emote);
                        try
                        {
                            var msg = Context.Channel.SendMessageAsync("Testing the emote...").Result;
                            await msg.AddReactionAsync(m);

                            await msg.ModifyAsync(x => x.Content = "Ok good you used a valid emote <3. ps il delete this in 5 seconds lol");

                            new Timer()
                            {
                                AutoReset = false, Interval = 5000, Enabled = true
                            }.Elapsed += (object s, ElapsedEventArgs a) =>
                            {
                                msg.DeleteAsync().Wait();
                            };
                            tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc()
                            {
                                Description = description, Emote = m.Name, RoleID = role.Id
                            });
                            //Global.SaveRoleCard();
                            //await UpdateRoleCard();
                        }
                        catch (Exception ex)
                        {
                            await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                            {
                                Title       = "What is that?",
                                Description = "The emote you provided is invalid or is broken :/",
                                Color       = Color.Red
                            }.Build());

                            return;
                        }
                    }

                    await DeployCard(tmpRolecard);
                }
            }