Replies: 1 comment
-
Read about Fixed code here: import discord
from discord.ext import commands
client = commands.Bot(command_prefix='$', self_bot=True) #discord.Client()
@client.event
async def on_ready():
print('=' * 30)
print(f'Logged in as')
print(f'User: {client.user.name}')
print(f'Id: {client.user.id}')
print('=' * 30)
@client.event
async def on_message(message):
if message.author == client.user:
print('0')
return
print('1')
if message.content.startswith('$hello'):
print('2')
await message.channel.send('Hello!')
await client.process_commands(message)
@client.command(name='test')
async def test(message, arg):
print('3')
try:
await message.channel.send(arg)
except Exception as e:
print(e)
client.run('token') |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='$', self_bot=True) #discord.Client()
@client.event
async def on_ready():
print('=' * 30)
print(f'Logged in as')
print(f'User: {client.user.name}')
print(f'Id: {client.user.id}')
print('=' * 30)
@client.event
async def on_message(message):
if message.author == client.user:
print('0')
return
print('1')
if message.content.startswith('$hello'):
print('2')
await message.channel.send('Hello!')
@client.command(name='test')
async def test(message, arg):
print('3')
try:
await message.channel.send(arg)
except Exception as e:
print(e)
client.run('token')
code with @client.command() does not work at all, but events work nice.
I use my discord account to login. Can any1 help me with this issue?
Beta Was this translation helpful? Give feedback.
All reactions