#Application Command raised an exception KeyError 1043936305127632927
1 messages · Page 1 of 1 (latest)
welcome command code:
@client.slash_command(description="Sets the welcome channel and message")
@commands.has_permissions(manage_guild=True)
async def welcome(ctx,ch: discord.TextChannel=None, *, msg=None):
if ch==None: ch=ctx.channel
if msg=="default": msg=default_welcome
if ctx.guild.id not in settings: settings[ctx.guild.id] = {}
if 'welcome' in settings[ctx.guild.id]:
settings[ctx.guild.id]['welcome'][0]=ch.id
if msg: settings[ctx.guild.id]['welcome'][1]=msg
else:
if msg==None: msg=default_welcome
settings[ctx.guild.id]['welcome'] = [ch.id, msg]
db.set('settings', str(settings))
await ctx.respond(f"**:yes: Set the Welcome Channel to {ch.mention}**")
@welcome.error
async def welcome_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.respond(f"**:no: {error}**")
return
args = ctx.message.content.lower().split()
if len(args)>1 and args[1]=="disable":
await ctx.respond(f"**:yes: Disabled the welcome message**")
del settings[ctx.guild.id]['welcome']
db.set('settings', str(settings))
else:
await ctx.respond(f"**:no: {error}**")
What error? You didn't show any errors
are you sure 1 line if statements work that way?
The error in the title is all the error I get
Yeah, I tried removing the 1st line
but it still shows the same error
https://0-o.pl/9kCyE9MW Application Command raised an exception: KeyError: {GuildID}
I tried console logging the error but I get the same result
I've had this issue for a while now
Any idea why this happens?
This means that the key of your guild_id doesn't exist in the settings dictionary
Very basic python error
do you not have the actual console logging of your bot? would make diagnosing these kinds of errors much easier
Must be some sort of error handler blocking it from showing up
Did you mean the DB?
@welcome.error
async def welcome_error(ctx, error):
print(error)
await ctx.respond(f"**:no: {error}**", ephemeral=True)
I use this to get errors
Whenever I try using
except Exception as e:
print(e)```
It prints our the guild ID
Ohhh, I get it,
I understand the issue now,
If the guild ID doesn't exist in the settings DB it will return this error instead of creating it on the DB
Thank you so much Colin,
I have finally resolved the issue, I've had this issue for a while now. It's now finally fixed, thank you so much again!