so i created a discord bot but i can only type in 1 server and 1 channel how can i make it so the bot can type in multiple channels?
Error msg
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 20, in on_message
amount = int (message.content)
ValueError: invalid literal for int() with base 10: '!Start'
Code:
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print ('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!Start'):
await message.channel.send('Hi')
client.run(os.getenv('TOKEN'))
Are you using discord.js or discord.py? Either way, unless you have a good reason, you are better of using
client = commands.Bot(command_prefix = "-")
@client.command()
async def Start(ctx):
await ctx.send("Hi")
Sorry this does not answer your question, but it may provide a way to achieve the result with a different method. Also if you are using discord.py rewrite, doing async def on_message(message):
without having await client.process_commands(message)
at the end can break a lot of things, so try adding that to your function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.