Skip to content

Commit

Permalink
Allow using /userinfo in DMs
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Sep 27, 2024
1 parent 71f60f0 commit 2bdc19d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Commands/UserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public class UserInfo : ApplicationCommandModule
{
[SlashCommand("userinfo", "Returns information about the provided server member.")]
[SlashRequireGuild]
public static async Task UserInfoCommand(InteractionContext ctx,
[Option("user", "The user to look up information for. Defaults to yourself.")]
DiscordUser user = null)
Expand All @@ -14,8 +13,15 @@ public static async Task UserInfoCommand(InteractionContext ctx,

try
{
var member = await ctx.Guild.GetMemberAsync(user.Id);
userInfoEmbed = await UserInfoHelpers.GenerateUserInfoEmbed(member);
if (ctx.Guild is not null)
{
var member = await ctx.Guild.GetMemberAsync(user.Id);
userInfoEmbed = await UserInfoHelpers.GenerateUserInfoEmbed(member);
}
else
{
userInfoEmbed = await UserInfoHelpers.GenerateUserInfoEmbed(user);
}
}
catch (NotFoundException)
{
Expand Down

0 comments on commit 2bdc19d

Please sign in to comment.