discord.py bot未加入频道

2024-04-25 21:56:35 发布

您现在位置:Python中文网/ 问答频道 /正文

好的,这是我的代码

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)

机器人加入了服务器,但当我说。加入,什么也没发生

如果有帮助的话,我想加入的语音频道叫做Club Meeting

不完全确定为什么,我运行它时没有错误。有人知道发生了什么吗


Tags: httpscomclienttokensendformatmessageasync