本文介绍了discord.py - 通过控制台发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我想要这样我可以在特定的服务器和通道中从控制台发送消息.我在其他帖子中看到如何在特定服务器和通道上发送消息,但它们来自不和谐应用程序而不是控制台.有人可以帮我吗?

ok, I wanted so I could send messages in an specific server and channel form the console. I seen on other post how to send messages on specific servers and channels but theyr from the discord app and not console. Can someone help me?

我想要,所以我输入 msg [server-id-here] [channel-name] [message] 例如

I wanted so I type msg [server-id-here] [channel-name] [message] for example

msg 493121776402825219 你好

我有代码,但有错误

@bot.event
async def on_ready(ch, *, msg):
while msg:
  channel = bot.get_channel(ch)
  msg=input("Mensagem: ")
if channel:
  await bot.send_message(channel, msg)
else:
  await bot.say("I can't find that channel")

输出错误

TypeError: on_message() 缺少 1 个必需的位置参数:'ch'

推荐答案

使用 say 命令.

@bot.command()
async def say(ctx, *,message):
   if not ctx.author.bot:

   else:
      pass

这篇关于discord.py - 通过控制台发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:22
查看更多