Направих си бота,обаче ся като го адна във друг сървър ми изписва грешки
ето какви
Грешката:
Код за потвърждение: Избери целия код
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
====== RESTART: C:\Users\User\Desktop\Stuff\discord bot\ресурси\rockbot.py =====
bot is ready.
Ignoring exception in command clear:
Traceback (most recent call last):
File "D:\porgrams\Python\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Stuff\discord bot\ресурси\rockbot.py", line 24, in clear
await ctx.channel.purge(limit=amount)
AttributeError: 'DMChannel' object has no attribute 'purge'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\porgrams\Python\lib\site-packages\discord\ext\commands\bot.py", line 863, in invoke
await ctx.command.invoke(ctx)
File "D:\porgrams\Python\lib\site-packages\discord\ext\commands\core.py", line 728, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "D:\porgrams\Python\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'DMChannel' object has no attribute 'purge'
EDIT:
Грешката е излизала защото съм писал командата .cleat на PM в дискорд
Кода на бота
Код за потвърждение: Избери целия код
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print('bot is ready.')
@client.event
async def on_member_join(member):
print(f'(member) has joined a server.')
@client.event
async def on_member_removed(member):
print(f'(member) has left a server.')
@client.command()
async def rock(ctx):
await ctx.send('n roll!')
@client.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount)
@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
client.run('API')
И май от тука по някв начин би тряло да се добаваят команди да се фиксне грешката
https://discordpy.readthedocs.io/en/lat ... guild_only
Но сега гледам че бота ми не е онлайн във други сървъри