How to create a Discord.py command?
In fact, it doesn't show anything in the console at all, what should I do?
There's no error, nothing is executing.
import discord
import time
from discord.ext import commands
client = commands.Bot(command_prefix='/')
# This detects when the bot started.
@client.event
async def on_ready():
print(f'{client.user.name} is ready!')
# This detects when someone sends a message.
@client.event
async def on_message(message):
if message.author == client.user:
return
if 'fuck' in message.content:
await message.delete()
async with message.channel.typing():
time.sleep(1)
await message.channel.send('You cannot swear in this discord server!')
if 'shit' in message.content:
await message.delete()
async with message.channel.typing():
time.sleep(1)
await message.channel.send('You cannot swear in this discord server!')
if 'bitch' in message.content:
await message.delete()
async with message.channel.typing():
time.sleep(1)
await message.channel.send('You cannot swear in this discord server!')
if 'https://' in message.content:
await message.delete()
async with message.channel.typing():
time.sleep(1)
await message.channel.send('You cannot send links in this discord server!')
# This cteates a command.
@commands.command()
async def test(ctx, arg):
async with message.channel.typing():
time.sleep(1)
await ctx.send(arg)
client.add_command(test)
client.run('TOKEN')