public async Task UserInfoFromMessageCommand(ContextMenuContext ctx) { DiscordGuild guild = await ctx.Client.GetGuildAsync(Guilds.SBG); DiscordMember member = await guild.GetMemberAsync(ctx.TargetMessage.Author.Id); Permissions memberPerms = member.PermissionsIn(guild.GetChannel(ctx.Channel.Id)); DiscordEmbedBuilder userDetails = new DiscordEmbedBuilder { Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"ID: {member.Id} | isBot: {(member.IsBot ? "✔" : "✘")}", }, Color = new DiscordColor(95, 95, 95), Timestamp = DateTime.UtcNow, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = member.AvatarUrl, }, Title = $"**User Details for {ctx.Channel.Name}**", }; userDetails.WithDescription(this.BuildUserDetails(member)); userDetails.AddField("Guild Permissions", this.BuildPermissions(memberPerms, ctx)); await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(userDetails.Build()).AsEphemeral(true)); }
public async Task UserInfoFromUserMenu(ContextMenuContext ctx) { DiscordGuild guild = await ctx.Client.GetGuildAsync(Guilds.SBG); DiscordMember member = await guild.GetMemberAsync(ctx.TargetMember.Id); DiscordEmbedBuilder userDetails = new DiscordEmbedBuilder { Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"ID: {member.Id} | isBot: {(member.IsBot ? "✔" : "✘")}", }, Color = new DiscordColor(95, 95, 95), Timestamp = DateTime.UtcNow, Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail { Url = member.AvatarUrl, }, Title = "**User Details**", }; userDetails.WithDescription(this.BuildUserDetails(member)); string userEvents = this.BuildUserEventsAsync(ctx.TargetMember.Id, ctx); if (!string.IsNullOrEmpty(userEvents)) { userDetails.AddField("User Server Events", userEvents); } await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(userDetails.Build()).AsEphemeral(true)); }
public async Task DumpCommand(ContextMenuContext ctx) { await using var outStream = new MemoryStream(Encoding.UTF8.GetBytes(ctx.TargetMessage.Content)) { Position = 0 }; await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddFile("message.txt", outStream)); }