0
    import disnake
import os
from disnake.ext import commands
import json

def get_server_prefix(bot, message):
    with open("prefix.json", "r") as f:
            prefix = json.load(f)

    return prefix[str(message.guild.id)]



bot = commands.Bot(command_prefix=get_server_prefix, help_command=None, intents=disnake.Intents.all())
bot.remove_command('help')


@bot.event
async def on_ready():
  print(f"Бот {bot.user} работает!")
  activity = disnake.Activity(type=disnake.ActivityType.listening, name=F"...")
  await bot.change_presence(status=disnake.Status.do_not_disturb, activity=activity)
        
@bot.event
async def on_guild_join(guild):
    with open("prefix.json", "r") as f:
            prefix = json.load(f)
    
    prefix[str(guild.id)] = "bt."

    with open("prefix.json", "w") as f:
          json.dump(prefix, f, indent=4)

@bot.event
async def on_guild_remove(guild):
    with open("prefix.json", "r") as f:
            prefix = json.load(f)
    
    prefix.pop(str(guild.id))

    with open("prefix.json", "w") as f:
          json.dump(prefix, f, indent=4)

     

@bot.command(administrator=True)
async def load(ctx, extension):
    extension = extension.lower()
    bot.load_extension(f'cogs.{extension}')
    await ctx.send(f'{extension} загружен')


@bot.command(administrator=True)
async def unload(ctx, extension):
    extension = extension.lower()
    bot.unload_extension(f'cogs.{extension}')
    await ctx.send(f'{extension} отгружен')

@bot.command(administrator=True)
async def reload(ctx, extension):
    extension = extension.lower()
    bot.unload_extension(f'cogs.{extension}')
    bot.load_extension( f'cogs.{extension}' )
    await ctx.send(f'**{extension}** **перезагружен**')


for fn in os.listdir('./cogs'):
  if fn.endswith('.py'):
    bot.load_extension(f"cogs.{fn[:-3]}")
                
TOKEN = "..."

bot.run(TOKEN)

Ошибка(в письменном виде не вставилась)

2
  • А что у вас в файле, может он пустой? Если нет, попробуйте указать кодировку при открытии файла.
    – CrazyElf
    23 мар в 11:22
  • у меня он не был пустым, просто я не сохранил его)) Спасибо! 23 мар в 18:57

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Посмотрите другие вопросы с метками или задайте свой вопрос.