trying direct sync slash command
This commit is contained in:
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
import discord
|
import discord
|
||||||
from typing import Any
|
|
||||||
from core.bot import bot, server_repo, channel_repo, home_debt_repo
|
from core.bot import bot, server_repo, channel_repo, home_debt_repo
|
||||||
|
|
||||||
|
@discord.app_commands.guilds(discord.Object(id=536422615649091595))
|
||||||
@bot.tree.command(name='set-home-debt', description='Set channel to home debt')
|
@bot.tree.command(name='set-home-debt', description='Set channel to home debt')
|
||||||
async def set_home_debt(interaction: discord.Interaction, channel: discord.TextChannel):
|
async def set_home_debt(interaction: discord.Interaction, channel: discord.TextChannel):
|
||||||
try:
|
try:
|
||||||
@@ -55,6 +55,7 @@ async def home_debt_add(interaction: discord.Interaction, amount: float, descrip
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
await interaction.response.send_message(f"Có lỗi xảy ra: {str(e)}", ephemeral=True)
|
await interaction.response.send_message(f"Có lỗi xảy ra: {str(e)}", ephemeral=True)
|
||||||
|
|
||||||
|
@discord.app_commands.guilds(discord.Object(id=536422615649091595))
|
||||||
@bot.tree.command(name="home-debt-check", description="Kiểm tra số dư của bạn")
|
@bot.tree.command(name="home-debt-check", description="Kiểm tra số dư của bạn")
|
||||||
async def home_debt_check(interaction: discord.Interaction):
|
async def home_debt_check(interaction: discord.Interaction):
|
||||||
"""Kiểm tra số dư của mọi người"""
|
"""Kiểm tra số dư của mọi người"""
|
||||||
@@ -65,6 +66,7 @@ async def home_debt_check(interaction: discord.Interaction):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
await interaction.response.send_message(f"Có lỗi xảy ra: {str(e)}", ephemeral=True)
|
await interaction.response.send_message(f"Có lỗi xảy ra: {str(e)}", ephemeral=True)
|
||||||
|
|
||||||
|
@discord.app_commands.guilds(discord.Object(id=536422615649091595))
|
||||||
@bot.tree.command(name="vay-debt", description="Vay nợ")
|
@bot.tree.command(name="vay-debt", description="Vay nợ")
|
||||||
async def vay_debt(interaction: discord.Interaction, amount: float, description: str):
|
async def vay_debt(interaction: discord.Interaction, amount: float, description: str):
|
||||||
"""Vay nợ"""
|
"""Vay nợ"""
|
||||||
@@ -79,6 +81,7 @@ async def vay_debt(interaction: discord.Interaction, amount: float, description:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
await interaction.response.send_message(f"Có lỗi xảy ra: {str(e)}", ephemeral=True)
|
await interaction.response.send_message(f"Có lỗi xảy ra: {str(e)}", ephemeral=True)
|
||||||
|
|
||||||
|
@discord.app_commands.guilds(discord.Object(id=536422615649091595))
|
||||||
@bot.tree.command(name="tra-debt", description="Trả nợ")
|
@bot.tree.command(name="tra-debt", description="Trả nợ")
|
||||||
async def tra_debt(interaction: discord.Interaction, amount: float):
|
async def tra_debt(interaction: discord.Interaction, amount: float):
|
||||||
"""Trả nợ"""
|
"""Trả nợ"""
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
|
import discord
|
||||||
from core.bot import bot
|
from core.bot import bot
|
||||||
from core.tasks import sync_commands
|
from core.tasks import sync_commands
|
||||||
|
|
||||||
|
# Using for sync commands to all guilds
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f'{bot.user} đã tham gia vào server!')
|
print(f'{bot.user} đã tham gia vào server!')
|
||||||
await sync_commands.start()
|
await sync_commands.start()
|
||||||
print("Đã đồng bộ lệnh!")
|
print("Đã đồng bộ lệnh!")
|
||||||
|
|
||||||
|
# @bot.event
|
||||||
|
# async def on_ready():
|
||||||
|
# guild_id = 536422615649091595
|
||||||
|
# guild_obj = discord.Object(id=guild_id)
|
||||||
|
|
||||||
|
# try:
|
||||||
|
# synced = await bot.tree.sync(guild=guild_obj)
|
||||||
|
# print(f"🔁 Synced {len(synced)} command(s) to guild {guild_id}")
|
||||||
|
# except Exception as e:
|
||||||
|
# print(f"❌ Failed to sync commands to guild {guild_id}: {e}")
|
||||||
Reference in New Issue
Block a user