Не появляются команды на сервере nextcord
Написал маленького бота для сервера друзей, на тестовом всё работало - при запуске скрипта и написании "/" выводился список доступных команд, при переходе на новый аккаунт бота и новый сервер команды просто не появляются
import nextcord
from nextcord.ext import commands
from nextcord import ButtonStyle
from nextcord.ui import Button, View
import json
from os import path
with open(path.abspath("Discord_vailage\\embed_save.json"), "r") as my_file:
embed_save = json.load(my_file)
clr = nextcord.Colour.fuchsia()
my_ds_server = 952213316187590658
chat_id = 983289704516558898
mbd = nextcord.Embed(color=clr, title="Задачи в деревне:")
bot = commands.Bot()
msg = None
@bot.event
async def on_ready():
print(f'We have logged in as {bot.user}')
channel = bot.get_channel(chat_id)
if len(embed_save) != 0:
for i in embed_save:
embed_now = embed_save[i]
mbd.add_field(name=embed_now["name"], value=f"{embed_now['description']}\n{embed_now['cords']}")
global msg
msg = await channel.send(content="Задачи не обязательно выполнять, но так всем будет легче, кста если вы хотите добавить задачу - напишите кому-то из админов",embed=mbd)
@bot.slash_command(name="new", description="Добавить новую задачу", guild_ids=[my_ds_server])
async def hello(interaction: nextcord.Interaction, name: str, description: str, cords: str):
mbd.add_field(name=name, value=f"{description}\n{cords}")
global embed_save
embed_save[f"embed{len(embed_save) + 1}"] = {"name": name, "description": description, "cords": cords}
with open(path.abspath("Discord_vailage\\embed_save.json"), "w") as my_file:
json.dump(embed_save, my_file)
await msg.edit(content="Задачи не обязательно выполнять, но так всем будет легче, кста если вы хотите добавить задачу - напишите кому-то из админов",embed=mbd)
await interaction.send(content="Done!", delete_after=5)
@bot.slash_command(name="delete", description="Удалить одну из задач", guild_ids=[my_ds_server])
async def delete(interaction: nextcord.Interaction, name: str):
if len(embed_save) == 0:
await interaction.send(content="Задач в деревне нет, сначала нужно добавить", delete_after=5)
else:
for i in embed_save:
embed_now = embed_save[i]
if embed_now["name"] == name:
embed_save.pop(i)
with open(path.abspath("Discord_vailage\\embed_save.json"), "w") as my_file:
json.dump(embed_save, my_file)
await interaction.send(content="Удалено!", delete_after=5)
mbd = nextcord.Embed(color=clr, title="Задачи в деревне:")
channel = bot.get_channel(chat_id)
if len(embed_save) != 0:
for i in embed_save:
embed_now = embed_save[i]
mbd.add_field(name=embed_now["name"], value=f"{embed_now['description']}\n{embed_now['cords']}")
global msg
await msg.edit(content="Задачи не обязательно выполнять, но так всем будет легче, кста если вы хотите добавить задачу - напишите кому-то из админов",embed=mbd)
else:
await interaction.send(content='Задач не найдено, бля не тупи - имя просто "ctr + c" и "ctrl + v"', delete_after=5)
@bot.slash_command(name="change_color", description="Ну цвет изменить...", guild_ids=[my_ds_server])
async def change_color(interaction: nextcord.Interaction):
green = Button(label="Green", style=ButtonStyle.blurple)
red = Button(label="Red", style=ButtonStyle.blurple)
purple = Button(label="Purple", style=ButtonStyle.blurple)
fuchsia = Button(label="fuchsia", style=ButtonStyle.blurple)
async def add_green(ctx):
global clr
clr = nextcord.Colour.green()
await color_fin()
green.callback = add_green
async def add_red(ctx):
global clr
clr = nextcord.Colour.red()
await color_fin()
red.callback = add_red
async def add_purple(ctx):
global clr
clr = nextcord.Colour.purple()
await color_fin()
purple.callback = add_purple
async def add_fuchsia(ctx):
global clr
clr = nextcord.Colour.fuchsia()
await color_fin()
async def color_fin():
mbd = nextcord.Embed(color=clr, title="Задачи в деревне:")
for i in embed_save:
embed_now = embed_save[i]
mbd.add_field(name=embed_now["name"], value=f"{embed_now['description']}\n{embed_now['cords']}")
await msg.edit(content="Задачи не обязательно выполнять, но так всем будет легче, кста если вы хотите добавить задачу - напишите кому-то из админов",embed=mbd)
await msg_to_delete.delete()
fuchsia.callback = add_fuchsia
myview = View(timeout=20)
myview.add_item(green)
myview.add_item(red)
myview.add_item(purple)
myview.add_item(fuchsia)
msg_to_delete = await interaction.send("Какой цвет поставить?: ",view=myview, )
bot.run(TOKEN)
(Токен естественно стоит)