I’m having trouble with my Discord bot running on a friend’s Raspberry Pi VPS. It starts fine and responds to commands for about 5 minutes. Then it stops working properly. When I click the green button, Discord shows “Interaction Failed”. If I send the command again, it works and keeps the user ID in the sign-in dictionary. But after another 5 minutes, the same issue happens.
The bot isn’t completely stopping, but something’s not right. Could this be a code issue or a VPS problem? Here’s a simplified version of my code:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', intents=discord.Intents.default())
registrations = {}
@bot.command()
async def signup(ctx):
button = discord.ui.Button(label='Register', style=discord.ButtonStyle.green)
async def button_click(interaction):
if interaction.user.id in registrations:
await interaction.response.send_message('Already registered', ephemeral=True)
return
await interaction.response.send_modal(RegistrationForm())
button.callback = button_click
view = discord.ui.View()
view.add_item(button)
await ctx.send('Click to register', view=view)
class RegistrationForm(discord.ui.Modal):
def __init__(self):
super().__init__(title='Registration Form')
self.name = discord.ui.TextInput(label='Name')
self.add_item(self.name)
async def on_submit(self, interaction):
registrations[interaction.user.id] = {'name': self.name.value}
await interaction.response.send_message('Registration complete!', ephemeral=True)
bot.run('YOUR_TOKEN_HERE')
Any ideas on what might be causing this intermittent issue?