【问题标题】:Self bot join server (discord,py)自 bot 加入服务器 (discord,py)
【发布时间】:2021-11-24 16:52:28
【问题描述】:

我试图让我的自我机器人加入服务器。我知道自我机器人违反 Discord TOS,但我想学习一些新东西。

这是我试过的命令:

@client.command()
async def join(serverlink):
    await client.accept_invite(serverlink)

错误:

File "bot.py", line 6821, in join
await client.accept_invite(serverlink)
AttributeError: 'Bot' object has no attribute 'accept_invite'

【问题讨论】:

    标签: python discord


    【解决方案1】:

    Discord 机器人目前无法自行加入服务器,只能通过具有“管理服务器”权限的用户手动邀请来邀请它们加入服务器。

    【讨论】:

      【解决方案2】:

      迟到了,但如果有人仍然需要它,把它留在这里。

      考虑到它是一个自我机器人,您可以使用 discord 的用户端点使其加入服务器,即https://discord.com/api/v9/invites/{invite_code},其中invite_code 是您服务器的代码。

      所以代码应该是这样的:

      import requests
      #base url
      url = "https://discord.com/api/v9/invites/{}"
      #headers, add more headers to make sure you dont get banned by discord for automating, you can see your headers by pressing ctrl+shift+i and going to the networks tab.
      headers = {
          "Authorization":"your token here"
      }
      
      r = requests.post(url.format("your invite code"), headers=headers, json={})
      print(r.status_code) #prints 200 if all went well
      

      请记住,这违反了 ToS,因此首先在 alt 帐户上进行测试似乎是个好主意。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-06-15
        • 2021-11-10
        • 2021-01-12
        • 1970-01-01
        • 2021-07-28
        • 2021-03-26
        • 2021-06-04
        • 2021-02-07
        相关资源
        最近更新 更多