Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Discord bot problem
#1
So today im trying to learn the basics of discord bots & coding, But i get this error when i try to run my bot.
screenshot https://gyazo.com/264d179484d54d863dac2e5af770134b

Error:
Traceback (most recent call last): File "C:\Users\edwin\Desktop\CustyCancookie.py", line 1, in <module> import discord File "C:\Users\edwin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\__init__.py", line 20, in <module> from .client import Client, AppInfo, ChannelPermissions File "C:\Users\edwin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 38, in <module> from .state import ConnectionState File "C:\Users\edwin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 36, in <module> from . import utils, compat File "C:\Users\edwin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\compat.py", line 32 create_task = asyncio.async ^ SyntaxError: invalid syntax
This is my code
Iwould love help.

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

Client = discord.Client()
client = commands.Bot(command_prefix = ",")

@client.event
async def on_ready():
    print("Bot is ready")

@client.event
async def on_message(message):
    if message.content == "cookie":
        await client.send_message(message.channel, ":cookie:")

client.run("ImNotLeakingMyToken")
Reply
#2
it looks like you don't have latest version of discord.
This problem was addressed in November'2017
https://github.com/Rapptz/discord.py/com...573c090c0b
However on pypi latest version is from 1 October 2017.
So until they release new version on PyPI you need to work with development version from GitHub if you want to stay with python 3.7.
Or you can use python 3.6 and discord from PyPI

Given that python 3.7 was released last week, there is high chance they will release new version shortly
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Install 3.6,don't add to Path.
Now use py(can access all version installed and install with pip),then Python 3.7 can still be your main version.
# Python 3.7 in main install in Path
E:\div_code
λ python -V
Python 3.7.0

E:\div_code
λ pip -V
pip 10.0.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Install to 3.6
E:\div_code
λ py -3.6 -m pip install -U discord.py
Requirement already up-to-date: discord.py in c:\python36\lib\site-packages (0.16.12)
Requirement not upgraded as not directly required: websockets<4.0,>=3.1 in c:\python36\lib\site-packages (from discord.py) (3.4)
Requirement not upgraded as not directly required: aiohttp<1.1.0,>=1.0.0 in c:\python36\lib\site-packages (from discord.py) (1.0.5)
Requirement not upgraded as not directly required: multidict>=2.0 in c:\python36\lib\site-packages (from aiohttp<1.1.0,>=1.0.0->discord.py) (3.3.2)
Requirement not upgraded as not directly required: async-timeout in c:\python36\lib\site-packages (from aiohttp<1.1.0,>=1.0.0->discord.py) (2.0.0)
Requirement not upgraded as not directly required: chardet in c:\python36\lib\site-packages (from aiohttp<1.1.0,>=1.0.0->discord.py) (3.0.4)
mypy 0.560 has requirement psutil<5.5.0,>=5.4.0, but you'll have psutil 5.3.1 which is incompatible.

# Run with 3.6 will be
py -3.6 my_program.py
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help discord bot Edward 0 2,059 Sep-15-2022, 09:55 PM
Last Post: Edward
  Discord Bot Dark_Sovereign_193 0 32,495 Jun-03-2021, 03:24 PM
Last Post: Dark_Sovereign_193
  Discord Bot Help Oshadha 0 1,384 Jan-26-2021, 04:23 PM
Last Post: Oshadha
  Creating Discord Bot: Unused import statement 'import discord EyeballCandy 0 3,517 Feb-02-2020, 10:53 PM
Last Post: EyeballCandy
  Problem Discord Bot Python Kint 4 70,227 Aug-11-2019, 04:02 PM
Last Post: Kint
  Discord Bot Arbys 7 27,335 Nov-06-2017, 03:36 PM
Last Post: Gamer
  discord bot lolteam 1 6,024 Aug-31-2017, 08:57 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020