Issue
As the title suggests I'm having difficulties with my Discord Bot. I have 2 client events and a couple more commands, those are, for overview, not included in the code down below. When I comment out the 'on_message'-event all the commands function properly but as soon as I uncomment it, neither the 'on_message' nor the commands work and there is no error message in the console either so I'm clueless as to what I am doing wrong here.
client = commands.Bot(command_prefix='!', help_command=None)
@client.event
async def on_ready():
channel = client.get_channel(821133655081484318)
print(f'Welcome, {client.user.name} is up and running!')
@client.event
async def on_message(message):
with open("author.json", "r") as f:
author_dic = json.load(f)
if message.author.bot or message.content.startswith("!"):
return None
try:
for list in author_dic.values():
for el in list:
if str(message.author) == el:
channelobj = client.get_channel(list[1])
if message.channel != channelobj:
await channelobj.send(message.content)
except IndexError:
return None
@client.command()
async def getid(ctx, given_name=None):
...
client.run("TOKEN")
I'd be really glad to have someone help me out since I'm kind of lost, already thanks a lot in advance.
Solution
You have to add await client.process_commands(message)
(check this issue in documentation).
@client.event
async def on_message(message):
# rest of your on_message code
await client.process_commands(message) # add this line at the end of your on_message event
Answered By - RiveN
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.