Add context menu for userinfo

This commit is contained in:
Zeva Rose 2022-03-31 00:15:59 -06:00
parent 502c5c2ad1
commit de063c1411

View file

@ -17,8 +17,10 @@ from dis_snek.models.discord.guild import Guild
from dis_snek.models.discord.role import Role from dis_snek.models.discord.role import Role
from dis_snek.models.discord.user import Member, User from dis_snek.models.discord.user import Member, User
from dis_snek.models.snek.application_commands import ( from dis_snek.models.snek.application_commands import (
CommandTypes,
OptionTypes, OptionTypes,
SlashCommandChoice, SlashCommandChoice,
context_menu,
slash_command, slash_command,
slash_option, slash_option,
) )
@ -178,16 +180,6 @@ class UtilCog(Scale):
await ctx.send(embed=embed, file=color_show) await ctx.send(embed=embed, file=color_show)
@slash_command(
name="userinfo",
description="Get user info",
)
@slash_option(
name="user",
description="User to get info of",
opt_type=OptionTypes.USER,
required=False,
)
async def _userinfo(self, ctx: InteractionContext, user: User = None) -> None: async def _userinfo(self, ctx: InteractionContext, user: User = None) -> None:
await ctx.defer() await ctx.defer()
if not user: if not user:
@ -233,6 +225,23 @@ class UtilCog(Scale):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@slash_command(
name="userinfo",
description="Get user info",
)
@slash_option(
name="user",
description="User to get info of",
opt_type=OptionTypes.USER,
required=False,
)
async def _userinfo_slsh(self, ctx: InteractionContext, user: User = None) -> None:
await self._userinfo()
@context_menu(name="User Info", context_type=CommandTypes.USER)
async def _userinfo_menu(self, ctx: InteractionContext) -> None:
await self._userinfo(ctx, ctx.target)
@slash_command(name="serverinfo", description="Get server info") @slash_command(name="serverinfo", description="Get server info")
async def _server_info(self, ctx: InteractionContext) -> None: async def _server_info(self, ctx: InteractionContext) -> None:
guild: Guild = ctx.guild guild: Guild = ctx.guild