-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
65 lines (54 loc) · 1.83 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import discord
from discord.ext import commands
import yaml
import asyncio
import sys
import traceback
import os
import subprocess
# add cogs
sys.path.insert(1, "cogs")
# cogs
import kevgpt3
# from disputils import BotEmbedPaginator, BotConfirmation, BotMultipleChoice
try:
with open("config.yml", "r") as r:
C = yaml.load(r.read(), Loader=yaml.FullLoader)
except FileNotFoundError:
print("No config.yml, please copy and rename config-example.yml and fill in the appropriate values.")
exit()
feedbacktimeout = []
intents = discord.Intents.default()
bot = commands.Bot(
command_prefix=C["prefix"],
intents=intents
)
# cogs setup
kevgpt3.setup(bot, C)
@bot.event
async def on_ready(): # I just like seeing basic info like this
await bot.change_presence(activity=discord.Game(name=f'{C["prefix"]}help'))
print("-----------------Info-----------------")
print(f"Total Servers: {len(bot.guilds)}")
@bot.event
async def on_command_error(ctx, error): # share certain errors with the user
if(isinstance(error, commands.CommandNotFound)):
return
if isinstance(error, commands.BadArgument):
await ctx.send(f"Bad Argument: {error}")
return
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(f"Missing Argument: {error}")
return
if isinstance(error, commands.CommandInvokeError):
original = error.original
if isinstance(original, IndexError):
await ctx.send(f"IndexError: {original}\n[This might mean your search found no results]")
return
await ctx.send("😖 Sorry, that command caused an error! Devs are investigating the issue.")
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
if(ctx):
print(f"Author: {ctx.author}")
print(f"Command: {ctx.message.clean_content}")
bot.run(C["token"])