-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinecraftServerBot.py
More file actions
31 lines (22 loc) · 901 Bytes
/
MinecraftServerBot.py
File metadata and controls
31 lines (22 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Basic Discord bot that launches batch file from local machine.
import os
import discord
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send("Hello! If you would like to start the minecraft server type $run. If I don't respond in the future, contact Zachary.")
if message.content.startswith('$run'):
await message.channel.send('Running...')
os.chdir(r'C:\Users\Zachary\Desktop\Minecraft Server')
os.system('RunServer.bat')
# Insert token provided by Discord Application here
token = ""
client.run(token)