-2

I am new to discord python so I don't have idea what is this problem.

It seem like in line 26 there are some problems

I am using replit to make the bot.

This is my code:

import os
import discord
#import io
import random
#import textwrap
#import urllib
#import aiohttp
#import datetime
#import os
from discord.ext import commands
from itertools import cycle
from webserver import keep_alive

client = commands.Bot(command_prefix = ["!$", "m!", "mi!", "m:", "mi:", "miracle:", "Miracle:", "@Miracle#4170"], case_insensitive=True, help_command = None)

keep_alive()

bot = client = commands

@client.event
async def on_ready():
    print('Ready')
    await client.change_presence(activity=discord.Game(name="Your Server"))

and this is the full error it gives out:

Traceback (most recent call last):
  File "main.py", line 26, in <module>
    @client.event
AttributeError: module 'discord.ext.commands' has no attribute 'event'
Traceback (most recent call last):
  File "main.py", line 26, in <module>
    @client.event
AttributeError: module 'discord.ext.commands' has no attribute 'event'
  • 1
    You are redefining `client` as `commands` in the line `bot=client=commands`. Remove this line, it is unnecessary. – Sandy Jul 09 '22 at 10:43
  • There is still error https://i.ibb.co/4MDcmK1/In-Collage-20220709-122607488.jpg – ctrl_c_ctrl_v Jul 09 '22 at 11:39
  • 1
    The error in the image is completely unrelated to this question. Please read the error, it clearly states that it got an unexpected keyword argument `bot`. Remove the `bot` argument, and it will work. The client will be a bot if you have ticked `bot` in the scopes of the application in the discord developer portal, you do not need to pass `bot` as an argument. – Sandy Jul 09 '22 at 20:22
  • 1
    I would also like to state that you are using replit and the token is not protected. Repls are visible publicly, and your token can be stolen and misused. Please read [this](https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables) to get an idea of how to securely use sensitive information. – Sandy Jul 09 '22 at 20:24
  • If you're using a self bot, then those are no longer supported. You need to downgrade to earlier versions if you still want to use them. Also you've set `bot` and `client` both to the `commands` module itself. – Eric Jin Jul 10 '22 at 13:11

1 Answers1

0

This should fix it:

import os
import discord
#import io
import random
#import textwrap
#import urllib
#import aiohttp
#import datetime
#import os
from discord.ext import commands
from itertools import cycle
from webserver import keep_alive

client = commands.Bot(command_prefix = ["!$", "m!", "mi!", "m:", "mi:", "miracle:", "Miracle:", "@Miracle#4170"], case_insensitive=True, help_command = None)

keep_alive()



@client.event
async def on_ready():
    print('Ready')
    await client.change_presence(activity=discord.Game(name="Your Server"))
client.run("YOUR TOKEN HERE")

I removed the line bot = client = commands, and replaced bot.run with client.run.

Jaffa
  • 189
  • 1
  • 6