Skip to content

Commit

Permalink
bot is live
Browse files Browse the repository at this point in the history
  • Loading branch information
96-LB committed Dec 14, 2020
1 parent 470af95 commit 0369119
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
14 changes: 14 additions & 0 deletions cogs/teams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from discord.ext import commands

class Test(commands.Cog):

def __init__(self, bot):
self.bot = bot

@commands.command()
@commands.bot_has_permissions(send_messages=True)
async def ping(self, ctx):
await ctx.send('pong')

def setup(bot):
bot.add_cog(Test(bot))
31 changes: 31 additions & 0 deletions core/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os, discord
from discord.ext import commands

bot = commands.Bot(command_prefix='q!')

@bot.event
async def on_ready():
for cog in [cog.replace('.py', '') for cog in os.listdir('cogs') if '.py' in cog]:
await bot.change_presence(activity=discord.Game(name=f'loading cogs.{cog}'))
print(f'loading cogs.{cog}')
try:
bot.load_extension(f'cogs.{cog}')
except Exception as e:
await bot.change_presence(activity=discord.Game(name=f'error loading cogs.{cog}!'))
print(f'error loading cogs.{cog}!')
raise e
await bot.change_presence(activity=discord.Game(name='Message me "q!help" for info'))

@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
print(f'{error}')
return
if isinstance(error, commands.CheckFailure):
print(f'{error} ({ctx.invoked_with})')
return
await ctx.send(f'`ERROR: {error}`')
raise error

def run():
bot.run(os.getenv('TOKEN'))
File renamed without changes.
File renamed without changes.
13 changes: 4 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from keep_alive import keep_alive
import data
from core.keep_alive import keep_alive
from core.bot import run

records = data.get('TEST')
records.append({'test': 'g', 'test1': 'h'})
records[1]['fsd'] = 'q'
print(records)
data.set('TEST', records)

keep_alive()
keep_alive()
run()

0 comments on commit 0369119

Please sign in to comment.