Exemplo n.º 1
0
            public async Task DatabaseAsync([Remainder] DiscordUser user)
            {
                var userDb = await DbContext.Users.FirstOrDefaultAsync(x => x.UserId == user.Id);

                if (userDb is null)
                {
                    await ReplyErrorAsync(Localization.BotUserNotInDatabase, user.FullName());

                    return;
                }

                var mutualGuilds = user is DiscordMember cachedUser?cachedUser.GetMutualGuilds(RiasBot).Count() : 0;

#if RELEASE
                var currency = GetText(Localization.GamblingCurrency);
#else
                var currency = GetText(Localization.GamblingHearts);
#endif

                var embed = new DiscordEmbedBuilder()
                            .WithColor(RiasUtilities.ConfirmColor)
                            .WithAuthor(user.FullName(), user.GetAvatarUrl(ImageFormat.Auto))
                            .AddField(GetText(Localization.CommonId), user.Id.ToString(), true)
                            .AddField(currency, $"{userDb.Currency} {Configuration.Currency}", true)
                            .AddField(GetText(Localization.XpGlobalLevel), RiasUtilities.XpToLevel(userDb.Xp, 30).ToString(), true)
                            .AddField(GetText(Localization.XpGlobalXp), userDb.Xp.ToString(), true)
                            .AddField(GetText(Localization.BotIsBanned), userDb.IsBanned.ToString(), true)
                            .AddField(GetText(Localization.BotMutualGuilds), mutualGuilds.ToString(), true)
                            .WithImageUrl(user.GetAvatarUrl(ImageFormat.Auto));

                await ReplyAsync(embed);
            }
Exemplo n.º 2
0
        internal static DiscordEmbedBuilder.EmbedAuthor MakeUserAuther(DiscordUser user)
        {
            var author = new DiscordEmbedBuilder.EmbedAuthor();

            author.Name    = user.Username;
            author.IconUrl = user.GetAvatarUrl(ImageFormat.Png, 16);
            return(author);
        }
 public static DiscordEmbedBuilder WithRequestedBy(this DiscordEmbedBuilder deb, DiscordUser usr, bool t = true)
 {
     deb.WithFooter($"Requested by {usr.Username}#{usr.Discriminator}", usr.GetAvatarUrl(ImageFormat.WebP));
     if (t)
     {
         deb.WithTimestamp(DateTime.Now);
     }
     return(deb);
 }
Exemplo n.º 4
0
 private ImageSource FindUserAvatar(DiscordUser user)
 {
     if (imgCache.ContainsKey(user.Id))
     {
         return(imgCache[user.Id]);
     }
     else
     {
         var bitmap = new BitmapImage();
         bitmap.BeginInit();
         bitmap.UriSource = new Uri(user.GetAvatarUrl(ImageFormat.Png, 64), UriKind.Absolute);
         bitmap.EndInit();
         imgCache.Add(user.Id, bitmap);
         return(bitmap);
     }
 }
Exemplo n.º 5
0
    public async Task Userinfo(CommandContext ctx, [Description("the user like duh")] DiscordUser a)
    {
        var lang = await Language.GetLanguageFromCtxAsync(ctx);

        await new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder()
                                                    .WithTitle(lang.User + a.Username)
                                                    .WithDescription(lang.InformationAbout + a.Mention)
                                                    .AddField(lang.Userid, a.Id.ToString(), true)
                                                    .AddField(lang.JoinedSilverCraft, BoolToEmoteString(await IsAtSilverCraftAsync(ctx.Client, a, Config)),
                                                              true)
                                                    .AddField(lang.IsAnOwner, BoolToEmoteString(ctx.Client.CurrentApplication.Owners.Contains(a)), true)
                                                    .AddField(lang.IsABot, BoolToEmoteString(a.IsBot), true)
                                                    .AddField(lang.AccountCreationDate, a.CreationTimestamp.UtcDateTime.DateTimeToTimeStamp(TimestampFormat.LongDateTime), true)
                                                    .AddField(lang.AccountJoinDate,
                                                              ctx.Guild?.Members.ContainsKey(a.Id) == true
                    ? ctx.Guild?.Members[a.Id].JoinedAt.UtcDateTime.DateTimeToTimeStamp(TimestampFormat.LongDateTime)
                    : "NA", true)
                                                    .WithColor(await ColorUtils.GetSingleAsync())
                                                    .WithThumbnail(a.GetAvatarUrl(ImageFormat.Png))
                                                    .WithFooter(lang.RequestedBy + ctx.User.Username, ctx.User.GetAvatarUrl(ImageFormat.Png))
                                                    .Build()).WithReply(ctx.Message.Id).SendAsync(ctx.Channel);
    }
Exemplo n.º 6
0
        private async Task AvatarFromUser(AvatarLocation location, Context ctx, PKMember target, DiscordUser user)
        {
            ctx.CheckSystem().CheckOwnMember(target);
            if (user.AvatarHash == null)
            {
                throw Errors.UserHasNoAvatar;
            }

            var url = user.GetAvatarUrl(ImageFormat.Png, 256);

            await UpdateAvatar(location, ctx, target, url);

            var embed = new DiscordEmbedBuilder().WithImageUrl(url).Build();

            if (location == AvatarLocation.Server)
            {
                await ctx.Reply($"{Emojis.Success} Member server avatar changed to {user.Username}'s avatar! This avatar will now be used when proxying in this server (**{ctx.Guild.Name}**). {Emojis.Warn} Please note that if {user.Username} changes their avatar, the member's server avatar will need to be re-set.", embed : embed);
            }
            else if (location == AvatarLocation.Member)
            {
                await ctx.Reply($"{Emojis.Success} Member avatar changed to {user.Username}'s avatar! {Emojis.Warn} Please note that if {user.Username} changes their avatar, the member's avatar will need to be re-set.", embed : embed);
            }
        }
Exemplo n.º 7
0
        public async Task LookupUserAsync(CommandContext ctx, [Description("The user to lookup, can be an ID")] DiscordUser InputUser = null)
        {
            if (InputUser == null)
            {
                InputUser = ctx.User;
            }

            DiscordMember member;

            try
            {
                member = await ctx.Guild.GetMemberAsync(InputUser.Id);
            }
            catch
            {
                member = null;
            }


            DiscordEmbedBuilder EBuilder = new DiscordEmbedBuilder()
                                           .WithAuthor($"{InputUser.Username}#{InputUser.Discriminator}")
                                           .WithImageUrl(InputUser.GetAvatarUrl(ImageFormat.Png, 64))
                                           .WithTimestamp(DateTime.Now)
                                           .AddField("\u200b", InputUser.Mention);

            if (member != null)
            {
                EBuilder.AddField("In current guild", "true");
            }
            else
            {
                EBuilder.AddField("In current guild", "false");
            }

            await ctx.RespondAsync(embed : EBuilder.Build());
        }
        private async void ExploitDetection_FakeMuteExploitDetected(AbuseTracker _, DiscordUser user)
        {
            if (user is null)
            {
                await Logger.Error("Log Channel", "User who attempted exploit is somehow null; cannot continue logging.");

                return;
            }

            var logChannel = await client.GetChannelAsync(logChannelID);

            if (logChannel is null)
            {
                await Logger.Error("Log Channel", "Logging channel is null; cannot continue logging.");

                return;
            }

            var embed = new DiscordEmbedBuilder()
                        .WithTitle("🔊 Fake Mute/Deaf Exploit Detected")
                        .WithAuthor($"{user.Username}#{user.Discriminator} [{user.Id}]", null, user.GetAvatarUrl(ImageFormat.Auto))
                        .WithColor(new DiscordColor(config.LogChannelEmbedColor))
                        .WithFooter(logChannel.Guild?.Name ?? "null (hmmm - this shouldn't happen)")
                        .WithTimestamp(DateTime.Now)
                        .AddField("Voice Channel", $"<#{config.ChannelID}>", true)
                        .AddField("Action Taken", config.BanDetectedUsers ? "This user was banned." : "No action taken.", true)
                        .Build();

            await logChannel.SendMessageAsync(embed);
        }
Exemplo n.º 9
0
        private static async Task <RandomAccessStreamReference> GetAvatarReferenceAsync(DiscordUser user, StorageFolder folder)
        {
            var tempFile = await folder.TryGetItemAsync($"{user.AvatarHash}.jpeg") as StorageFile;

            if (tempFile == null)
            {
                tempFile = await folder.CreateFileAsync($"{user.AvatarHash}.jpeg", CreationCollisionOption.FailIfExists);

                using (var fileStream = await tempFile.OpenAsync(FileAccessMode.ReadWrite))
                    using (var stream = await Tools.HttpClient.GetInputStreamAsync(new Uri(user.GetAvatarUrl(ImageFormat.Jpeg, 256))))
                    {
                        await RandomAccessStream.CopyAndCloseAsync(stream, fileStream);
                    }
            }

            return(RandomAccessStreamReference.CreateFromFile(tempFile));
        }
Exemplo n.º 10
0
            public async Task TagInfo(CommandContext ctx, [RemainingText] string tag)
            {
                var GuildSettings = await discordUrie.Config.FindGuildSettings(ctx.Guild);

                tag = Regex.Escape(tag).ToLower();
                var Tag = GuildSettings.Tags.First(xr => xr.Tag.ToLower() == tag);

                if (Tag == null)
                {
                    await ctx.RespondAsync("Invalid tag");

                    return;
                }

                DiscordUser TagOwner = await ctx.Client.GetUserAsync(Tag.Owner);

                DiscordEmbedBuilder EBuilder = new DiscordEmbedBuilder();

                EBuilder.WithAuthor($"{TagOwner.Username}#{TagOwner.Discriminator}", iconUrl: TagOwner.GetAvatarUrl(ImageFormat.Png));
                EBuilder.AddField("Tag Name", Tag.Tag);
                EBuilder.AddField("Owner Id", Tag.Owner.ToString());
                await ctx.RespondAsync(embed : EBuilder.Build());
            }
Exemplo n.º 11
0
 public async Task AvatarCommand(CommandContext ctx, [Description("The user to get the profile picture of")] DiscordUser user)
 {
     await ctx.RespondAsync(embed : new DiscordEmbedBuilder()
                            .WithImageUrl(user.GetAvatarUrl(ImageFormat.Auto, size: 256))
                            .WithTitle(user.Username + "'s Profile Picture"));
 }
Exemplo n.º 12
0
    public async Task WhoIsTask(BaseContext ctx, DiscordUser user)
    {
        var lang = await Language.GetLanguageFromGuildIdAsync(ctx.Guild.Id, Dbctx);

        await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
                                      new DiscordInteractionResponseBuilder().AddEmbed(new DiscordEmbedBuilder()
                                                                                       .WithTitle(lang.User + user.Username)
                                                                                       .WithDescription(lang.InformationAbout + user.Mention)
                                                                                       .AddField(lang.Userid, Formatter.InlineCode(user.Id.ToString()), true)
                                                                                       .AddField(lang.JoinedSilverCraft,
                                                                                                 StringUtils.BoolToEmoteString(await Genericcommands.IsAtSilverCraftAsync(ctx.Client, user, Cnf)),
                                                                                                 true)
                                                                                       .AddField(lang.IsAnOwner,
                                                                                                 StringUtils.BoolToEmoteString(ctx.Client.CurrentApplication.Owners.Contains(user)), true)
                                                                                       .AddField(lang.IsABot, StringUtils.BoolToEmoteString(user.IsBot), true)
                                                                                       .AddField(lang.AccountCreationDate, user.CreationTimestamp.UtcDateTime.DateTimeToTimeStamp(TimestampFormat.LongDateTime), true)
                                                                                       .AddField(lang.AccountJoinDate,
                                                                                                 ctx.Guild?.Members.ContainsKey(user.Id) == true
                        ? ctx.Guild?.Members[user.Id].JoinedAt.UtcDateTime.DateTimeToTimeStamp(TimestampFormat.LongDateTime)
                        : "NA", true)
                                                                                       .WithColor(await ColorUtils.GetSingleAsync())
                                                                                       .WithThumbnail(user.GetAvatarUrl(ImageFormat.Png))
                                                                                       .WithFooter(lang.RequestedBy + ctx.User.Username, ctx.User.GetAvatarUrl(ImageFormat.Png))
                                                                                       .Build()).AsEphemeral(true));
    }
Exemplo n.º 13
0
 public SdImage(DiscordUser user)
 {
     Url = user.GetAvatarUrl(ImageFormat.Png, 2048);
 }
Exemplo n.º 14
0
 public static string GetCurrentAvatarUrl(this DiscordUser user, ushort size = 1024)
 {
     return((user.AvatarHash?.StartsWith("a_") == true
         ? user.GetAvatarUrl(ImageFormat.Gif, size)
         : user.GetAvatarUrl(ImageFormat.Png, size)) ?? user.DefaultAvatarUrl);
 }