-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
105 lines (90 loc) · 3.4 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from discord.ext import commands, tasks
from itertools import cycle
import discord.utils, discord, os
from sdk import husk_sdk
import async_cleverbot as ac
from discord_slash import SlashCommand
from discord_components import DiscordComponents, Button
from discord_slash.utils.manage_commands import create_choice,create_option
from discord_slash.utils import manage_commands
config = husk_sdk.BotConfig("bot.json")
config.Load()
intents = discord.Intents().all()
prefix = config.prefix
status = cycle([f'{prefix}help', f'Version 2.0 Is Up', f'{prefix}Update to see it!',
'Im UPDATED, Yaaaay!', 'slash commands are here!!'])
bot = commands.Bot(command_prefix=prefix, intents=intents, case_insensitive=True,
help_command=husk_sdk.HelpCommand())
bot.__setattr__("config", config)
slash = SlashCommand(bot, sync_commands=True)
def getbot():
return bot
moods = {
"joy": ac.Emotion.joy,
"anger": ac.Emotion.anger,
"angry": ac.Emotion.angry,
"fear": ac.Emotion.fear,
"sad": ac.Emotion.sad,
"sadness": ac.Emotion.sadness,
"happy": ac.Emotion.happy,
"neutral": ac.Emotion.neutral,
"normal": ac.Emotion.normal,
"scared": ac.Emotion.scared
}
mood = moods["normal"]
@bot.event
async def on_ready():
status_update.start()
DiscordComponents(bot)
print('The bot has logged in as {0.user}\n-------------------↴'.format(bot))
# EVENT ZONE ----------↴
@bot.event
async def on_message(message):
if message.content.lower().startswith("husk") and len(message.content[0:4]) > 3:
await husk_sdk.call_CeleverBot(message, bot, mood)
await bot.process_commands(message)
#######################
# main error handler #
#####################
@bot.event
async def on_command_error(ctx: commands.Context, error):
error = getattr(error, 'original', error)
if isinstance(error, commands.CommandNotFound):
await ctx.send(f"**ERROR** | `🚫` `Command Not Found, Use {prefix}help to see the bots commands`",
delete_after=3)
await ctx.message.delete()
else:
errorlist = [commands.MissingPermissions,
commands.MissingRequiredArgument,
commands.UserNotFound,
commands.CommandInvokeError,
TimeoutError,
husk_sdk.NotInVoice,
husk_sdk.OverTheLimit,
commands.NotOwner]
for er in errorlist:
if isinstance(error, er):
await ctx.send(f"**ERROR** | `🚫` `{error}`", delete_after=3)
await ctx.message.delete()
return
print("ERROR:" + str(error))
# COMMAND ZONE ----------↴
@commands.is_owner()
@bot.command(hidden=True)
async def set_mood(ctx, inpmood: str):
global mood
try:
mood = moods[inpmood]
await ctx.send(f"**Done!, mood set to `{inpmood}`**", delete_after=5)
except:
await ctx.send("**Wrong Mood Given**", delete_after=5)
# LOOP ZONE ----------↴
@tasks.loop(minutes=2)
async def status_update():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=status.__next__(),
url='https://discord.gg/Pr6qtxSUve'))
# Etc. ZONE ----------↴
for file in os.listdir('./cogs'):
if file.endswith('.py'):
bot.load_extension(f'cogs.{file[:-3]}')
bot.run(config.token)