(discord.py - RPC)“运行时警告:从未等待过协程‘BaseClient.handshake’”

时间:2021-05-08 19:24:57

标签: python discord discord.py discord-rpc

我正在尝试在我的客户端中使用 Discord Rich Presence,但是我一直收到以下错误:\rpc.py:27: RuntimeWarning: coroutine 'BaseClient.handshake' was never awaited 即使 RPC 模块不是协程。

我的完整代码:

from discord.ext import commands, tasks
from pypresence import Presence


class RPC(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._rpc = self.default_rpc.start()

    @tasks.loop(seconds=15)
    async def default_rpc(self):
        app_ID = "id"
        main_text = "text"
        details = "text"
        large_image = "text"
        large_text = "text"
        buttons = [
            {"label": "Server", "url": "https://discord.gg/"},
            {"label": "Website", "url": "https://"}
        ]

        RPC = Presence(app_ID)
        try:
            RPC.connect()
            RPC.update(state=main_text, details=details, large_image=large_image, large_text=large_text, buttons=buttons)
        except:
            pass

    @default_rpc.before_loop
    async def before_default_rpc(self):
        await self.bot.wait_until_ready()

def setup(bot):
    bot.add_cog(RPC(bot))

完全错误:

\cogs\rpc.py:28: RuntimeWarning: coroutine 'BaseClient.handshake' was never awaited
  pass
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

RPC 模块:pypresence

0 个答案:

没有答案