簡體   English   中英

我的命令在我的 Discord 服務器中不起作用

[英]my commands dont work in my discord server

我試圖為我的不和諧服務器制作一個機器人,但我所有的命令都不起作用。

我使用 windows 和 pycharm 來測試和使用機器人。 我嘗試了許多不同的類型,但沒有任何效果。 我正在使用 python 3.7

import discord
from discord.ext import commands
import asyncio
from discord.ext.commands import Bot

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


@client.event
async def on_ready():
    print("bot is active")


@client.command()
async def ping(ctx):
    await ctx.send('pong')
    await print("pong")

它不會崩潰或給出錯誤,它只是在命令中沒有做任何事情

嘗試這個:

import discord
from discord.ext import commands

TOKEN = YOUR_TOKEN_GOES_HERE

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

@client.event
async def on_ready():
      print("Powering up the bot")

@client.event
async def on_message(message):                    
      print("A new message!")
      await client.process_commands(message)

@client.command()
async def ping(ctx):
      await ctx.channel.send("Pong!")

暫無
暫無

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

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