-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
52 lines (43 loc) · 1.37 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
import asyncio
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
# Setup Bot
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True
activity = discord.Activity(type=discord.ActivityType.listening, name="s!help")
bot = commands.Bot(
command_prefix='s!',
activity=activity,
case_insensitive=True,
intents=intents
)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
# Check if more than 2 minutes remaining
if error.retry_after < 121:
await ctx.reply(f'You can use this command again in *{int(error.retry_after)} seconds*.', delete_after=5)
else:
await ctx.reply(f'You can use this command again in *{int(error.retry_after / 60)} minutes*.', delete_after=5)
if isinstance(error, commands.CommandNotFound):
await ctx.reply('That command doesn\'t exist!')
@bot.event
async def on_ready():
print(' > Discord connected, bot on:')
async def main():
env = os.getenv('SLIME_DEV', 'True')
dev = True if env == 'True' else False
token = 'DISCORD_DEV' if dev else 'DISCORD_PROD'
print(' > Dev Mode:', str(dev))
# Load cogs and run
await bot.load_extension('cogs.slimes')
await bot.start(os.getenv(token), reconnect=True)
if __name__ == '__main__':
# Catch CTRL+C
try:
asyncio.run(main())
except KeyboardInterrupt:
print(' > CTRL+C detected, exiting...')