# Copyright 2022 Michael Hall # LICENSE: Apache License, Version 2.0 : http://www.apache.org/licenses/LICENSE-2.0 from __future__ import annotations import discord import pathlib import random from discord import app_commands class Client(discord.Client): def __init__(self, *, intents: discord.Intents): super().__init__(intents=intents) self.tree = app_commands.CommandTree(self) async def setup_hook(self): f = (Path.cwd() / __file__).with_name("has.sync") if not f.exists(): await self.tree.sync() f.touch() client = Client(intents=discord.Intents.none()) @client.tree.command() async def coinflip(interaction: discord.Interaction): """Flip a coin.""" await interaction.response.send_message(random.choice(("Heads", "Tails")) if __name__ == "__main__": # If you are sharing this file with anyone, remove the token first. client.run("Token goes here")