Scriptinger
Scriptinger

Reputation: 21

How do i fix discord client command not working in Python

I'm currently working on a bot in Discord written in The Python programming language. Ive watched a few tutorials cause i couldn't get it to work by myself and i noticed all the people used the Client = discord.Client() command after importing needed files for running the program. When i try to run the app, it says

 Traceback (most recent call last):
File "C:\Users\Admin\Desktop\testbot.py", line 2, in <module>
import discord.client
ModuleNotFoundError: No module named 'discord.client'

If anyone has any suggestions, please reply and let me know! Thanks!

Here's my code for the bot!

import discord

Client = discord.Client()

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

@client.event
async def on_message(message):
    if message.content == '/testconnection':
        await client.send_message(message.channel, "Connection     successfully established with Discord NET")

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('-------')




client.run("my discord bot token goes here but i'm hiding it ")

Upvotes: 0

Views: 4591

Answers (1)

Patrick Haugh
Patrick Haugh

Reputation: 60954

import discord.client This line does not appear anywhere in the code you posted.

You're assigning discord.Client() to Client, but using client in the rest of your code. Names are case-sensitive, so you should change that line to

client = discord.Client()

Upvotes: 2

Related Questions