【问题标题】:Turning invite code to url discord rewrite将邀请码转为 url discord 重写
【发布时间】:2019-10-13 10:58:14
【问题描述】:

我在我的机器人上设置了一个命令以从服务器中提取有效邀请,但似乎无法将结果转换为 url。

我尝试将 {invites} 转换为 {invites.url},但它似乎不起作用

@commands.is_owner()
    @commands.command()
    async def fi(self, ctx, id: int):
        server = self.bot.get_guild(id)
        invites = await server.invites()
        fetching = await ctx.send("Fetching Invites...")
        await fetching.edit(content=f"All Active Invites Codes: \n {invites}")
        await asyncio.sleep(8)
        await fetching.delete()
        # Fetches invite codes

【问题讨论】:

    标签: url-rewriting discord.py


    【解决方案1】:

    Guild.invites返回一个Invites的列表,所以需要单独获取每个Inviteurl属性。

    invites = await server.invites()
    invites = [invite.url for invite in invites]
    invites_message = "\n".join(invites)
    await fetching.edit(content=f"All Active Invites Codes: \n{invites_message}")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-23
      • 2020-10-17
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多