I’m super new to programming and wanted to make a simple bot that could roll dice and stuff with everything I’ve already learnt. The bot usually works fine, but I encounter 429s every few weeks randomly. Any help on how I could prevent this from happening would be super appreciated.
from keep_alive import keep_alive from discord.ext import commands import os import random client = commands.Bot(command_prefix='/') @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) @client.command(aliases=['r']) async def roll(ctx, amount=69): n1 = random.randint(1, amount) await ctx.send('{} rolled a **{}**!'.format((ctx.author.mention), n1)) if n1 == 69: await ctx.send(':clap:') if n1 == 420: await ctx.send('holy shit') @client.command() async def choose(ctx, *, ctx1): try: ctx1 = ctx1.replace(';', ',') ctx1 = ctx1.replace('|', ',') s1 = ctx1.split(',') await ctx.send('I choose **{}**!'.format(random.choice(s1))) except: await ctx.send('Error') client.run(os.getenv('TOKEN'))