-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
157 lines (136 loc) · 4.45 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Bot originally made by using NAFF
# Ported to i.py v5
# pip install -U discord-py-interactions
import interactions as inter
from interactions import (
Client,
Button,
VoiceState,
slash_command,
InteractionContext,
context_menu,
listen,
Intents,
Member,
Embed,
slash_option,
Color,
ActionRow,
ComponentContext,
spread_to_rows,
ComponentContext,
is_owner,
OptionType,
Permissions,
SlashCommandChoice,
ButtonStyle,
check,
)
from const import WATCHINGSTATUS, PLAYINSTATUS
import asyncio
import re
import random
import os
from random import randint
from datetime import date, datetime
from babel.dates import format_date
import json
import time
from asyncio import sleep as eep
import pandas as pd
from const import CONTRIBUTORS, HELPERS
from dotenv import load_dotenv
load_dotenv()
from Bot_website import start
bot_intents: Intents = Intents.ALL
bot = inter.Client(sync_interactions=True, intents=bot_intents, send_command_tracebacks=False)
# unedited_ndaytext = None
# defenitionmade = False
# # @listen()
# # async def on_error():
# # print("Caught an error")
# # os.system("kill 1")
def load_extensions(bot, folder, folder_name="", exclude_files=[]):
extensions = [file.replace(".py", "") for file in os.listdir(folder) if file.endswith(".py") and file not in exclude_files]
for ext in extensions:
bot.load_extension(f"{folder_name}{ext}")
print(f"Loadded {ext}.py correctly")
@listen()
async def on_startup():
print(f"{bot.user} has connected to Discord!")
load_extensions(bot, "data", "data.", exclude_files=[
"quit.py",
"tictactoe.py",
"voice.py",
"configcmds.py",
])
bot.del_unused_app_cmd = True
lab_guild = 974354202430169139
lab_contributor = 974586417932021760
lab_lilhelper = 1041445249668624475
# get all of the users with the roles
lab_guild = bot.get_guild(lab_guild)
if lab_guild != None :
contributors = lab_guild.get_role(lab_contributor).members
for user in contributors:
CONTRIBUTORS.append(user.id)
helpers = lab_guild.get_role(lab_lilhelper).members
for user in helpers:
HELPERS.append(user.id)
dev = bot.get_user(737983831000350731)
start(contributors, helpers, dev)
else:
print("Failed to get the guild")
guild_list = bot.guilds
guild_names = []
guild_members = []
guild_ids = []
for i in range(len(guild_list)):
guild_names.append(guild_list[i].name)
guild_members.append(guild_list[i].member_count)
guild_ids.append(guild_list[i].id)
guild_list = pd.DataFrame({"id": guild_ids, "guild": guild_names, "members": guild_members})
guild_list.set_index("id", inplace=True)
print(guild_list)
while True: # Select a random activity, which will change every 60 seconds
random_activity = randint(1, 3)
if random_activity == 1:
await bot.change_presence(
activity=inter.Activity(
name=random.choice(PLAYINSTATUS),
type=inter.ActivityType.PLAYING,
)
)
await asyncio.sleep(60)
elif random_activity == 2:
await bot.change_presence(
activity=inter.Activity(
name=random.choice(WATCHINGSTATUS),
type=inter.ActivityType.WATCHING,
)
)
await asyncio.sleep(60)
elif random_activity == 3:
if str(len(bot.guilds)).endswith("1") and not str(len(bot.guilds)).endswith("11"):
await bot.change_presence(
activity=inter.Activity(
type=inter.ActivityType.STREAMING,
url="https://www.twitch.tv/pre1ude0",
name="to {0} server".format(len(bot.guilds)),
)
)
else:
await bot.change_presence(
activity=inter.Activity(
type=inter.ActivityType.STREAMING,
name="to {0} servers".format(len(bot.guilds)),
url="https://www.twitch.tv/pre1ude0",
)
)
await asyncio.sleep(60)
secret_TOKEN = os.environ["TOKEN"]
try:
bot.start(secret_TOKEN)
except Exception as e:
os.system("kill 1")
raise Exception(f"Failed to log in, reason: {e}")