forked from Nquxii/Rho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
49 lines (39 loc) · 1.5 KB
/
start.py
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
import discord
from discord.ext import commands
import data.config as config
import datetime
from discord import slash_command
from os import listdir
from os.path import isfile, join
# add required intents like message_content
intents = discord.Intents.default()
intents.message_content = True
# discord bot variable
bot = commands.Bot(command_prefix=str(config.prefix), case_insensitive=True, heartbeat_timeout=300, intents=intents)
# removes default help command so you can make your own
bot.remove_command("help")
# state cogs (classes used) here
cogs = ['finance', 'general']
# Bot action on startup
@bot.event
async def on_ready():
print(f'\n{bot.user} online @ {str(datetime.datetime.now())}')
print(f'prefix: {str(config.prefix)}')
#print("\ninvite link:\nhttps://discordapp.com/oauth2/authorize?&client_id=" + str(bot.user.id) + "&scope=applications.commands%20bot&permissions=8\n")
# global command error handler
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
pass
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send("missing required argument")
elif isinstance(error, commands.BadArgument):
await ctx.send("missing required argument")
else:
print(error, ctx)
# Load cogs mentioned in list to add to command list
for cog in cogs:
bot.load_extension('plugins.' + cog) # loads in each file, Cog, that is defined in the list
# if name of script equals to main, run the bot
if __name__ == "__main__":
bot.run(config.discordtoken)