import os
import discord
from typing import Any
from nextcord.ext import commands
import nextcord
from discord import Member, utils
from discord.utils import get
from imgay import TOKEN
client = commands.AutoShardedBot(command_prefix = "t", intents = nextcord.Intents.default())
client.remove_command("help")
@client.event
async def on_ready():
print(f"запущен )")
for filename in os.listdir("./cogs"):
if filename.endswith (".py"):
client.load_extension (f"cogs.{filename[:-3]}")
client.run(TOKEN)
Выдал Debug :
Возникло исключение: ExtensionFailed
Extension 'cogs.Moderation' raised an error: ClientException: Cog named 'CogName' already loaded
File "C:\Users\maty2go\Desktop\Discord bot\cogs\Moderation.py", line 88, in setup
client.add_cog(CogName(client))
The above exception was the direct cause of the following exception:
File "C:\Users\maty2go\Desktop\Discord bot\main.py", line 23, in
client.load_extension (f"cogs.{filename[:-3]}")
Коги :
Ambulance.py :
import asyncio
import nextcord
import discord
import time
import os
import disnake
import typing
from re import S
from http import client
from pickle import FALSE
from asyncore import loop
from tracemalloc import stop
from setuptools import Command
from nextcord.ext import commands
from multiprocessing.connection import Client, wait
from nextcord.ext.commands import has_permissions, CheckFailure
bot = commands.bot
timi = str(0.8)
class CogName(commands.Cog):
def __init__(self, client):
self.client = client
self._last_member = None
@commands.command("boom")
async def boom(self, ctx):
if ctx.author.id == 962339486220558416:
global flood_flag
flood_flag=True
while flood_flag:
await ctx.send("@everyone")
await asyncio.sleep(timi)
else:
embed=nextcord.Embed(title= "**Аахахах, не не не ))** " , description="Теье низя так делать )\nКак ты вообще нашел это ? ", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
@commands.command("calm")
async def calm(self, ctx):
if ctx.author.id == 962339486220558416:
global flood_flag
flood_flag=False
else:
embed=nextcord.Embed(title= "**Аахахах, не не не ))** " , description="Теье низя так делать )\nКак ты вообще нашел это ? ", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
def setup(client):
client.add_cog(CogName(client))
Moderation.py :
import asyncio
import nextcord
import discord
import time
import os
import disnake
import typing
from re import S
from http import client
from pickle import FALSE
from asyncore import loop
from tracemalloc import stop
from setuptools import Command
from nextcord.ext import commands
from multiprocessing.connection import Client, wait
from nextcord.ext.commands import has_permissions, CheckFailure
bot = commands.bot
class CogName(commands.Cog):
def __init__(self, client):
self.client = client
self._last_member = None
@commands.command(aliases=["b"])
@has_permissions(ban_members=True)
async def ban(self, ctx, user: nextcord.Member = None, *, Reason = None):
if ctx.author.id == 962339486220558416:
if user == None:
embed=nextcord.Embed(title= " " , description="Could you please enter utka ?", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
return
try:
await user.ban(reason=Reason)
embed=nextcord.Embed(title= " " , description=f'**{user}** has been banned.'.format(str(user)), color=nextcord.Colour.random())
await ctx.reply(embed=embed)
except Exception as error:
if isinstance(error, CheckFailure):
embed=nextcord.Embed(title= " " , description="Looks like you don't have the permissions to use this command.", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
else:
embed=nextcord.Embed(title= " " , description=error, color=nextcord.Colour.random())
await ctx.reply(embed=embed)
else:
embed=nextcord.Embed(title= "**Аахахах, не не не ))** " , description=" ", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
@commands.command(aliases=["k"])
@has_permissions(kick_members=True)
async def kick(self, ctx, user: nextcord.Member = None, *, Reason = None):
if ctx.author.id == 962339486220558416:
if user == None:
embed=nextcord.Embed(title= " " , description="Could you please enter utka ?", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
return
try:
await user.kick(reason=Reason)
embed=nextcord.Embed(title= " " , description=f'**{user}** has been kicked.'.format(str(user)), color=nextcord.Colour.random())
await ctx.reply(embed=embed)
except Exception as error:
if isinstance(error, CheckFailure):
embed=nextcord.Embed(title= " " , description="Looks like you don't have the permissions to use this command.", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
else:
embed=nextcord.Embed(title= " " , description=error, color=nextcord.Colour.random())
await ctx.reply(embed=embed)
else:
embed=nextcord.Embed(title= "**Аахахах, не не не ))** " , description=" ", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
@commands.command(aliases=["bid"])
@has_permissions(ban_members=True)
async def banid(self, ctx, user: typing.Union[nextcord.User, int], *, reason=None):
if ctx.author.id == 962339486220558416:
if isinstance(user, int):
user = nextcord.Object(user)
try:
await user.ban(user, reason=reason)
except client.NOT_FOUND:
embed=nextcord.Embed(title= " " , description=f"Та я хз кто это... {user.id}", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
else:
embed=nextcord.Embed(title= "**Аахахах, не не не ))** " , description=" ", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
def setup(client):
client.add_cog(CogName(client))
Starter_com.py :
import asyncio
import nextcord
import discord
import time
import os
import disnake
import typing
from re import S
from http import client
from pickle import FALSE
from asyncore import loop
from tracemalloc import stop
from setuptools import Command
from nextcord.ext import commands
from multiprocessing.connection import Client, wait
from nextcord.ext.commands import has_permissions, CheckFailure
timi = str(1)
class CogName(commands.Cog):
def __init__(self, client):
self.client = client
self._last_member = None
@commands.command("h")
async def h(self, ctx):
embed=nextcord.Embed(title= " " , description="h - This message\nUse - th, thelp\n\nhello - saying hello to you\nUse - thello\n\nbye - saying bye to you\nUse - tbye", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
@commands.command("hello")
async def hello(self, ctx):
if ctx.author.id == 962339486220558416:
embed=nextcord.Embed(title= " " , description="Welcome my lord.", color=nextcord.Colour.random())
else:
embed=nextcord.Embed(title= " " , description="Hi bitch", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
@commands.command("bye")
async def bye(self, ctx):
if ctx.author.id == 962339486220558416:
embed=nextcord.Embed(title= " " , description="Happy Travel.", color=nextcord.Colour.random())
else:
embed=nextcord.Embed(title= " " , description="Bye bitch", color=nextcord.Colour.random())
await ctx.reply(embed=embed)
def setup(client):
client.add_cog(CogName(client))
я не знаю что с ним делать. все коги разные в них никаких ошибок нет.