#π Check if command was done in guild, where bot is added or user install
43 messages Β· Page 1 of 1 (latest)
@plush grove
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
wdym? hide a commend if the bot is a user installed?
that would be nice but overall just check
if bot is added to the server
you can see if command was called from guild if there's ctx.guild field
if it's from a user install, ctx.guild should be None
user installed apps can still be used on servers
oh well
that would only work for dms
wouldnt it
yeah I was thinking about dms
i am unsure about hiding commands but you could try and fetch the bot from the guild, if it returned None than the bot is not in the guild
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member) from a guild ID, and a member ID...
as user installed apps are not members of guilds
hmm
i was thinking if
checking if intertaction.guild
isnt in bot.guilds
wouldnt that work
sounds expensive? doesn't bot.guilds fetch all bot guilds?
There's context of interactions but I guess it would be guild (pycord):
class InteractionContextType(Enum):
"""The interaction's context type"""
guild = 0
bot_dm = 1
private_channel = 2
pretty sure it would be
that would break the case where user is the member of the guild
He wouldn't be able to use that command even though he installed the app
i dont use pycord
so wont work
uhhh
These libs use the same concept
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-context-types
joined or not, invoked in a guild will always be guild
discord/app_commands/commands.py line 2691
def guild_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:```
this is what you looking for
shit ty
Check if the interaction have guild, if it have, maybe check what role the guild have
I think this might work, but not sure
Don't think user install app have permission to see roles
There might be better way tho
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.