by Guest » 04 Feb 2025, 12:49
Hallo, ich mache Bot für Ereignisse in SCP Sl ive, hatte Probleme, einfache Befehl zu erstellen, um zu rollen
Heres meinen Code < /p>
Code: Select all
import discord
from discord import app_commands
import traceback
import discord.ui
TOKEN = 'i deleted token for this topic'
PREFIX = '/'
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
@client.event
async def on_ready():
game = discord.Game(name="Работа на благо ивентов!")
await client.change_presence(status=discord.Status.do_not_disturb, activity=game)
await tree.sync(guild=discord.Object(id=1282201922434105435))
print("Ready!")
chnl = await client.fetch_channel(1282328133667917947)
await chnl.send("1")
@tree.command(name="spacethaumiel-register-acc", description="222-1---222-22-1", guild=discord.Object(id=1282201922434105435))
async def reg(ctx: discord.Interaction):
# r = ctx.guild.get_role("1292398370085797951")
role = discord.utils.get(ctx.guild.roles, id="1292398370085797951")
try:
await ctx.user.add_roles(role)
await ctx.response.send_message("успешно")
except:
print("Возникла ошибка")
client.run(TOKEN)
Ich wollte in der Reg -Funktion den Befehl rollenabgeben, aber es wirft einfach aus und Ausnahme
Hallo, ich mache Bot für Ereignisse in SCP Sl ive, hatte Probleme, einfache Befehl zu erstellen, um zu rollen
Heres meinen Code < /p>
[code]import discord
from discord import app_commands
import traceback
import discord.ui
TOKEN = 'i deleted token for this topic'
PREFIX = '/'
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
@client.event
async def on_ready():
game = discord.Game(name="Работа на благо ивентов!")
await client.change_presence(status=discord.Status.do_not_disturb, activity=game)
await tree.sync(guild=discord.Object(id=1282201922434105435))
print("Ready!")
chnl = await client.fetch_channel(1282328133667917947)
await chnl.send("1")
@tree.command(name="spacethaumiel-register-acc", description="222-1---222-22-1", guild=discord.Object(id=1282201922434105435))
async def reg(ctx: discord.Interaction):
# r = ctx.guild.get_role("1292398370085797951")
role = discord.utils.get(ctx.guild.roles, id="1292398370085797951")
try:
await ctx.user.add_roles(role)
await ctx.response.send_message("успешно")
except:
print("Возникла ошибка")
client.run(TOKEN)
[/code]
Ich wollte in der Reg -Funktion den Befehl rollenabgeben, aber es wirft einfach aus und Ausnahme