简体   繁体   English

discord.py bot 未加入频道

[英]discord.py bot not joining channel

ok so here is my code好的,这是我的代码

import discord
from discord.ext import commands

TOKEN = 'THIS_IS_MY_BOT_TOKEN'

client = commands.Bot(command_prefix = '.')

@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return
    #typing cat
    if message.content.startswith('!cat'):
        msg = 'https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif'.format(message)
        await client.send_message(message.channel, msg)
    #I dont need sleep i need awnsers
    if message.content.startswith('!sleep'):
        msg = 'https://i.kym-cdn.com/entries/icons/original/000/030/338/New.jpg'.format(message)
        await client.send_message(message.channel, msg)
    #murica
    if message.content.startswith('!murica'):
        msg = 'https://www.dictionary.com/e/wp-content/uploads/2018/08/Murica_1000x700.jpg'.format(message)
        await client.send_message(message.channel, msg)
    if message.content.startswith('!why'):
        msg = 'https://drive.google.com/file/d/1rb132Y785zUjj2RP2G-a_yXBcNK5Ut9z/view?usp=sharing'.format(message)
        await client.send_message(message.channel, msg)
@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.command(pass_context=True)
async def join(ctx):
    if ctx.message.author.voice:
        channel = ctx.message.author.voice.channel
        await channel.connect()

client.run(TOKEN)

the bot joins the sever, but when I say.join, nothing happens机器人加入服务器,但是当我说.join 时,什么也没有发生

the voice channel I want to join is called Club Meeting if that helps如果有帮助,我想加入的语音频道称为Club Meeting

Not entirely sure why, I have no errors when I run it.不完全确定为什么,我运行它时没有错误。 Anyone have any idea whats going on?有人知道发生了什么吗?

I think the problem is your lack of Bot.process_commands You need to put that at the end of your on_message function.我认为问题在于您缺少Bot.process_commands您需要将其放在 on_message function 的末尾。 That seems to be the reason your command isn't working.这似乎是您的命令不起作用的原因。

From The Docs:来自文档:

Why does on_message make my commands stop working?为什么 on_message 使我的命令停止工作? https://discordpy.readthedocs.io/en/latest/faq.html#why-does-on-message-make-my-commands-stop-working https://discordpy.readthedocs.io/en/latest/faq.html#why-does-on-message-make-my-commands-stop-working

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM