Creating a Support Ticket System with Discord Bot DMs

I need help building a Discord bot that can handle support requests through private messages. The bot should work like this:

When someone sends a DM with commands like “.support” or “.ticket”, the bot checks if a channel already exists with that user’s ID as the name. If no channel exists, it creates a new one using their Discord ID as the channel name to avoid duplicate requests.

Once the channel is created, the bot should ping all support staff members in that channel and then delete the ping message after a short delay.

For the messaging system, when support staff write in the user’s channel, the bot should forward their message to the user via DM. The message should include the staff member’s name, tag, and role. When the user replies in DMs, the bot should check if their support channel still exists and forward their message there with their username.

I also want a command like “.closeticket” that support staff can use to delete the channel after a brief countdown.

The goal is to make this work without needing databases or persistent storage. Can someone share example code for implementing this kind of ticket system?

Built something very similar last year and ran into several issues you should know about. The channel naming approach works but Discord has strict limits on channel creation rate - you’ll hit the API limit fast if multiple users request tickets simultaneously. I added a queue system to handle this properly. For the message forwarding, you absolutely need to handle cases where the user blocks the bot or disables DMs after creating a ticket, otherwise your support staff will be talking to a wall. Also worth mentioning that without persistent storage, if your bot goes down during active tickets, the user-channel relationships are lost and you end up with orphaned channels. I recommend adding a startup routine that scans existing channels and attempts to rebuild the mappings based on channel names. The ping deletion timing needs careful consideration too - make it long enough for staff to see but short enough to keep channels clean.

Been running a similar setup for about 6 months now and it works pretty well without databases. The key challenge you’ll face is maintaining the user-channel mapping since you’re avoiding persistent storage. I handle this by using a simple dictionary that maps user IDs to channel IDs, which gets rebuilt on bot restart by scanning existing channels. For the messaging relay, make sure to add error handling for when users have DMs disabled or leave the server. I learned this the hard way when messages started failing silently. Also consider adding a cooldown on ticket creation to prevent spam - some users will keep creating tickets if they don’t get immediate responses. One gotcha with the ping deletion: use asyncio.sleep() instead of time.sleep() to avoid blocking the bot during the delay. The countdown for ticket closure is nice for accidental closures but make sure only staff with proper permissions can use it.

honestly this sounds overly complicated without a database. why not just use discord’s built-in thread feature? you could create a thread in your support channel when someone dms the bot, much simpler than managing channel creation/deletion. threads auto-archive after inactivity too so less cleanup needed. just my 2 cents but avoiding persistent storage will bite you later when the bot restarts and forgets everything