import discord
import random
import asyncio
import pickle
import os
client = discord.Client()
@client.event
async def on_ready():
print('logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
if message.content.startswith('!hello'):
await client.send_message(message.channel,'sample text')
client.run(MY_TOKEN)
when i run it it prints the following message :
Traceback (most recent call last):
File "C:/Users/Tommy/PycharmProjects/discord/discord.py", line 1, in <module>
import discord
File "C:\Users\Tommy\PycharmProjects\discord\discord.py", line 8, in <module>
client = discord.Client()
AttributeError: module 'discord' has no attribute 'Client'
not sure what to do here, i already set the paths in the interpreter but it still prints this message, i got all this code from a youtube video and it is verbatim so i dont know why it is not working
Don't give your files the same name as the modules you are importing.
You are having this problem because your filename is "discord.py". Just change it and the code should work.
Also, you should avoid posting your token...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With