This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
297 lines (273 loc) · 10.2 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
import voltage, json, asyncio
import os, random
from voltage.ext import commands
from voltage import CommandNotFound, NotEnoughArgs, NotEnoughPerms, NotBotOwner, NotFoundException
from host import alive
async def get_prefix(message, client):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
if message.server is None:
return "m!"
elif str(message.server.id) not in prefixes:
with open("prefixes.json", "w") as f:
prefixes[str(message.server.id)] = "m!"
json.dump(prefixes, f, indent=2)
return "m!"
else:
return prefixes.get(str(message.server.id), "m!")
class MyHelpCommand(commands.HelpCommand):
async def send_help(self, ctx: commands.CommandContext):
embed = voltage.SendableEmbed(
title="Help",
description=f"Use `{ctx.prefix}help <command>` to get help for a command.",
colour="#516BF2",
icon_url=ctx.author.display_avatar.url
)
text = "\n### **No Category**\n"
for command in self.client.commands.values():
if command.cog is None:
text += f"> {command.name}\n"
for i in self.client.cogs.values():
text += f"\n### **{i.name}**\n{i.description}\n"
for j in i.commands:
text += f"\n> {j.name}"
if embed.description:
embed.description += text
return await ctx.reply(f"[]({ctx.author.id})", embed=embed)
bot = commands.CommandsClient(get_prefix, help_command=MyHelpCommand)
async def status():
for i in range(1, 10000):
statuses = [
f"Playing with {len(bot.cache.servers)} servers and {len(bot.members)} users!",
f"Watching {len(bot.members)} users!",
f"My waifu is better than yours!!! | {len(bot.cache.servers)} servers",
f"Jan | {len(bot.cache.servers)} servers",
f"guys my father just came back with the milk O_O - delta2571 | {len(bot.cache.servers)} servers",
f"Revolt > shitcord | {len(bot.cache.servers)} servers",
f"Jans Onlyfans: onlyfans.com/linustechtips | {len(bot.cache.servers)} servers",
]
status = random.choice(statuses)
await bot.set_status(status, voltage.PresenceType.online)
await asyncio.sleep(5)
@bot.listen("message")
async def on_message(message):
with open("prefixes.json", "r") as g:
prefixes = json.load(g)
if message.server.id not in prefixes:
with open("prefixes.json", "w") as g:
prefixes[message.server.id] = "m!"
json.dump(prefixes, g, indent=2)
with open("json/users.json", "r") as f:
data = json.load(f)
if message.author.id in data:
pass
elif message.server.id in prefixes:
pass
else:
if message.author.id not in data:
with open("json/users.json", "w") as f:
data[message.author.id] = {
"username": message.author.name,
"id": message.author.id,
"bio": "User has no bio set!",
"beta": "False",
"ff": "False",
"notifications": [],
}
json.dump(data, f, indent=2)
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefix = prefixes.get(str(message.server.id))
if message.content == "<@01FZB4GBHDVYY6KT8JH4RBX4KR>":
await message.channel.send(
f"Pong, {message.author.mention}! My prefix for this server is `{prefix}`"
)
elif message.content.startswith(prefix) is True:
if message.author.bot is False:
pass
else:
with open("json/users.json", "r") as f:
data = json.load(f)
if message.author.id in data:
with open("json/users.json", "w") as f:
data[message.author.id] = {
"username": message.author.name,
"id": message.author.id,
"bio": "User has no bio set!",
"beta": "False",
"ff": "False",
"notifications": [],
}
json.dump(data, f, indent=2)
return
await bot.handle_commands(message)
@bot.command()
async def reload(ctx):
if str(ctx.author.id) == "01FZB2QAPRVT8PVMF11480GRCD":
await ctx.send("Reloading all cogs!")
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
try:
bot.reload_extension(f"cogs.{filename[:-3]}")
print(f"Just reloaded {filename}")
await ctx.send(f"Reloaded {filename}")
except Exception as e:
print(e)
else:
await ctx.send("Get outta hea' you ain't my ownah'!")
@bot.listen("server_added")
async def server_added(server):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
with open("prefixes.json", "w") as f:
prefixes[str(server.id)] = "m!"
json.dump(prefixes, f, indent=2)
channel = bot.cache.get_channel("01FZBBJJM9R6VYE0M5WJDGKMPT")
embed = voltage.SendableEmbed(
title="New Server alert!",
description=f"## Just Joined a new server!\nNow at **{len(bot.servers)}** servers!",
color="#516BF2",
)
await channel.send(content="[]()", embed=embed)
@bot.listen("member_join")
async def member_join(member):
if str(member.server.id) == "01FZB38TYPX73VSWFMMJTZE8C5":
print(f"{member} just joined!")
else:
return
@bot.listen("ready")
async def on_ready():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
try:
bot.add_extension(f"cogs.{filename[:-3]}")
print(f"Just loaded {filename}")
except Exception as e:
print(e)
await status()
@bot.command(description="Get some support!")
async def support(ctx):
embed = voltage.SendableEmbed(
title="Need Help? Found a Bug? Want to see a feature implimented? All of the above?",
description="Tell us at [Our Website](https://mechabot.tk/) or join us in [Our Server](https://app.revolt.chat/invite/hqSq0yZh)!",
colour="#516BF2",
media="https://i.imgur.com/3DQ7a6I.jpg",
)
await ctx.send(content=ctx.author.mention, embed=embed)
@bot.command(description="Get a users avatar!")
async def avatar(ctx, member: voltage.Member):
embed = voltage.SendableEmbed(
title=f"{member.display_name}'s avatar!",
media=member.display_avatar.url,
colour="#516BF2",
)
await ctx.send(content=ctx.author.mention, embed=embed)
@bot.error("message")
async def on_message_error(error: Exception, message):
if isinstance(error, CommandNotFound):
errormsg = [
"Error! Error!",
"LOOK OUT!!! ERROR!!",
"Whoops!",
"Oopsie!",
"Something went wrong!",
"Something happened..",
"What happened? I know!",
"404!",
"ERROR.. ERROR..",
"Error Occured!",
"An Error Occured!",
]
embed = voltage.SendableEmbed(
title=random.choice(errormsg),
description="That command doesnt exist!",
colour="#516BF2",
media="https://i.imgur.com/NUg5Lx7.png",
)
return await message.reply(message.author.mention, embed=embed)
elif isinstance(error, NotEnoughArgs):
errormsg = [
"Error! Error!",
"LOOK OUT!!! ERROR!!",
"Whoops!",
"Oopsie!",
"Something went wrong!",
"Something happened..",
"What happened? I know!",
"404!",
"ERROR.. ERROR..",
"Error Occured!",
"An Error Occured!",
]
embed = voltage.SendableEmbed(
title=random.choice(errormsg),
description="YOU'RE MISSING ARGS!",
colour="#516BF2",
media="https://i.imgur.com/IqqnqmF.png",
)
return await message.reply(message.author.mention, embed=embed)
elif isinstance(error, NotFoundException):
errormsg = [
"Error! Error!",
"LOOK OUT!!! ERROR!!",
"Whoops!",
"Oopsie!",
"Something went wrong!",
"Something happened..",
"What happened? I know!",
"404!",
"ERROR.. ERROR..",
"Error Occured!",
"An Error Occured!",
]
embed = voltage.SendableEmbed(
title=random.choice(errormsg),
description=error,
colour="#516BF2",
media="https://i.imgur.com/T3YNsY1.png",
)
return await message.reply(message.author.mention, embed=embed)
elif isinstance(error, NotEnoughPerms):
errormsg = [
"Error! Error!",
"LOOK OUT!!! ERROR!!",
"Whoops!",
"Oopsie!",
"Something went wrong!",
"Something happened..",
"What happened? I know!",
"404!",
"ERROR.. ERROR..",
"Error Occured!",
"An Error Occured!",
]
embed = voltage.SendableEmbed(
title=random.choice(errormsg),
description=error,
colour="#516BF2",
media="https://i.imgur.com/T3YNsY1.png",
)
return await message.reply(message.author.mention, embed=embed)
elif isinstance(error, NotBotOwner):
errormsg = [
"Error! Error!",
"LOOK OUT!!! ERROR!!",
"Whoops!",
"Oopsie!",
"Something went wrong!",
"Something happened..",
"What happened? I know!",
"404!",
"ERROR.. ERROR..",
"Error Occured!",
"An Error Occured!",
]
embed = voltage.SendableEmbed(
title=random.choice(errormsg),
description="You dont own me! You cant use my owner only commands!",
colour="#516BF2",
media="https://i.imgur.com/T3YNsY1.png",
)
return await message.reply(message.author.mention, embed=embed)
alive()
bot.run(os.environ["TOKEN"])