当twitter发布消息时,尝试将消息发布到discord时出错

9vw9lbht  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(272)

所以这个想法很简单,我有一个twitter id列表,当这些帐户中的任何一个发布一个帖子时,我希望这个bot接收该帖子,并在特定的discord频道中共享指向它的链接。目前,当我在twitter上发帖时,它会向我抛出一个错误。相关代码:

class MyStreamListener(tweepy.StreamListener): #this runs whenever a tweet is posted
    async def on_status(self, status):
        send(status)

bot = commands.Bot(command_prefix='=')
@bot.event
async def on_ready():
    print(f'{bot.user.name} has connected to Discord!')
    myStreamListener = MyStreamListener() #sets up the listener
    myStream = tweepy.Stream(auth = auth_api.auth, listener=myStreamListener)
    myStream.filter(follow=[{ids of the accounts}], is_async = True)

async def send(postID):
    channel = bot.get_channel(834887013756305490)
    channel.send('https://twitter.com/twitter/statuses/'+str(postID.id)) #error happens here.

以下是错误:c:…site packages\tweepy\streaming.py:54:运行时警告:如果self.on\u状态(status)为false,则从不等待协同程序“mystreamlistener.on\u status”:运行时警告:启用tracemalloc以获取对象分配跟踪
我尝试在非异步通道中执行此操作,这会给我带来一个错误,并且我尝试在channel.send之前添加“await”(这是在命令提示符上发送消息的方式),但这两个都不起作用。
如果有人知道我在这里遗漏了什么,我们将不胜感激。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题