I know discord.py is kinda old but like 2 years ago i discovered this and decided to try code, kinda lost it and month ago retry coding
So i have this strange error beacose while i was codding tree comands i delete something and my commands stopped working
Spent 2 days to find solution but still the same
Here is part of code:
Main.py
`import datetime
import discord
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions
from client import client
from fun import ocena
from moderation import delete, usun_kanal, dodaj_kanal
from spaming import ghost, spam, stop, spam_error
@client.command()
async def pfp(ctx, *, avamember: str = None):
if avamember is None:
await ctx.send("Musisz oznaczyć użytkownika!")
return
try:
avamember = await commands.MemberConverter().convert(ctx, avamember)
except commands.MemberNotFound:
await ctx.send("Nie mogłem znaleźć tego użytkownika!")
return
user_avatar_url = avamember.display_avatar.url
await ctx.send(f"**Awatar użytkownika** {avamember.name}: {user_avatar_url}")
@client.command()
async def ocenka(ctx):
.......
@client.event
async def on_command_error(ctx, error):
if ctx.message.content.count('.') <= 1:
if isinstance(error, commands.CommandNotFound):
await ctx.send("Podano złą komende! ⚠️")
@client.event
async def on_message(message):
if client.user.mentioned_in(message):
await message.channel.send("Witaj! Aby zobaczyć liste moich komend wpisz `.help `! ")
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle,
activity=discord.Game(name="Wpisz .help by zobaczyć co mogę dla ciebie zrobić!"))
print('------------------------------')
print('Pomyślnie zalogowano jako:')
print("Nazwa bota:", client.user.name)
print("Id bota:", client.user.id)
print("Bot został uruchomiony", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
print('------------------------------')
client.run(`yk`)
client.py
import discord
from discord.ext import commands
intents = discord.Intents.all()
client = commands.Bot(command_prefix='.',intents=intents)
tree = client.tree
client.remove_command('help')
Rest of files are commands but pattern is basicly the same
from command import command
@client.command()
async def command(ctx):
await command(ctx)
I have twice @client.command() for command
First in main.py :
@client.command
async def delete(ctx, name):
await delete(ctx, name)
Second in command.py:
@client.command()
@has_permissions(manage_messages=True)
async def delete(ctx, count):
try:
count = int(count)
if (count < 0):
await ctx.send("wrong number")
return
except ValueError:
await ctx.send("error")
else:
await ctx.send(f"{count} messages")
deleted_messages = await ctx.channel.purge(limit=count + 1)
I save this “method” or “schema” on some old youtube tutorial so i decided to do the same
ready for down arrows ????
Kamil Konieczny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.