Something went wrong. Try again.
A discord bot. www.aesth.lol/byte
discord-bot bot fun discord
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364# thanks to https://github.com/imptype/BasicBot/tree/main for the example code this is forked fromimport osimport asyncioimport datetimeimport tracebackimport contextlibimport aiohttpimport discohookfrom starlette.responses import JSONResponsefrom cogs.utils import ping_command, timestamp_command, info_commandfrom cogs.fun import decide_command, funfact_cmd, randomgif_cmdfrom cogs.games import rps_command, gtn_commandfrom cogs.dice import dice_command, old_dice_command
def run(): @contextlib.asynccontextmanager async def lifespan(app): try: yield finally: if app.http.session: await app.http.session.close()
app = discohook.Client( application_id = os.getenv('DISCORD_APPLICATION_ID'), public_key = os.getenv('DISCORD_PUBLIC_KEY'), token = os.getenv('DISCORD_BOT_TOKEN'), password = os.getenv('SYNC_PASSWORD'), lifespan = lifespan )
error_log_webhook = discohook.PartialWebhook.from_url(app, os.getenv('ERROR_LOG_WEBHOOK')) @app.on_interaction_error() async def on_error(interaction, error): trace = tuple(traceback.TracebackException.from_exception(error).format()) text = ''.join(trace) print(text) if interaction.responded: await interaction.response.followup('An error occured in a followup message... ') else: await interaction.response.send('An error occured...') await error_log_webhook.send(text[:2000])
app.started_at = datetime.datetime.now(datetime.timezone.utc)
app.add_commands( ### --- Cog: Utils --- ### ping_command, timestamp_command, info_command, ### --- Cog: Fun --- ### decide_command, funfact_cmd, randomgif_cmd, ### --- Cog: Games --- ### rps_command, gtn_command, ### --- Cog: Dice --- ### dice_command, old_dice_command, ) return app
app = run()