#how can I make a @tree.command working only on a specific guild id?

17 messages · Page 1 of 1 (latest)

nocturne fiber
#

?

spark galleon
#

from discord.ext import commands

bot = commands.Bot(command_prefix='!')

def guild_check(guild_id):
async def predicate(ctx):
return ctx.guild and ctx.guild.id == guild_id
return commands.check(predicate)

@guild_check(1234567890) # Replace with your specific guild ID
@bot.group()
async def tree(ctx):
if ctx.invoked_subcommand is None:
await ctx.send('Invalid tree command.')

@tree.command()
async def add(ctx, value):
# Logic for the add command
await ctx.send(f'Adding {value} to the tree.')

@tree.command()
async def remove(ctx, value):
# Logic for the remove command
await ctx.send(f'Removing {value} from the tree.')

bot.run('YOUR_BOT_TOKEN')`

nocturne fiber
#

@spark galleon I tried but it didn’t work

#

@spark galleon

spark galleon
#

Do you have any errors?

nocturne fiber
#

D

#

@spark galleon

#

Bruh

#

@spark galleon help plz

spark galleon
nocturne fiber
#

U don’t get errors

#

But it runs

#

It doesn’t work

#

@spark galleon

#

That’s why I ask you