-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipington.py
More file actions
executable file
·91 lines (75 loc) · 2.84 KB
/
ipington.py
File metadata and controls
executable file
·91 lines (75 loc) · 2.84 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import discord
import logging
from dotenv import dotenv_values
from discord.ext import commands
import functions
class IPington(commands.Bot):
"""
A Discord bot for automating a self-hosted Minecraft server.
This class is a subclass of :class:`discord.commands.Bot`.
Attributes
-----------
command_prefix
The command prefix is the string any message intended as a command must start with
for the bot to execute the following message as a command.
Example: '!'
server_name
The name of the server IPington is managing.
server_version
The version of the server IPington is managing.
Example: '1.18.1'
server_path
The full path to the top-level directory containing the server files.
server_exec
The relative or full path to the `minecraft_server.jar`.
server_port
The port number used to connect to the server.
xms
The amount of memory to give the server at start
xmx
The maximum amount of memory the server is allowed
"""
def __init__(self,
command_prefix: str,
server_name: str,
server_version: str,
server_path: str,
server_exec: str,
server_port: str,
xms: str,
xmx: str):
super(IPington, self).__init__(command_prefix=command_prefix,
intents=discord.Intents(messages=True, message_content=True))
self.server_name = server_name
self.minecraft_version = server_version
self.server_path = server_path
self.jar_path = server_exec
self.server_port = server_port
self.xms = xms
self.xmx = xmx
# self.wait_for(self.add_cog(functions.Functions(self)))
self.server_process = None
logging.basicConfig(
filename='ipington.log',
level=logging.WARNING,
format='%(asctime)s %(message)s')
async def cogs(ipington):
await ipington.add_cog(functions.Functions(ipington))
if __name__ == '__main__':
import asyncio
# Load .conf file.
config = dotenv_values('.conf')
# Setup IPington.
ipington: IPington = IPington(server_name=config['NAME'],
command_prefix=config['PREFIX'],
server_version=config['MINECRAFT_VERSION'],
server_path=config['PATH_TO_SERVER'],
server_exec=config['SERVER_EXEC'],
server_port=config['SERVER_PORT'],
xms=config['XMS'],
xmx=config['XMX'])
asyncio.run(cogs(ipington))
# Run IPington
ipington.run(config['TOKEN'])