Some basic structure
This commit is contained in:
commit
3978b44793
4 changed files with 45 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
config.json
|
17
cogs/basic.py
Normal file
17
cogs/basic.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
class Basic(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@discord.slash_command()
|
||||
async def sayhello(self, ctx):
|
||||
await ctx.respond('Hello world!')
|
||||
|
||||
@discord.slash_command()
|
||||
async def ping(self, ctx):
|
||||
await ctx.respond('My ping is {:.0f}ms'.format(self.bot.latency*1000), ephemeral=True)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Basic(bot))
|
12
data.py
Normal file
12
data.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import json
|
||||
import os.path
|
||||
|
||||
DATA_FOLDER = "data"
|
||||
|
||||
def load_json(filename: str):
|
||||
with open(filename + ".json") as f:
|
||||
content = json.load(f)
|
||||
return content
|
||||
|
||||
def load_data(filename: str):
|
||||
return load_json(os.path.join(DATA_FOLDER, filename))
|
15
main.py
Normal file
15
main.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from discord.ext import commands
|
||||
import data
|
||||
|
||||
CONFIG = data.load_json("config")
|
||||
|
||||
bot = commands.Bot()
|
||||
|
||||
cogs_list = [
|
||||
'basic',
|
||||
]
|
||||
|
||||
for cog in cogs_list:
|
||||
bot.load_extension(f'cogs.{cog}')
|
||||
|
||||
bot.run(CONFIG["token"])
|
Loading…
Reference in a new issue