from config import config from lib import * import discord import logging intents = discord.Intents(messages=True,message_content=True) client = discord.Client(intents=intents) @client.event async def on_ready(): print(f'We have logged in as {client.user}') @client.event async def on_message(message): #if isinstance(message.channel, discord.channel.DMChannel) or message.channel.name: # return #print(message.channel.name) # Handle own messages if message.author == client.user: return # Handle whitelist if message.author.name not in config['bot']['whitelist']: await message.channel.send(f"Sorry {message.author.mention}, you are not authorized to do that.") return if message.content == f"{client.user.mention} ping": await message.channel.send(f"{message.author.mention} ") return # Handle @Bot mention messagearray = message.content.split() if messagearray[0] == client.user.mention: messagearray.pop(0) if messagearray[0] == "help": await message.channel.send(BuildHelpList()) return if messagearray[0] == "list": await message.channel.send(BuildGameList()) return if messagearray[0] in ["start", "stop", "restart"] and len(messagearray) >= 2: success = HandleSystemdService(messagearray[1], messagearray[0]) # :white_check_mark: :x: if success: await message.add_reaction("✅") else: await message.add_reaction("❌") await message.channel.send(f"Sorry {message.author.mention}, that didn't work. Ping @lauralani") if messagearray[0] == "status": await message.channel.send(BuildSingleGameStatus()) return client.run(config['bot']['token'])