[Python] User.mutual_guilds returning an empty list

Discussão em 'Python' iniciado por Stack, Maio 1, 2025.

  1. Stack

    Stack Membro Participativo

    I decided to code another bot, but this time I coded it with an on_message support function. It worked perfectly fine until I decided to let the user choose which Server the problem relates to. So, i passed ctx (basically the message), and used self.ctx.author.mutual_guilds. And now, I ran into problems, because mutual_guilds returned an empty string. Can anybody please explain me why this happens?

    class ChooseTicketServer(Select):

    def __init__(self, ctx, id):
    self.ctx = ctx
    self.id = id
    self.ServerOptions = [SelectOption(label="Test", value="Test")]
    self.servername = None

    print(self.ctx.author.mutual_guilds)

    for guild in self.ctx.author.mutual_guilds:
    self.ServerOptions.append(SelectOption(label = guild.name, value=f"Server-ID: {guild.id}"))

    super().__init__(placeholder="Choose the Server your Problem relates to...", min_values=1, max_values=1, options=self.ServerOptions)


    class SupportViewCreate(View):

    def __init__(self, *, timeout: float = 120.0, ctx, id):
    super().__init__(timeout=timeout)
    self.ctx = ctx
    self.id = id
    self.add_item(ChooseTicketServer(ctx=self.ctx, id=self.id))


    @bot.event
    async def on_message(ctx):
    if ctx.author == bot.user:
    return
    if not ctx.guild:

    id = random.randint(0, 99999999999999999999)

    while id in bot.activeSupportIDs:
    id = random.randint(0, 99999999999999999999)

    bot.activeSupportIDs.append(id)

    embed = Embed(title="Support Ticket", description="Please choose the Server your Problem relates to.", color=discord.Colour.green())
    embed.set_author(name=f"{ctx.author.display_name}#{ctx.author.discriminator}", icon_url=ctx.author.avatar)
    embed.add_field(name="Ticket-ID: ", value=f"#{id}")
    embed.set_footer(text=f"This is an automatically sent message from {bot.user.name}.")

    View = SupportViewCreate(ctx=ctx, id=id)
    await ctx.channel.send(embed=embed, view=View)

    else:
    await bot.process_commands(ctx)

    Continue reading...

Compartilhe esta Página