#Discord Bot stops working after nearly 5 hours
1 messages · Page 1 of 1 (latest)
What hosting are you using?
How is it not reacting to commands
Selfhosted on root server
just showing No
2
Are they slash commands
Just showing the discord red error message
Do you have tasks or not async commands?
Yes but nothing works
bot=discord.Bot(intents=intents, activity=discord.Activity(type=discord.ActivityType.watching,name="")) If you mean this
And what's the code for your slash command
Like i said nothing works no buttons but the code is @bot.slash_command(guild_ids=[guildid],name="verwarnen",description="""Verwarnt einen User""")
`@bot.slash_command(guild_ids=[guildid],name="verwarnen",description="""Verwarnt einen User""")
@commands.has_permissions(kick_members = True)
async def verwarnen(ctx, member: Option(discord.Member, description= "Wen möchtest du verwarnen?",ephemeral=True), reason: Option(str, description= "Grund",ephemeral=True, required = True)):
mycursor = mydb.cursor()
id = member.id
sql = 'INSERT INTO warnings (name, id, time, reason) VALUES ("' + str(member.name) + '", "' + str(id) + '", "' + str(int(time.time())) + '"' + ', "' + str(reason) + '")'
mycursor.execute(sql)
mydb.commit()
sql = "SELECT reason FROM warnings WHERE EXISTS (SELECT id FROM warnings WHERE id = " + str(member.id) + ")"
mycursor.execute(sql)
myresult = mycursor.fetchall()
counter = 0
for item in myresult:
#Incrementing counter variable to get each item in the list
counter = counter + 1
view = KickView(member, reason)
#await ctx.send(f"Are you sure you want to kick {member.name}?", view=view)
await ctx.respond("der " + str(counter) + ". Verstoß", view=view, ephemeral=True)
embed=discord.Embed(title="Verwarnung", description=member.mention + "\nHiermit wirst du aus folgendem Grund zum " + str(counter) + ". mal verwarnt: \n" + reason, color=0xff0000)
if counter == 1:
embed.set_footer(text="Bitte halte dich an unsere Serverregeln und pflege einen respektvollen und gewaltfreien Umgang mit den anderen Usern.")
elif counter == 2:
embed.set_footer(text="Noch so´n Ding, Augenring!")
elif counter >= 3 :
embed.set_footer(text="Noch so´n Spruch, Kieferbruch!")
await member.send(embed=embed)`
there are more shlash commands but buttons and other stuff isnt working either and after a restart everything is working again
- You're taking too long to send a response
- You are not sending a response
use await ctx.defer() at the start of your callback
And then use ctx.respond to respond, not ctx.send
and with buttons and so the same?
Deferring depends on how long you'll take to respond
You don't defer just because
If you think and assume you'll take more than 3 seconds to respond, then you defer
ok but why is it so that when the bot starts everything is working but after hours it 'stops'?
The only different thing with buttons (or views generally), is that you use interaction.response.defer() and respond with interaction.folloup.send() instead
?
And thank you for the quick response 😀
I assume that's a problem with your hosting
ok so when you use defer my responding message isn't ephemeral anymore
You need to also tell the defer function you'll respond ephemeral too
so defer(ephemeral=True) ???
Indeed