This commit is contained in:
annihilator708 2018-05-20 21:05:17 +02:00
parent 7ffbb83b39
commit baf1359d60
5 changed files with 90 additions and 0 deletions

View File

@ -1,2 +1,5 @@
# Sebi-Machine
Guild-bot
In the folder "external_packages" you can find the discord.py rewrite module.
Make sure this one is installed.

@ -0,0 +1 @@
Subproject commit 3cb6ac152edb1004dd6f6afef2adb1777902bbbe

40
run.py Normal file
View File

@ -0,0 +1,40 @@
# !/usr/bin/python
# -*- coding: utf8 -*-
# Import packages
import discord
from discord.ext import commands
import json
# Import custom files
from src.config.config import LoadConfig
# Bot Class
class SebiMachine(commands.Bot, LoadConfig):
"""This discord is dedicated to http://www.discord.gg/GWdhBSp"""
def __init__(self):
# Initialize and attach config / settings
LoadConfig.__init__(self)
commands.Bot.__init__(self, command_prefix=self.defaultprefix)
# Load plugins
# Add your cog file name in this list
cogs = ['example']
for cog in cogs:
self.load_extension(f'src.cogs.{cog}')
async def on_ready(self):
"""On ready function"""
if self.maintenance:
print('MAINTENANCE ACTIVE')
if __name__ == '__main__':
client = SebiMachine()
# Make sure the key stays private.
with open('src/config/PrivateConfig.json') as fp:
PrivateConfig = json.load(fp)
fp.close()
client.run(PrivateConfig["bot-key"])

20
src/cogs/example.py Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/python
# -*- coding: <encoding name> -*-
from discord.ext import commands
import discord
class CogName:
"""
CogName should be the name of the cog
"""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
"""Say pong"""
await ctx.send('Pong')
def setup(bot):
bot.add_cog(CogName(bot))

26
src/config/config.py Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/python
# -*- coding: <encoding name> -*-
import json
import psycopg2
import psycopg2.extensions
class LoadConfig:
"""
All config is collected here
"""
def __init__(self):
# Read our config file
with open('src/config/Config.json') as fp:
self.config = json.load(fp)
# Initialize config
self.ownerlist = self.config["ownerlist"]
self.defaultprefix = self.config["prefix"]
self.version = self.config["version"]
self.display_name = self.config["display_name"]
self.maintenance = self.config["maintenance"]
if self.maintenance == 'False':
self.maintenance = False
else:
self.maintenance = True