【问题标题】:Is there a way to join a server/get it's invite through it's ID with the help of your bot?(the bot in this case is already in the server)有没有办法在你的机器人的帮助下通过它的 ID 加入服务器/获得邀请?(在这种情况下,机器人已经在服务器中)
【发布时间】:2019-06-13 11:12:44
【问题描述】:

我的机器人在一些我不在的服务器中,我想在我的机器人的帮助下加入这些服务器。

我尝试了get_invite(url),但它似乎只收到来自 discord.gg 的邀请,这不是我想要的。

我得到了公会ID,现在呢?

@bot.command(pass_context = True)
async def mycmd(ctx):
    guild = bot.get_guild(521738684803055636)

我正在使用 Discord.py 重写 1.0.0a。

【问题讨论】:

    标签: python-3.x discord.py discord.py-rewrite


    【解决方案1】:
    @client.command(pass_context=True)
    async def link(ctx):
        server = client.get_server("server_id")
        link = client.create_invite(destination=server,xkcd=True,max_age=0,max_uses=number)
        await client.say(link)
        #max_age=0-> Never expire link
        #max_uses-> limit to usage the link
        #xkcd-> The URL fragment used for the invite if it is human readable.    
    

    【讨论】:

      【解决方案2】:

      当然,使用create_invite()

      它应该看起来像这样

      @bot.command(pass_context = True)
      async def mycmd(ctx):
          channel = ctx.channel
          invite = await channel.create_invite()
      

      【讨论】:

        猜你喜欢
        • 2015-09-13
        • 1970-01-01
        • 2018-12-04
        • 1970-01-01
        • 2021-07-09
        • 2021-02-13
        • 2020-10-16
        • 2020-10-14
        • 2019-06-30
        相关资源
        最近更新 更多