import discord import yaml import datetime from discord_slash import SlashContext, SlashCommand from discord.ext.commands import Bot from models.user import User from exp import Exp 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) bot_channel = None # 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_channel = channel @bot.event async def on_message(message): print(message.author.id) user = User.get(User.discord_id == message.author.id) exp = Exp(user, message.channel) await exp.calculate_exp() @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.load_extension("commands.rank") bot.load_extension("commands.shop") bot.load_extension("commands.inventory") bot.run(config["discord_token"])