-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
71 lines (52 loc) · 1.61 KB
/
main.py
File metadata and controls
71 lines (52 loc) · 1.61 KB
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
print(f'\033[0;34mInitializing Bot...\033[0m')
from dotenv import load_dotenv
load_dotenv()
__version__ = '0.0.0'
import os
import time
import util
import nextcord
from console import fg, bg
old_print = print
def new_print(*args, **kwargs):
old_print(bg.black, *args, **kwargs)
print = new_print
from nextcord.ext import commands
intents = nextcord.Intents.none()
intents.guilds = True
activity = nextcord.Activity(
type=nextcord.ActivityType.watching,
name='replit.com/bounties',
)
bot = commands.Bot(
intents=intents,
activity=activity,
case_insensitive=True,
chunk_guilds_at_startup=False,
)
# Remove the default help command
bot.remove_command('help')
bot.__version__ = __version__
@bot.event
async def on_ready():
print(f'Bot Version: {fg.lightgreen}{__version__}{fg.default}')
print(f'Connected to bot: {fg.lightgreen}{bot.user.name}{fg.default}')
print(f'Bot ID: {fg.lightgreen}{bot.user.id}{fg.default}')
print(
f'I\'m in {fg.blue}{str(len(bot.guilds))}{fg.default} server{"s" if len(bot.guilds) > 1 else ""}!'
)
util.load_directory(bot, 'extensions')
util.load_directory(bot, 'commands')
while True:
try:
bot.run(os.getenv('TOKEN'))
except nextcord.errors.HTTPException as err:
# Catch ratelimits
if err.status == 429:
util.clear_terminal()
print(f'{fg.red}Rate limit exceeded.{fg.default}')
retry_after = err.response.headers['Retry-After']
print(
f'{fg.green}Retrying in {retry_after} seconds...{fg.default}')
time.sleep(int(retry_after))
continue