Minecraft-Server-Discord-Bot/main.py

58 lines
1.7 KiB
Python
Raw Permalink Normal View History

2022-10-30 22:36:37 +00:00
import os
import discord
from dotenv import load_dotenv
BOT_NAME = "Dumb Bitch"
2022-10-31 00:30:30 +00:00
class ComputerManager:
def __init__(self):
pass
def start_computer(self):
print("Starting Computer")
2022-10-30 23:01:25 +00:00
2022-10-30 23:38:20 +00:00
class MyClient(discord.Client):
2022-10-31 00:30:30 +00:00
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.computer_manager = ComputerManager()
self.information_message = None
async def send_information_message(self, channel: discord.TextChannel):
self.information_message = await channel.send(
"Placeholder message for server information\n"
"react with :arrow_forward: to start the server"
)
await self.information_message.add_reaction("")
2022-10-30 23:38:20 +00:00
async def on_ready(self):
print(f"Logged on as {self.user}.")
2022-10-30 22:36:37 +00:00
2022-10-30 23:38:20 +00:00
async def on_message(self, message):
if message.author == self.user:
return
2022-10-31 00:30:30 +00:00
print(f"Message from {message.author}: {message.content}")
if message.content == "!information_message":
await self.send_information_message(message.channel)
async def on_reaction_add(self, reaction, user):
if user == self.user:
return
print(f"User {user} reacted to message {reaction.message.id} with {reaction}")
if reaction.message == self.information_message:
if reaction.emoji == "":
self.computer_manager.start_computer()
2022-10-31 00:34:33 +00:00
await reaction.message.remove_reaction("", user)
2022-10-30 22:36:37 +00:00
if __name__ == "__main__":
load_dotenv()
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
2022-10-30 23:38:20 +00:00
# intents = discord.Intents.default()
# intents.message_content = True
intents = discord.Intents.all()
client = MyClient(intents=intents)
client.run(DISCORD_TOKEN)