-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
75 lines (52 loc) · 1.61 KB
/
bot.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
# Import standard library dependencies
import os
# Import external dependencies
import pendulum
# Import discord.py stuff
from discord.ext import commands
# Import events
from Events.on_guild_join import set_up_guild
# Initialise bot
bot = commands.Bot(command_prefix="q/")
# Cogs or extensions or categories
extensions = [
"Cogs.Verification.verification_cog"
]
# Load cogs
for cog in extensions:
bot.load_extension(cog)
# Print bot details
@bot.event
async def on_ready():
print("Logged in as")
print(bot.user.name)
print(bot.user.id)
print("--------------------------------")
# End of on_ready()
@bot.event
async def on_command_error(ctx, error):
mention = ctx.author.mention
# If user uses command before cooldown gets over
if isinstance(error, commands.CommandOnCooldown):
retry = pendulum.duration(seconds=error.retry_after).in_words()
await ctx.send(f"Retry after {retry}! Have patience, {mention}!")
# If missing permissions for executing commands
if isinstance(error, commands.MissingPermissions):
await ctx.send(f"You are not allowed to do that, {mention}.")
# End of on_command_error()
@bot.event
async def on_guild_join(guild):
await set_up_guild(guild)
# End of on_guild_join()
@bot.command
async def invite(self, ctx):
perms = 268438528
params = f"client_id={bot.user.id}&permissions={perms}"
link = f"https://discordapp.com/oauth2/authorize?scope=bot&{params}"
await ctx.send(link)
# End of invite
# Run the bot with token
bot.run(os.environ["TOKEN_BOT"])
# bot.run ends when bot logs out
print("Logged out.")
# End of file