#πŸ”’ Check if command was done in guild, where bot is added or user install

43 messages Β· Page 1 of 1 (latest)

plush grove
#

simple question, just wanna do some feature that U NEED to have bot added to that server to use rather then user install

rain cloakBOT
#

@plush grove

Python help channel opened

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.

idle pendant
plush grove
#

if bot is added to the server

empty pagoda
#

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

plush grove
#

user installed apps can still be used on servers

empty pagoda
#

oh well

plush grove
#

wouldnt it

empty pagoda
#

yeah I was thinking about dms

idle pendant
#

!d discord.Guild.fetch_member

rain cloakBOT
#

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...
idle pendant
#

as user installed apps are not members of guilds

plush grove
#

hmm

#

i was thinking if

#

checking if intertaction.guild

#

isnt in bot.guilds

#

wouldnt that work

idle pendant
#

sounds expensive? doesn't bot.guilds fetch all bot guilds?

empty pagoda
#

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
idle pendant
#

pretty sure it would be

empty pagoda
#

He wouldn't be able to use that command even though he installed the app

plush grove
#

so wont work

#

uhhh

empty pagoda
plush grove
#

ima just fetch member ig

#

ty guys

rain cloakBOT
#

discord/app_commands/commands.py line 2691

def guild_install(func: Optional[T] = None) -> Union[T, Callable[[T], T]]:```
idle pendant
#

this is what you looking for

plush grove
#

shit ty

lilac reef
#

Don't think user install app have permission to see roles

#

There might be better way tho

rain cloakBOT
#
Python help channel closed for inactivity

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.