Ejemplo n.º 1
0
        private static async Task ChannelCreate(BaseDiscordClient client, Embed embed, ChannelCreateEventArgs channelCreateEventArgs)
        {
            embed.Title = $"{DiscordEmoji.FromGuildEmote(client, EmojiLibrary.New)} {channelCreateEventArgs.Channel.Type.ToString()} channel created";
            var description = new StringBuilder()
                              .AppendLine($"{Formatter.InlineCode(channelCreateEventArgs.Channel.Name)} {channelCreateEventArgs.Channel.Mention}");

            if (string.IsNullOrWhiteSpace(channelCreateEventArgs.Channel.Topic))
            {
                description.AppendLine($"Topic: {channelCreateEventArgs.Channel.Topic}");
            }

            description.AppendLine($"Identity: {Formatter.InlineCode(channelCreateEventArgs.Channel.Id.ToString())}")
            .AppendLine($"Parent: {Formatter.InlineCode(channelCreateEventArgs.Channel.Parent.Name)}")
            .AppendLine($"NSFW: {Formatter.InlineCode(channelCreateEventArgs.Channel.IsNSFW.ToString())}");

            if (channelCreateEventArgs.Channel.Type == ChannelType.Voice)
            {
                description.AppendLine($"Bitrate: {Formatter.InlineCode(channelCreateEventArgs.Channel.Bitrate.ToString())}")
                .AppendLine($"User Limit: {Formatter.InlineCode(channelCreateEventArgs.Channel.UserLimitToString())}");
            }

            if (channelCreateEventArgs.Channel.Type == ChannelType.Text)
            {
                description.AppendLine($"Slowmode: {Formatter.InlineCode(channelCreateEventArgs.Channel.PerUserRateLimitToString())}");
            }

            embed.Description = description.ToString();
            embed.Color       = DiscordColor.SpringGreen;
        }
Ejemplo n.º 2
0
        public async Task ClosedPollThreeOption(CommandContext ctx, [RemainingText] string message)
        {
            string[] embedTitle   = message.Split('|');
            string   embedMessage = string.Empty;

            embedMessage += $"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.Polls.Yes)} **Yes**\n";
            embedMessage += $"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.Polls.No)} **No**\n";
            embedMessage += $"{DiscordEmoji.FromName(ctx.Client, ":regional_indicator_m:")} **Maybe**\n";

            DiscordEmbed pollEmbed = new DiscordEmbedBuilder
            {
                Footer = new DiscordEmbedBuilder.EmbedFooter
                {
                    IconUrl = DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.Polls.InfoIcon).Url,
                    Text    = "Vote using reactions",
                },
                Color       = new DiscordColor(250, 250, 250),
                Timestamp   = DateTime.UtcNow,
                Title       = $"**{embedTitle[0]}**",
                Description = embedMessage,
            };
            DiscordMessage reactionMessage = await ctx.Channel.SendMessageAsync(embed : pollEmbed);

            await reactionMessage.CreateReactionAsync(DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.Polls.Yes));

            await reactionMessage.CreateReactionAsync(DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.Polls.No));

            await reactionMessage.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":regional_indicator_m:"));
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Editing the embedded message
    /// </summary>
    /// <param name="builder">Builder</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public override Task EditMessage(DiscordEmbedBuilder builder)
    {
        builder.WithTitle(LocalizationGroup.GetText("ChooseCommandTitle", "Raid experience levels configuration"));
        builder.WithDescription(LocalizationGroup.GetText("ChooseCommandDescription", "With this assistant you are able to configure the raid experience levels. The following experience levels are already created:"));

        var levelsBuilder = new StringBuilder();

        var levels = GetLevels();

        if (levels.Count > 0)
        {
            var currentLevel = levels.FirstOrDefault(obj => obj.SuperiorExperienceLevelId == null);
            while (currentLevel != null)
            {
                levelsBuilder.AppendLine(Formatter.Bold($"{DiscordEmoji.FromGuildEmote(CommandContext.Client, currentLevel.DiscordEmoji)} {currentLevel.Description}"));

                currentLevel = levels.FirstOrDefault(obj => obj.SuperiorExperienceLevelId == currentLevel.Id);
            }
        }
        else
        {
            levelsBuilder.Append('\u200B');
        }

        builder.AddField(LocalizationGroup.GetText("LevelsFields", "Levels"), levelsBuilder.ToString());

        return(Task.CompletedTask);
    }
Ejemplo n.º 4
0
        private static DiscordEmoji GetPresenceEmoji(DiscordClient client, DiscordUser member, out string status)
        {
            status = string.Empty;
            switch (member.Presence?.Status)
            {
            case UserStatus.Online:
                status = "Online";
                return(DiscordEmoji.FromGuildEmote(client, 743339430672203796));

            case UserStatus.Idle:
                status = "Away";
                return(DiscordEmoji.FromGuildEmote(client, 743339431720910889));

            case UserStatus.DoNotDisturb:
                status = "Do Not Disturb";
                return(DiscordEmoji.FromGuildEmote(client, 743339431632568450));

            case UserStatus.Offline:
                status = "Offline";
                return(DiscordEmoji.FromGuildEmote(client, 743339431905198100));

            default:
                status = "Offline";
                return(DiscordEmoji.FromGuildEmote(client, 743339431905198100));
            }
        }
Ejemplo n.º 5
0
        public async Task PackagAccountsProfile(CommandContext ctx)
        {
            if (this.CheckBasics(ctx) == true)
            {
                PackageAccount      account      = this.accountService.FindAccount(ctx.User.Id);
                DiscordEmbedBuilder accountEmbed = new DiscordEmbedBuilder
                {
                    Footer = new DiscordEmbedBuilder.EmbedFooter
                    {
                        IconUrl = DiscordEmoji.FromGuildEmote(ctx.Client, CommandEmojis.Run).Url,
                        Text    = $"Package Account Profile | Account Created: {account.AccountCreated}",
                    },
                    Color     = new DiscordColor(52, 114, 53),
                    Timestamp = DateTime.UtcNow,
                    Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail
                    {
                        Url = ctx.User.AvatarUrl,
                    },
                };

                accountEmbed.AddField($"**Discord ID**", $"`{account.DiscordID}`", false);
                accountEmbed.AddField($"**Steam ID**", $"`{account.SteamID}`", false);
                accountEmbed.AddField($"**Private Profile**", $"`{account.PrivateProfile}`", false);
                accountEmbed.AddField($"**Account Permission**", $"`{account.Type}`", false);
            }
            else
            {
                await ctx.Channel.SendMessageAsync($"This command can only be run within a DM channel or you do not have an account setup.");

                return;
            }
        }
Ejemplo n.º 6
0
        private static async Task InviteCreate(BaseDiscordClient client, Embed embed, InviteCreateEventArgs inviteCreateEventArgs)
        {
            embed.Title = $"{DiscordEmoji.FromGuildEmote(client, EmojiLibrary.New)} Invite created";
            var maxAge  = inviteCreateEventArgs.Invite.MaxAge == 0 ? "No limit" : $"{TimeSpan.FromSeconds(inviteCreateEventArgs.Invite.MaxAge).TotalHours}h";
            var maxUses = inviteCreateEventArgs.Invite.MaxUses == 0 ? "Unlimited" : inviteCreateEventArgs.Invite.MaxUses.ToString();

            embed.Description = new StringBuilder().AppendLine($"Code: {Formatter.InlineCode(inviteCreateEventArgs.Invite.Code)}")
                                .AppendLine($"{Formatter.InlineCode(inviteCreateEventArgs.Channel.Name)} {inviteCreateEventArgs.Channel.Mention}")
                                .AppendLine($"Identity: {Formatter.InlineCode(inviteCreateEventArgs.Channel.Id.ToString())}")
                                .AppendLine($"Temporary: {Formatter.InlineCode(inviteCreateEventArgs.Invite.IsTemporary.ToString())}")
                                .AppendLine($"Max age: {Formatter.InlineCode(maxAge)}")
                                .AppendLine($"Max uses: {Formatter.InlineCode(maxUses)}")
                                .ToString();

            var inviter            = inviteCreateEventArgs.Invite.Inviter;
            var inviterDescription = new StringBuilder().AppendLine($"Username: {Formatter.InlineCode(inviter.GetUsertag())} {inviter.Mention}")
                                     .AppendLine($"Identity: {Formatter.InlineCode(inviter.Id.ToString())}")
                                     .ToString();

            embed.Fields = new List <EmbedField> {
                new EmbedField {
                    Inline = false, Name = "Inviter", Value = inviterDescription
                }
            };
            embed.Color = DiscordColor.SpringGreen;
        }
Ejemplo n.º 7
0
        public async Task PackagAccountsGeneral(CommandContext ctx)
        {
            if (this.CheckBasics(ctx) == true)
            {
                DiscordEmbedBuilder accountEmbed = new DiscordEmbedBuilder
                {
                    Footer = new DiscordEmbedBuilder.EmbedFooter
                    {
                        IconUrl = DiscordEmoji.FromGuildEmote(ctx.Client, ManageRoleEmojis.Warning).Url,
                        Text    = "Package Account Help Embed",
                    },
                    Color     = new DiscordColor(52, 114, 53),
                    Timestamp = DateTime.UtcNow,
                    Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail
                    {
                        Url = ctx.User.AvatarUrl,
                    },
                    Title = "Package Account Help",
                };
                accountEmbed.AddField($"**Creating an Account**", $"To create an account, simply run `.package -c`. You can also use `.package -create`. This is the first step to creating an account on Bloon", true);
                accountEmbed.AddField($"**Seeing my Profile**", $"You can see you profile on the website or via Discord in a DM using `.package -p` - This feature is not complete yet.", false);
                accountEmbed.AddField($"**Edit my Profile**", $"You can edit your profile *or delete* via the website or by using `.package -pe`. - This feature is not complete yet.", false);
                accountEmbed.AddField($"**FAQ**", $"To see FAQ use `.package -faq`. Your question might be answered there. If not, try one of the bot admins.", false);

                await ctx.Channel.SendMessageAsync(string.Empty, embed : accountEmbed.Build());
            }
            else
            {
                await ctx.Channel.SendMessageAsync($"This command may only be ran within a DM.");
            }
        }
Ejemplo n.º 8
0
        public async void Information(LogConsole consoleChannel, ulong emoji, string message)
        {
            DiscordChannel channel;

            switch (consoleChannel)
            {
            case LogConsole.Commands:
                channel = await this.dClient.GetChannelAsync(Channels.Commands).ConfigureAwait(false);

                break;

            case LogConsole.RoleEdits:
                channel = await this.dClient.GetChannelAsync(Channels.RoleEdits).ConfigureAwait(false);

                break;

            case LogConsole.UserInfo:
                channel = await this.dClient.GetChannelAsync(Channels.Console).ConfigureAwait(false);

                break;

            default:
                channel = await this.dClient.GetChannelAsync(Channels.ExceptionReporting).ConfigureAwait(false);

                break;
            }

            await channel.SendMessageAsync($"**[{DateTime.UtcNow}]** {DiscordEmoji.FromGuildEmote(this.dClient, emoji)} {message}").ConfigureAwait(false);
        }
Ejemplo n.º 9
0
    /// <summary>
    /// Editing the embedded message
    /// </summary>
    /// <param name="builder">Builder</param>
    /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
    public override async Task EditMessage(DiscordEmbedBuilder builder)
    {
        builder.WithTitle(LocalizationGroup.GetText("ChooseCommandTitle", "Raid experience level configuration"));
        builder.WithDescription(LocalizationGroup.GetText("ChooseCommandDescription", "With this assistant you are able to configure the raid experience level."));

        using (var dbFactory = RepositoryFactory.CreateInstance())
        {
            var templateId = DialogContext.GetValue <long>("ExperienceLevelId");

            var data = await dbFactory.GetRepository <RaidExperienceLevelRepository>()
                       .GetQuery()
                       .Where(obj => obj.Id == templateId)
                       .Select(obj => new
            {
                obj.Description,
                obj.AliasName,
                obj.DiscordEmoji,
                obj.DiscordRoleId
            })
                       .FirstAsync()
                       .ConfigureAwait(false);

            builder.AddField(LocalizationGroup.GetText("Description", "Description"), data.Description);
            builder.AddField(LocalizationGroup.GetText("AliasName", "Alias name"), data.AliasName);
            builder.AddField(LocalizationGroup.GetText("Emoji", "Emoji"), DiscordEmoji.FromGuildEmote(CommandContext.Client, data.DiscordEmoji));

            if (data.DiscordRoleId != null)
            {
                builder.AddField(LocalizationGroup.GetText("Role", "Role"), CommandContext.Guild.Roles[data.DiscordRoleId.Value].Mention);
            }
        }
    }
Ejemplo n.º 10
0
        public async Task Feedback(CommandContext ctx, [RemainingText] string text)
        {
            if (String.IsNullOrWhiteSpace(value: text))
            {
                await ctx.RespondAsync(content : $"I can't submit an empty feedback {DiscordEmoji.FromGuildEmote(client: ctx.Client, id: 609551531620171784)}");

                await ctx.Message.DeleteAsync();

                return;
            }
            var guild = await ctx.Client.GetGuildAsync(id : 483279257431441410);

            var emb = new DiscordEmbedBuilder();

            emb.WithAuthor(name: $"{ctx.Member.Username}#{ctx.Member.Discriminator}", iconUrl: ctx.Member.AvatarUrl).
            WithTitle(title: "Feedback").
            WithDescription(description: text).
            WithFooter(text: $"Sent from {ctx.Guild.Name}");
            emb.AddField(name: "User", value: $"{ctx.Member.Mention}", inline: true);
            emb.AddField(name: "ID", value: $"{ctx.Guild.Id}", inline: true);
            var embed = await guild.GetChannel(484698873411928075).SendMessageAsync(embed: emb.Build());

            await embed.CreateReactionAsync(DiscordEmoji.FromName(client: ctx.Client, name: ":thumbsup:"));

            await embed.CreateReactionAsync(DiscordEmoji.FromName(client: ctx.Client, name: ":thumbsdown:"));

            await ctx.RespondAsync($"Feedback sent {DiscordEmoji.FromGuildEmote(client: ctx.Client, id: 623933340520546306)}");

            await ctx.Message.DeleteAsync("Cleanup");
        }
Ejemplo n.º 11
0
        private string BuildUserEventsAsync(ulong discordId, ContextMenuContext ctx)
        {
            List <UserEvent> userEvents = this.userEventService.QueryEventReportAsync(discordId);

            StringBuilder discordUserEvents = new StringBuilder();

            foreach (UserEvent events in userEvents)
            {
                if (events.Event == Event.Joined)
                {
                    discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Join)} Joined - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n");
                }

                if (events.Event == Event.Left)
                {
                    discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Leave)} Left - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n");
                }

                if (events.Event == Event.Banned)
                {
                    discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Banned)} Banned - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n");
                }

                if (events.Event == Event.Unbanned)
                {
                    discordUserEvents.Append($"{DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.EventEmojis.Edited)} Unbanned - {events.Timestamp.ToString("ddd, MMM d, yyyy", CultureInfo.CurrentCulture)}\n");
                }
            }

            return(discordUserEvents.ToString());
        }
Ejemplo n.º 12
0
        private async Task Commands_CommandErrored(CommandsNextExtension c, CommandErrorEventArgs e)
        {
            e.Context.Client.Logger.LogError($"MechaSquidski | {e.Context.User.Username} tried executing '{e.Command?.QualifiedName ?? "<unknown command>"}' in {e.Context.Guild.Name} (#{e.Context.Guild.Id}) but it errored: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"}", DateTime.Now);

            if (e.Exception is ChecksFailedException ex)
            {
                var checks = ex.FailedChecks;
                if (checks[0].GetType() == typeof(CooldownAttribute))
                {
                    var ratelimitemoji = DiscordEmoji.FromGuildEmote(e.Context.Client, 628767100709765158);
                    var ratelimitembed = new DiscordEmbedBuilder
                    {
                        Title       = "You have been rate limited",
                        Description = $"{ratelimitemoji} Please slow down your command usage",
                        Color       = new DiscordColor(0x0f00ff)
                    };
                    await e.Context.RespondAsync("", embed : ratelimitembed);

                    return;
                }
                var emoji = DiscordEmoji.FromName(e.Context.Client, ":no_entry:");

                var embed = new DiscordEmbedBuilder
                {
                    Title       = "Access denied",
                    Description = $"{emoji} You do not have permissions required to execute this command",
                    Color       = new DiscordColor(0xFF0000)
                };
                await e.Context.RespondAsync("", embed : embed);
            }
        }
Ejemplo n.º 13
0
        public async Task SearchOnlineAgents(CommandContext ctx)
        {
            List <Agent> agents = await this.agentService.GetAgents(null, null, true, 1, 25);

            DiscordEmbedBuilder onlineUsersEmbed = new DiscordEmbedBuilder
            {
                Footer = new DiscordEmbedBuilder.EmbedFooter
                {
                    IconUrl = DiscordEmoji.FromGuildEmote(ctx.Client, Variables.Emojis.SBGEmojis.Superboss).Url,
                    Text    = $"IntruderFPS API | Total Online Users: {agents.Count}",
                },
                Color     = new DiscordColor(95, 95, 95),
                Timestamp = DateTime.UtcNow,
                Title     = $"**Current Online Users**",
            };

            string agentDetails = string.Empty;

            foreach (Agent agent in agents)
            {
                agentDetails += $"{agent.IntruderID} | {agent.Name} | `{agent.SteamID}`\n";
            }

            if (agents.Count > 25)
            {
                onlineUsersEmbed.Description = $"It looks like there are more than 25 results. Try narrowing your results.\n" +
                                               "Try: .agentsearch -online (int){page} (bool){ShowRooms}\n" +
                                               "Example: `.as -o 1 true`";
            }

            onlineUsersEmbed.AddField($"ID  |  NAME | Steam ID ", agentDetails, false);

            await ctx.Channel.SendMessageAsync(string.Empty, embed : onlineUsersEmbed.Build());
        }
Ejemplo n.º 14
0
        public async Task React(
            CommandContext ctx,
            [Description("Message link")] string messageLink,
            [RemainingText, Description("List of reactions to add")] string emojis
            )
        {
            try
            {
                var message = await ctx.GetMessageAsync(messageLink).ConfigureAwait(false);

                if (message == null)
                {
                    await ctx.ReactWithAsync(Config.Reactions.Failure, "Couldn't find the message").ConfigureAwait(false);

                    return;
                }

                string emoji = "";
                for (var i = 0; i < emojis.Length; i++)
                {
                    try
                    {
                        var c = emojis[i];
                        if (char.IsHighSurrogate(c))
                        {
                            emoji += c;
                        }
                        else
                        {
                            DiscordEmoji de;
                            if (c == '<')
                            {
                                var endIdx = emojis.IndexOf('>', i);
                                if (endIdx < i)
                                {
                                    endIdx = emojis.Length;
                                }
                                emoji = emojis.Substring(i, endIdx - i);
                                i     = endIdx - 1;
                                var emojiId = ulong.Parse(emoji.Substring(emoji.LastIndexOf(':') + 1));
                                de = DiscordEmoji.FromGuildEmote(ctx.Client, emojiId);
                            }
                            else
                            {
                                de = DiscordEmoji.FromUnicode(emoji + c);
                            }
                            emoji = "";
                            await message.ReactWithAsync(de).ConfigureAwait(false);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception e)
            {
                Config.Log.Debug(e);
            }
        }
Ejemplo n.º 15
0
        private async Task OnGuildAvailable(DiscordClient dClient, GuildCreateEventArgs args)
        {
            if (args.Guild.Id != Guilds.Bloon)
            {
                return;
            }

            await this.dClient.Guilds[Guilds.Bloon].GetEmojisAsync();

            DiscordChannel settingsChannel = await this.dClient.GetChannelAsync(BloonChannels.Settings);

            IReadOnlyList <DiscordMessage> messages = await settingsChannel.GetMessagesAsync(this.featureManager.Features.Count);

            for (int i = 0; i < this.featureManager.Features.Count; i++)
            {
                Feature        feature  = this.featureManager.Features[i];
                DiscordMessage message  = messages.Where(m => m.Embeds[0]?.Title == feature.Name).FirstOrDefault();
                DiscordEmbed   newEmbed = CreateFeatureEmbed(feature);

                if (message == null)
                {
                    message = await settingsChannel.SendMessageAsync(embed : newEmbed);

                    await message.CreateReactionAsync(DiscordEmoji.FromGuildEmote(this.dClient, FeatureEmojis.ToggleOff));

                    await message.CreateReactionAsync(DiscordEmoji.FromGuildEmote(this.dClient, FeatureEmojis.ToggleOn));
                }
                else if (!IdenticalEmbed(message.Embeds[0], newEmbed))
                {
                    await message.ModifyAsync(embed : newEmbed);
                }
            }
        }
Ejemplo n.º 16
0
 private void VoiceStateUpdateMemberConnected(BaseDiscordClient client, Embed embed, VoiceStateUpdateEventArgs voiceStateUpdateEventArgs, DiscordChannel afterChannel)
 {
     embed.Title       = $"{DiscordEmoji.FromGuildEmote(client, EmojiLibrary.Joined)} Member connected";
     embed.Description = $"Connected {Formatter.InlineCode(afterChannel.Name)}";
     embed.Color       = DiscordColor.SpringGreen;
     this.logger.Information($"Member '{voiceStateUpdateEventArgs.User.GetUsertag()}' ({voiceStateUpdateEventArgs.User.Id}) connected to the channel '{afterChannel.Name}' ({afterChannel.Id}) on the guild '{voiceStateUpdateEventArgs.Guild.Name}' ({voiceStateUpdateEventArgs.Guild.Id}).");
 }
Ejemplo n.º 17
0
 private void VoiceStateUpdateMemberDisconnected(BaseDiscordClient client, Embed embed, VoiceStateUpdateEventArgs voiceStateUpdateEventArgs, DiscordChannel beforeChannel)
 {
     embed.Title       = $"{DiscordEmoji.FromGuildEmote(client, EmojiLibrary.Left)} Member disconnected";
     embed.Description = $"Disconnected {Formatter.InlineCode(beforeChannel.Name)}";
     embed.Color       = DiscordColor.IndianRed;
     this.logger.Information($"Member '{voiceStateUpdateEventArgs.User.GetUsertag()}' ({voiceStateUpdateEventArgs.User.Id}) disconnected from the channel '{beforeChannel.Name}' ({beforeChannel.Id}) on the guild '{voiceStateUpdateEventArgs.Guild.Name}' ({voiceStateUpdateEventArgs.Guild.Id}).");
 }
Ejemplo n.º 18
0
        private static void MessageUpdate(BaseDiscordClient client, Embed embed, MessageUpdateEventArgs messageUpdateEventArgs)
        {
            var fields = new List <EmbedField>
            {
                new EmbedField
                {
                    Inline = false,
                    Name   = "Before"
                }
            };

            fields.First()
            .Value = messageUpdateEventArgs.MessageBefore != null
                ? messageUpdateEventArgs.MessageBefore.Content
                : "The value is not available due to the message was send while the bot were offline or it's no longer in the cache.";

            fields.Add(new EmbedField
            {
                Inline = false,
                Name   = "Now",
                Value  = Formatter.MaskedUrl("Jump to message", messageUpdateEventArgs.Message.JumpLink)
            });

            embed.Title       = $"{DiscordEmoji.FromGuildEmote(client, EmojiLibrary.Edit)} Message updated";
            embed.Description = new StringBuilder().AppendLine($"Message ({messageUpdateEventArgs.Message.Id}) updated in {messageUpdateEventArgs.Channel.Mention}.")
                                .ToString();
            embed.Color     = DiscordColor.CornflowerBlue;
            embed.Thumbnail = messageUpdateEventArgs.Author.AvatarUrl;
            embed.Fields    = fields;
            embed.Footer    = new EmbedFooter {
                Text = $"Author: {messageUpdateEventArgs.Author.Id} | Message Id: {messageUpdateEventArgs.Message.Id}"
            };
        }
Ejemplo n.º 19
0
        public static async Task ReactionClear(ModCoreShard bot, MessageReactionsClearEventArgs e)
        {
            GuildSettings cfg = null;

            using (var db = bot.Database.CreateContext())
            {
                cfg = e.Channel.Guild.GetGuildSettings(db);
                if (cfg == null)
                {
                    return;
                }

                var          emoji = cfg.Starboard.Emoji;
                DiscordEmoji em    = null;
                if (emoji.EmojiId != 0)
                {
                    em = DiscordEmoji.FromGuildEmote(e.Client, (ulong)emoji.EmojiId);
                }
                else
                {
                    em = DiscordEmoji.FromUnicode(e.Client, emoji.EmojiName);
                }

                if (cfg.Starboard.Enable)
                {
                    var c = e.Channel.Guild.Channels.First(x => x.Key == (ulong)cfg.Starboard.ChannelId).Value;
                    if (db.StarDatas.Any(x => (ulong)x.MessageId == e.Message.Id))
                    {
                        await(await c.GetMessageAsync((ulong)db.StarDatas.First(x => (ulong)x.MessageId == e.Message.Id).StarboardMessageId)).DeleteAsync();
                        db.StarDatas.RemoveRange(db.StarDatas.Where(x => (ulong)x.MessageId == e.Message.Id));
                        await db.SaveChangesAsync();
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public async Task GoodBot(CommandContext context)
        {
            await context.TriggerTypingAsync();

            var emoji = DiscordEmoji.FromGuildEmote(context.Client, 625863698287951873);
            await context.RespondAsync($"{emoji} Thank you, {context.Member.Mention}!");
        }
Ejemplo n.º 21
0
                public async Task addAssignableRole(CommandContext ctx, [Description("Discord Role to add.")] DiscordRole discordRole, [Description("Discord Emoji to assign to role.")] DiscordEmoji emoji)
                {
                    await ctx.TriggerTypingAsync();

                    AssignableRoleJson json = await GetRoleJson(ctx);

                    try
                    {
                        DiscordEmoji testEmoji = DiscordEmoji.FromGuildEmote(ctx.Client, emoji.Id);
                    }
                    catch
                    {
                        await ctx.Channel.SendMessageAsync("You can only use server emojis from a guild where wiggims bot is connected for this command, no default emojis either.");

                        return;
                    }

                    foreach (var role in json.Roles)
                    {
                        if (role.RoleId == discordRole.Id || role.EmojiId == emoji.Id)
                        {
                            await ctx.Channel.SendMessageAsync("Either that role or emoji has already been used, if you wish to remove a role and add it again please use the `w@guild role rm [Role] command`");

                            return;
                        }
                    }

                    await _assignableRoleService.AddRoleToAssignableRoles(ctx.Guild.Id, discordRole.Id, emoji.Id);

                    await ctx.Channel.SendMessageAsync($"{discordRole.Name} was added to the assignable roles list! Please not if the role is higher up than the bots role wiggims bot will not be able to assign this role. Mr_Wiggims1 hasn't figured out how to check for this yet.");
                }
Ejemplo n.º 22
0
        public async Task GoodMorning(CommandContext ctx, [RemainingText] string message)
        {
            DiscordEmoji goodMorningEmoji = DiscordEmoji.FromGuildEmote(
                ShimakazeBot.Client, ShimaConsts.GoodMorningEmojiId);

            if (!string.IsNullOrWhiteSpace(message))
            {
                await CTX.RespondSanitizedAsync(ctx, $"{goodMorningEmoji}/ {message}!", false, null,
                                                new List <IMention> {
                });

                return;
            }

            if (ctx.User.Id == 155038222794227712)
            {
                await CTX.RespondSanitizedAsync(ctx,
                                                $"We have finally awoken, that was slow, wasn't it?\n{goodMorningEmoji}/ everyone!");

                return;
            }

            if (ThreadSafeRandom.ThisThreadsRandom.Next(0, 2) == 1)
            {
                await CTX.RespondSanitizedAsync(ctx, $"You're finally awake? You're too slow! {goodMorningEmoji}/");
            }
            else
            {
                await CTX.RespondSanitizedAsync(ctx, $"{goodMorningEmoji}/ Wanna race? I won't lose!");
            }
        }
Ejemplo n.º 23
0
        public Task <Optional <DiscordEmojiWrapper> > ConvertAsync(string value, CommandContext ctx)
        {
            DiscordEmoji        emoji = null;
            DiscordEmojiWrapper wrapper;

            if (ulong.TryParse(value, out ulong result))
            {
                try
                {
                    emoji   = DiscordEmoji.FromGuildEmote(ctx.Client, result);
                    wrapper = new DiscordEmojiWrapper(emoji);
                    return(Task.FromResult(Optional.FromValue(wrapper)));
                }
                catch
                {
                    return(Task.FromResult(Optional.FromNoValue <DiscordEmojiWrapper>()));
                }
            }
            else
            {
                try
                {
                    emoji   = DiscordEmoji.FromName(ctx.Client, $":{value}:");
                    wrapper = new DiscordEmojiWrapper(emoji);
                    return(Task.FromResult(Optional.FromValue(wrapper)));
                }
                catch
                {
                    return(Task.FromResult(Optional.FromNoValue <DiscordEmojiWrapper>()));
                }
            }
        }
        public async Task RuleAccept(CommandContext ctx)
        {
            ulong grantRoleId = 0;
            int   guildId     = GetGuildIdByUid(ctx.Guild.Id);

            try
            {
                await connection.OpenAsync();

                MySqlCommand selectCmdSub = new MySqlCommand();
                selectCmdSub.Connection  = connection;
                selectCmdSub.CommandText = $"SELECT roleId FROM `guilds.config` WHERE guildId='{guildId}'";
                MySqlDataReader read = selectCmdSub.ExecuteReader();
                if (read.Read())
                {
                    grantRoleId = Convert.ToUInt64(read[0]);
                }
                read.Close();
                await connection.CloseAsync();
            }
            catch (Exception ey)
            {
                Console.WriteLine("Error: " + ey);
                Console.WriteLine(ey.StackTrace);
            }
            await ctx.Message.CreateReactionAsync(DiscordEmoji.FromGuildEmote(ctx.Client, hcEmote));

            await ctx.Member.GrantRoleAsync(ctx.Guild.GetRole(grantRoleId));

            await ctx.Message.DeleteAsync();
        }
Ejemplo n.º 25
0
        private async Task BloonsideEmbed(DiscordClient dClient, GuildMemberAddEventArgs args)
        {
            DiscordChannel sbgChannel = await this.dClient.GetChannelAsync(SBGChannels.Bloonside);

            // If guild isn't SBG, just ignore this user join event.
            if (args.Guild.Id != Variables.Guilds.SBG)
            {
                return;
            }

            DiscordEmbedBuilder embed = this.BuildEmbed(args.Member);

            using IServiceScope scope = this.provider.CreateScope();
            using AnalyticsContext db = scope.ServiceProvider.GetRequiredService <AnalyticsContext>();
            List <UserEvent> userEvents = await db.UserEvents
                                          .Where(u => u.UserId == args.Member.Id)
                                          .OrderByDescending(u => u.Timestamp)
                                          .Take(10)
                                          .ToListAsync();

            embed.AddField(
                "Events",
                string.Join(
                    "\n",
                    userEvents.Select(u => $"{DiscordEmoji.FromGuildEmote(this.dClient, this.eventEmotes[u.Event])} {u.Event.ToString().PadRight(8, '\u2000')} - {u.Timestamp.ToString("ddd, dd MMM yyyy, hh:mm:ss tt", CultureInfo.InvariantCulture)}")));

            // Post embed to #bloonside
            await sbgChannel.SendMessageAsync(embed);
        }
Ejemplo n.º 26
0
        public Task LoadListeners(BaseDiscordClient client)
        {
            var ids = _redis.SetMembers("MessageIds");

            _listener = new Dictionary <string, Dictionary <DiscordEmoji, ulong> >();

            foreach (var id in ids)
            {
                var reactions       = _redis.HashGetAll($"Messages:{id}");
                var emojiDictionary = new Dictionary <DiscordEmoji, ulong>();

                foreach (var reaction in reactions)
                {
                    DiscordEmoji emoji;
                    var          fieldName = reaction.Name.ToString();

                    if (fieldName.StartsWith("<"))
                    {
                        fieldName = fieldName.Substring(fieldName.LastIndexOf(':'));
                        var emojiId = fieldName.Substring(1, fieldName.Length - 2);
                        emoji = DiscordEmoji.FromGuildEmote(client, ulong.Parse(emojiId));
                    }
                    else
                    {
                        emoji = DiscordEmoji.FromUnicode(fieldName);
                    }

                    emojiDictionary.Add(emoji, ulong.Parse(reaction.Value));
                }

                _listener.Add(id, emojiDictionary);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Advertises/Shares a stream. '<paramref name="force"/>' overrides any current stream.
        /// </summary>
        /// <param name="streamerID">Discord user id.</param>
        /// <param name="streamerName">Stream name.</param>
        /// <param name="url">Stream url.</param>
        /// <param name="force">Force Bloon to switch to this stream.</param>
        /// <returns>Awaitable task.</returns>
#pragma warning disable CA1054 // Uri parameters should not be strings
        public async Task SetStreamAsync(ulong streamerID, string streamerName, string url, bool force = false)
#pragma warning restore CA1054 // Uri parameters should not be strings
        {
            if (!force && this.dClient.CurrentUser.Presence.Activity.ActivityType == ActivityType.Streaming)
            {
                return;
            }

            DiscordChannel sbgGeneral = await this.dClient.GetChannelAsync(SBGChannels.General);

            DiscordEmbed streamEmbed = new DiscordEmbedBuilder
            {
                Footer = new DiscordEmbedBuilder.EmbedFooter
                {
                    Text    = url,
                    IconUrl = DiscordEmoji.FromGuildEmote(this.dClient, PlatformEmojis.Twitch).Url,
                },
                Description = $"{streamerName} is streaming Intruder! Stop by and check them out! [**{streamerName}'s Stream**]({url})",
                Color       = new DiscordColor(100, 64, 165),
                Timestamp   = DateTime.UtcNow,
                Title       = $"*Stream Detected!*",
            };

            this.streamOwnerID = streamerID;
            await this.dClient.UpdateStatusAsync(new DiscordActivity
            {
                ActivityType = ActivityType.Streaming,
                Name         = $"Intruder with {streamerName}",
                StreamUrl    = url,
            });

            await sbgGeneral.SendMessageAsync(embed : streamEmbed);
        }
Ejemplo n.º 28
0
        public async Task TopWorkshopMaps(CommandContext ctx)
        {
            List <WorkshopMap> maps = await this.workshopService.GetMapsFromDBAsync();

            DiscordEmbedBuilder workshopMapEmbed = new DiscordEmbedBuilder
            {
                Footer = new DiscordEmbedBuilder.EmbedFooter
                {
                    IconUrl = DiscordEmoji.FromGuildEmote(ctx.Client, PlatformEmojis.Steam).Url,
                    Text    = "Workshop",
                },
                Color     = new DiscordColor(0, 173, 238),
                Title     = "Top Workshop Maps",
                Timestamp = DateTime.Now,
                Url       = $"https://steamcommunity.com/app/518150/workshop/",
            };
            string description = string.Empty;

            for (int i = 0; i < 5; i++)
            {
                description = description +
                              $"{DiscordEmoji.FromGuildEmote(ctx.Client, ServerEmojis.Map)} __[{maps.ElementAt(i).Title}](https://steamcommunity.com/sharedfiles/filedetails/?id={maps.ElementAt(i).FileID})__ " +
                              $"• {DiscordEmoji.FromGuildEmote(ctx.Client, ServerEmojis.Players)} __[{await this.workshopService.GetDBWorkshopMapCreator(maps.ElementAt(i).CreatorSteamID)}](https://steamcommunity.com/profiles/{maps.ElementAt(i).CreatorSteamID}/myworkshopfiles/?appid=518150)__ \n" +
                              $"{DiscordEmoji.FromName(ctx.Client, ":pushpin:")} Subscriptions: **{maps.ElementAt(i).Subscriptions}**\n" +
                              $"{DiscordEmoji.FromName(ctx.Client, ":heart:")} Favorites: **{maps.ElementAt(i).Favorited}**\n" +
                              $"{DiscordEmoji.FromGuildEmote(ctx.Client, EventEmojis.Join)} Followers: **{maps.ElementAt(i).Followers}**\n" +
                              $"\n";
            }

            workshopMapEmbed.Description = description;
            await ctx.RespondAsync(embed : workshopMapEmbed);
        }
Ejemplo n.º 29
0
 private static async Task GuildRoleDelete(BaseDiscordClient client, Embed embed, GuildRoleDeleteEventArgs guildRoleDeleteEventArgs)
 {
     embed.Title       = $"{DiscordEmoji.FromGuildEmote(client, EmojiLibrary.Erase)} Role deleted";
     embed.Description = new StringBuilder().AppendLine($"Name: {Formatter.InlineCode(guildRoleDeleteEventArgs.Role.Name)}")
                         .AppendLine($"Identity: {Formatter.InlineCode(guildRoleDeleteEventArgs.Role.Id.ToString())}")
                         .ToString();
     embed.Color = DiscordColor.IndianRed;
 }
Ejemplo n.º 30
0
        public static DiscordEmoji ToDiscord(DiscordClient client, string rawEmoji)
        {
            if (ulong.TryParse(rawEmoji, out var emojiId))
            {
                return(DiscordEmoji.FromGuildEmote(client, emojiId));
            }

            return(DiscordEmoji.FromName(client, rawEmoji));
        }