簡體   English   中英

discord.py - 無法向其他公會的頻道發送消息

[英]discord.py - Can't send message to channel in other guild

async def sendmessage(ctx, channelID=None, content=None):
  if channelID == None:
      print("ERROR: NSB01")
  else:
     await bot.get_channel(channelID).send(content)

似乎無法向其他服務器/公會中的頻道發送消息...該機器人存在於兩台服務器中(用戶發出命令的服務器和目標頻道所在的服務器)

控制台中也沒有任何錯誤。 任何幫助或建議表示贊賞

嘗試做這樣的事情:

@bot.command()
async def sendmessage(ctx, channelID: int = None, content=None):
  if channelID is None:
      print("ERROR: NSB01")
  else:
     await bot.get_channel(channelID).send(content)

或者你可以獲取一個頻道:

channel = await bot.fetch_channel(channelID)
await channel.send(content)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM