import discord import yaml import datetime from discord_slash import SlashContext, SlashCommand from discord.ext.commands import Bot from models.user import User with open("config.yaml", "r") as yamlfile: config = yaml.load(yamlfile, Loader=yaml.CLoader) print("Read config successful") config = config intents = discord.Intents.default() intents.members = True bot = Bot(command_prefix="!", self_bot=True, intents=intents) slash = SlashCommand(bot, sync_commands=True) # Runs once bot has connected to discord @bot.event async def on_ready(): time_now = datetime.datetime.utcnow() print(f"{time_now}: {bot.user} has connected to Discord!") for guild in bot.guilds: if guild.id == config["discord_server_id"]: print(f"{time_now}: {bot.user} has joined {guild.name}!") for channel in guild.channels: if channel.name == config["discord_channel"]: print(f"{time_now}: Found channel {channel.name}!") @bot.event async def on_message(message): print(message.author.id) user = User.get(User.discord_id == message.author.id) user.add_message() print(user.display_name) @slash.slash( name="test", description="This is just a test command, nothing more.", guild_ids=[config["discord_server_id"]], ) async def test(ctx: SlashContext): print("test") await ctx.send(content="Beep boop") bot.load_extension("commands.economy") bot.load_extension("commands.basic_games") bot.run(config["discord_token"])