-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
669 lines (589 loc) · 30.1 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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
import discord
import os
import re
import asyncio
from random import randint
from discord.ext import commands
from discord import Webhook
# import tsv editing commands
from tsv import *
# import webhook send command builder
from webhook import buildSendCommand
# initialization
import settings
try:
f = open("token", "r")
tokenTest = f.read()
except:
print("[URANIUM|Error] Token file could not be found or could not be read successfully, please create a bot via discordapi.com and copy the bot token into a file called 'token'.")
exit()
print("[URANIUM] Token file exists.")
userDataExists = os.path.exists("./user-data/")
if userDataExists == False:
os.mkdir("user-data")
print("[URANIUM] User data directory exists.")
webhookDataExists = os.path.exists("./webhook-data/")
if webhookDataExists == False:
os.mkdir("webhook-data")
print("[URANIUM] Webhook data directory exists.")
messageLogsExists = os.path.exists("./message-logs/")
if messageLogsExists == False:
os.mkdir("message-logs")
print("[URANIUM] Message log directory exists.")
if settings.messageLogging == "perSession":
print("[LOGGING] Deleting all previous message ID logging...")
for f in os.listdir("./message-logs/"):
os.remove(os.path.join("./message-logs/", f))
else:
print("[LOGGING] Persistent messaging logging on.")
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
async def obtainWebhookData(ctx, channelID):
# check if channel webhook exists in local database
direc = os.listdir("./webhook-data/")
for file in direc:
if str(channelID) in file:
webhookRead = open("./webhook-data/{0}".format(str(channelID), "r"))
webhookID = webhookRead.read()
webhookRead.close()
return webhookID
# if not, create and store it
else:
channel = uranium.get_channel(int(channelID))
webhookID = await channel.create_webhook(name="Uranium Proxy Webhook")
webhookPath = "./webhook-data/{0}".format(str(channelID))
webhookStore = open(webhookPath, "w")
webhookStore.write(str(webhookID))
webhookStore.close()
return webhookID
uranium = commands.Bot(command_prefix=settings.prefixes, intents=intents)
@uranium.event
async def on_ready():
print(f'[URANIUM] I have logged in as {uranium.user}!')
game = discord.Game("with isotopes! | {0}help".format(settings.prefixes[0]))
await uranium.change_presence(status=discord.Status.online, activity=game)
@uranium.event
async def on_reaction_add(reaction, user):
ctx = await uranium.get_context(reaction.message)
if (ctx.author.bot):
if reaction.emoji == "❌":
await ctx.invoke(uranium.get_command("delete"), user=user)
if reaction.emoji == "❓":
await ctx.invoke(uranium.get_command("showmsg"), user=user)
@uranium.event
async def on_message(message):
# this event will handle autoproxy and multiproxies
ctx = await uranium.get_context(message)
settingsPath = "./user-data/{0}.tsv".format(message.author.id)
if os.path.exists(settingsPath):
proxyStart = False
with open(settingsPath) as f:
# check if multiproxy is being invoked
for line in f:
proxy = line.split("\t")
if message.content.startswith(proxy[0]):
proxyStart = True
if proxyStart == True:
with open(settingsPath) as f:
multiproxyList = []
# search for other proxies being used
for line in f:
proxy = line.split("\t")
if proxy[0] in message.content:
multiproxyList.append(proxy[0])
if len(multiproxyList) > 0:
# detect attachments
try:
getAttachments = ctx.message.attachments[0]
except:
fileAttachments = None
else:
fileAttachments = []
for x in ctx.message.attachments:
x = await discord.Attachment.to_file(x)
fileAttachments.append(x)
# detect a reply
try:
getReply = ctx.message.reference
replyInformation = await ctx.fetch_message(getReply.message_id)
except:
replyInformation = None
rawLines = message.content.split("\n")
lineCount = message.content.count("\n") + 1
finishedLine = ""
currentBrackets = ""
firstMessage = True
firstMessage2 = True # for images and reply information
for x in range(lineCount):
for proxy in multiproxyList:
if proxy in rawLines[x]:
if firstMessage == False:
if firstMessage2 == True:
await ctx.invoke(uranium.get_command("send"), brackets=currentBrackets, msg=finishedLine, multiProxy=True, replyInformation=replyInformation, fileAttachments=fileAttachments)
firstMessage2 = False
else:
await ctx.invoke(uranium.get_command("send"), brackets=currentBrackets, msg=finishedLine, multiProxy=True)
finishedLine = rawLines[x][(len(proxy)):]
currentBrackets = proxy
firstMessage = False
break
else:
finishedLine += "\n{0}".format(rawLines[x])
else:
await ctx.invoke(uranium.get_command("send"), brackets=currentBrackets, msg=finishedLine, replyInformation=replyInformation, fileAttachments=fileAttachments)
await uranium.process_commands(message)
@uranium.command()
async def about(ctx):
embedVar = discord.Embed(
title="About {0}".format(settings.botName), description="{0} is a Discord bot that is used for roleplay and for use in systems/plurality.".format(settings.botName), color=0xC71203
)
if settings.modified == True:
embedVar.add_field(name="Warning:", value="*The owner of this bot has enabled the modified variable, which means this bot's code has been modified and put up for public use. A valid respository link for this code will be provided at the bottom.*", inline=False)
embedVar.set_footer(text="Created by NetscapeDreams. // Americium-223 Release [v0.3.1]")
embedVar.set_image(url="https://user-images.githubusercontent.com/121664679/213885228-339ba626-c546-4745-acad-6c7c13415a70.png")
embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own {0} instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.".format(settings.botName), inline=False)
embedVar.add_field(name="GNU Affero General Public License v3", value="https://www.gnu.org/licenses/agpl-3.0.html", inline=False)
embedVar.add_field(name="Repository Link", value=settings.respositoryLink, inline=False)
await ctx.send(embed=embedVar)
@uranium.group(invoke_without_command=True)
async def reinit(ctx):
databasePath = "./user-data/{0}.tsv".format(ctx.message.author.id)
databaseExists = os.path.exists(databasePath)
if databaseExists == True:
await ctx.send(":grey_exclamation: *A database under your user ID has been found.*\nIf you would like to re-initalize it, this will **delete all of your current isotopes and settings**.\n*Please note that you can export your user data via `{0}export` if you would like to.*\nIf you are sure you want to do this, please do `{0}reinit confirm`.".format(settings.prefixes[0]))
else:
await ctx.send(":x: *There is nothing to re-initialize.*")
@reinit.command()
async def confirm(ctx):
databasePath = "./user-data/{0}.tsv".format(ctx.message.author.id)
os.remove(databasePath)
databaseCreation = open(databasePath, "w")
databaseCreation.close()
await ctx.send(":white_check_mark: *Your database has been reinitalized. All former isotopes and settings have been deleted.*")
@uranium.command(description="register isotope")
async def register(ctx, name:str, brackets:str):
if len(name) > 80:
await ctx.send(":x: *Your isotope's name is too long, please keep it equal to or under 80 characters.*")
return
if "text" in brackets:
await ctx.send(":speech_balloon: *I have detected the \"text\" parameter in your isotope's brackets, commonly used by Tupperbox and PluralKit.*\n\nPlease note, Uranium does not support the \"text\" parameter, and you can change your isotope's brackets via the `{0}brackets` command.\n**Registration will continue.**".format(settings.prefixes[0]))
try:
avatar = ctx.message.attachments[0]
proxyAvatar = avatar.url
except:
proxyAvatar = "*"
if os.path.exists("./user-data/{0}.tsv".format(ctx.message.author.id)) == True:
conflictions = checkForConflicts(ctx, name, brackets)
else:
conflictions = None
appendProxy = open("./user-data/{0}.tsv".format(ctx.message.author.id), "a")
appendProxy.write("{0}\t{1}\t{2}".format(brackets, name, proxyAvatar))
appendProxy.close()
await ctx.send("Wonderful! `{0}` has been created under your user data using the brackets `{1}`.\nTo send a message via this isotope, you can just use the brackets. `{1}I'm a proxy!`".format(name, brackets))
return
if conflictions == None:
appendProxy = open("./user-data/{0}.tsv".format(ctx.message.author.id), "a")
appendProxy.write("\n{0}\t{1}\t{2}".format(brackets, name, proxyAvatar))
appendProxy.close()
await ctx.send("Wonderful! `{0}` has been created under your user data using the brackets `{1}`.\nTo send a message via this isotope, you can just use the brackets. `{1}I'm a proxy!`".format(name, brackets))
elif conflictions == "name":
await ctx.send(":x: There already is an isotope with this name in your user data.")
elif conflictions == "brackets":
await ctx.send(":x: There already is an isotope with these brackets in your user data.")
@uranium.command(description="delete an isotope")
async def remove(ctx, name:str):
await removeProxy(ctx, name)
@uranium.command(description="set an isotope's avatar")
async def avatar(ctx, name:str):
try:
avatar = ctx.message.attachments[0]
except:
await getProxyAvatar(ctx, name)
await setProxyAvatar(ctx, name, avatar)
@uranium.command(description="mainly for debugging", aliases=["whs"])
async def webhookstatus(ctx):
direc = os.listdir("./webhook-data/")
for file in direc:
if str(ctx.channel.id) in file:
webhookRead = open("./webhook-data/{0}".format(str(ctx.channel.id), "r"))
webhookID = webhookRead.read()
webhookRead.close()
await ctx.send(":white_check_mark: Webhook ID of `{0}` for this channel is present in my local database.".format(str(webhookID)))
break
else:
await ctx.send(":x: I do not have a local webhook database entry for this channel.")
webhookList = await ctx.message.channel.webhooks()
try:
for wh in webhookList:
if str(webhookID) == str(wh):
await ctx.send(":white_check_mark: My local webhook database entry for this channel was found in this channel's webhook list.")
return
except:
await ctx.send(":x: My local webhook database did not find a match in this channel's webhook list.")
@uranium.command()
async def rename(ctx, oldname, newname):
await editProxyName(ctx, oldname, newname)
@uranium.command()
async def brackets(ctx, name, newbrackets=None):
if newbrackets == None:
with open("./user-data/{0}.tsv".format(ctx.message.author.id)) as f:
for line in f:
proxy = line.split("\t")
if proxy[1] == name:
await ctx.send("The brackets for {0} are `{1}`.".format(name, proxy[0]))
else:
await editProxyBrackets(ctx, name, newbrackets)
@uranium.command()
async def list(ctx, member: discord.Member=None):
if member == None:
member = ctx.message.author
pageCount = 0
proxies, proxyCount = parseAll(ctx, member)
embedVar = discord.Embed(
title="{0}'s Isotopes".format(member.name), description="{0} has a total of {1} isotopes. Page 1/{2}.".format(member.name, proxyCount, len(proxies))
)
for x in proxies[0]:
embedVar.add_field(name=x[1], value="brackets: {0}\navatar url: {1}".format(x[0], x[2]), inline=False)
msg = await ctx.send(embed=embedVar)
await msg.add_reaction("🛑")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
if int(user.id) == int(ctx.author.id):
return True
else:
return False
while True:
try:
reaction, user = await uranium.wait_for("reaction_add", timeout=60.0, check=check)
except asyncio.TimeoutError:
break
else:
userCheck = check("nothing", user)
if userCheck == True:
if reaction.emoji == '🛑':
await msg.delete()
elif reaction.emoji == '⬅️' or reaction.emoji == '➡️':
if reaction.emoji == '➡️':
literalPageCount = pageCount + 1
if literalPageCount == len(proxies):
pageCount = 0
else:
pageCount += 1
else:
if pageCount == 0:
pageCount = len(proxies) - 1
else:
pageCount -= 1
embedVar = discord.Embed(
title="{0}'s Isotopes".format(member.name), description="{0} has a total of {1} isotopes. Page {2}/{3}.".format(member.name, proxyCount, pageCount + 1, len(proxies))
)
for x in proxies[pageCount]:
embedVar.add_field(name=x[1], value="brackets: {0}\navatar url: {1}".format(x[0], x[2]), inline=False)
await msg.edit(embed=embedVar)
@uranium.command(aliases=["s"])
async def send(ctx, brackets:str, *, msg, multiProxy=None, replyInformation=None, fileAttachments=None):
# attempt to detect if sending channel is a thread
try:
# thread channels have a parent_id attribute
detectThread = ctx.channel.parent_id
except:
detectThread = False
else:
detectThread = True
sendToThread = False
redirect = False
detectRedirect = re.compile("\{\{.*\}\}")
if detectRedirect.search(msg):
res = re.findall(r"\{\{.*?\}\}", msg)
originalres = res[0]
res[0] = res[0].replace('{{', '')
res[0] = res[0].replace('}}', '')
if res[0].startswith("<#"):
urghID = re.sub("\D", " ", res[0]);
channelID = re.sub("\s", "", urghID);
channel = uranium.get_channel(int(channelID))
try:
sendToThread = channel.parent_id
except:
sendToThread = False
webhookID = await obtainWebhookData(ctx, channel.id)
webhookList = await channel.webhooks()
else:
sendToThread = True
webhookID = await obtainWebhookData(ctx, channel.parent_id)
parentChannel = uranium.get_channel(int(channel.parent_id))
webhookList = await parentChannel.webhooks()
msg = msg.replace(originalres, "")
redirect = True
if detectThread == True and redirect == False:
webhookID = await obtainWebhookData(ctx, ctx.channel.parent_id)
channel = uranium.get_channel(int(ctx.channel.parent_id))
webhookList = await channel.webhooks()
elif detectThread == False and redirect == False:
webhookID = await obtainWebhookData(ctx, ctx.channel.id)
webhookList = await ctx.message.channel.webhooks()
for wh in webhookList:
if str(webhookID) == str(wh):
embedList = []
try:
name, avtr = parseProxy(ctx, brackets)
except:
return
detectCommand = re.compile("\{\{.*\}\}")
if detectCommand.search(msg):
res = re.findall(r"\{\{.*?\}\}", msg)
originalres = res[0]
res[0] = res[0].replace('{{', '')
res[0] = res[0].replace('}}', '')
separateDie = res[0].split('d')
if not separateDie[0]:
separateDie[0] = 1
separateExtra = separateDie[1].split('+')
separateExtra.append(0)
numberz = [int(separateDie[0]), int(separateExtra[0]), int(separateExtra[1])]
result = []
for die in range(numberz[0]):
die = randint(1, numberz[1])
result.append(die)
msg = msg.replace(originalres, "`🎲{0}`".format(sum(result, numberz[2])))
dieEmbed = discord.Embed(
title=res[0], description="{1} + {2} → **{3}**".format(res[0], result, numberz[2], sum(result, numberz[2])), color=0x20FD00
)
embedList.append(dieEmbed)
else:
dieEmbed = None
if replyInformation == None:
pass
else:
replyEmbed = discord.Embed(
description=replyInformation.content, color=0x20FD00
)
try:
replyAvatar = replyInformation.author.avatar.url
except:
replyEmbed.set_author(name=replyInformation.author.name)
else:
replyEmbed.set_author(name=replyInformation.author.name, icon_url=replyInformation.author.avatar.url)
embedList.append(replyEmbed)
if replyInformation == None and dieEmbed == None:
embedList = None
sendCommand = buildSendCommand(msg=msg, username=name, avatar=avtr, attachments=fileAttachments, detectThread=detectThread, sendToThread=sendToThread, redirect=redirect, embeds=embedList)
webhookMessage = await eval(sendCommand)
appendMessage = open("./message-logs/{0}.tsv".format(ctx.guild.id), "a")
appendMessage.write("{0}\t{1}\t{2}\n".format(webhookMessage.id, ctx.author.id, brackets))
appendMessage.close()
if multiProxy == None:
await ctx.message.delete()
return
await ctx.send(":x: **Something went wrong!**\nThe webhook ID in my local database could not be found in this channel's webhook list. *Did the webhook get deleted?*")
@uranium.command()
async def edit(ctx, *, msg):
getReply = ctx.message.reference
replyInformation = await ctx.fetch_message(getReply.message_id)
checkPermission = checkForPermission(ctx, replyInformation.id, ctx.author.id)
if checkPermission == True:
try:
detectThread = ctx.channel.parent_id
except:
detectThread = False
else:
detectThread = True
if detectThread == True:
webhookID = await obtainWebhookData(ctx, ctx.channel.parent_id)
channel = uranium.get_channel(int(ctx.channel.parent_id))
webhookList = await channel.webhooks()
elif detectThread == False:
webhookID = await obtainWebhookData(ctx, ctx.channel.id)
webhookList = await ctx.message.channel.webhooks()
for wh in webhookList:
if str(webhookID) == str(wh):
if detectThread == False:
await wh.edit_message(replyInformation.id, content=msg)
else:
await wh.edit_message(replyInformation.id, content=msg, thread=ctx.channel)
await ctx.message.delete()
@uranium.command()
async def delete(ctx, user=None):
if user == None:
getReply = ctx.message.reference
reply = await ctx.fetch_message(getReply.message_id)
checkPermission = checkForPermission(ctx, reply.id, ctx.author.id)
if checkPermission == True:
await reply.delete()
await ctx.message.delete()
else:
checkPermission = checkForPermission(ctx, ctx.message.id, user.id)
if checkPermission == True:
await ctx.message.delete()
@uranium.command()
async def export(ctx):
try:
if os.stat('./user-data/{0}.tsv'.format(ctx.author.id)).st_size == 0:
await ctx.send(":x: *Why would I send a blank user data file?*")
else:
dmChannel = await ctx.author.create_dm()
try:
await dmChannel.send("**Hi, {0}!** :wave:\nHere is your user data file you requested.\nOh, and please note: user data importing is not supported at the moment, so all you can really do is view your data. Sorry :(".format(ctx.author.name), file=discord.File(r'./user-data/{0}.tsv'.format(ctx.author.id)))
await ctx.message.add_reaction("✅")
except discord.errors.Forbidden:
await ctx.send(":x: *I was not able to message you, please allow server DMs so that I can send your user data file privately.*")
except FileNotFoundError:
await ctx.send(":x: *I could not find a user data file with your user ID. I think you should create your file first before exporting it.*")
@uranium.command()
async def data(ctx):
embedVar = discord.Embed(
title="{0} and your data.".format(settings.botName), description="What does {0} exactly do with data it obtains?".format(settings.botName), color=0x20FD00
)
embedVar.set_footer(text="Last updated January 21st, 2023.")
embedVar.add_field(name="User data", value="This bot stores your user ID (this is to help identify which file belongs to who) and the proxies you create via the information you provide, and your user ID used in message logging for helping determine if you own a proxy message.\nThis information is exportable via the bot's **export** command.", inline=False)
embedVar.add_field(name="Webhook data", value="This bot stores webhook ID data under a channel ID filename, to help keep a local value for comparison to send proxies via webhooks.", inline=False)
embedVar.add_field(name="Channel data", value="This bot stores channel IDs as filenames for help in identifying the webhook ID for the channel you are sending the proxy to.", inline=False)
embedVar.add_field(name="Guild and message data", value="This bot stores guild (server) IDs as filenames and message IDs for help in message logging, and to determine if the proxy message you sent is in the logs.", inline=False)
embedVar.add_field(name="Who can see this data?", value="It depends. All information can only be read by the bot host(s), with the exception of user data, which can be viewed at the user's request.", inline=False)
await ctx.send(embed=embedVar)
@uranium.command()
async def find(ctx, *, search):
getMember = ctx.message.author
proxies, proxyCount = parseAll(ctx, getMember, search)
pageCount = 0
embedVar = discord.Embed(
description="A total of {0} isotope(s) matches your search. Page 1/{1}.".format(proxyCount, len(proxies))
)
for x in proxies[0]:
embedVar.add_field(name=x[1], value="brackets: {0}\navatar url: {1}".format(x[0], x[2]), inline=False)
msg = await ctx.send(embed=embedVar)
await msg.add_reaction("🛑")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
if int(user.id) == int(ctx.author.id):
return True
else:
return False
while True:
try:
reaction, user = await uranium.wait_for("reaction_add", timeout=60.0, check=check)
except asyncio.TimeoutError:
break
else:
userCheck = check("nothing", user)
if userCheck == True:
if reaction.emoji == '🛑':
await msg.delete()
elif reaction.emoji == '⬅️' or reaction.emoji == '➡️':
if reaction.emoji == '➡️':
literalPageCount = pageCount + 1
if literalPageCount == len(proxies):
pageCount = 0
else:
pageCount += 1
else:
if pageCount == 0:
pageCount = len(proxies) - 1
else:
pageCount -= 1
embedVar = discord.Embed(
description="A total of {0} isotope(s) matches your search. Page {1}/{2}.".format(proxyCount, pageCount + 1, len(proxies))
)
for x in proxies[pageCount]:
embedVar.add_field(name=x[1], value="brackets: {0}\navatar url: {1}".format(x[0], x[2]), inline=False)
await msg.edit(embed=embedVar)
@uranium.command()
async def gfind(ctx, *, search):
proxies, proxyCount = parseAll(ctx, None, search, True)
pageCount = 0
embedVar = discord.Embed(
description="A total of {0} isotope(s) matches your search. Page 1/{1}.".format(proxyCount, len(proxies))
)
for x in proxies[0]:
proxyMember = ctx.guild.get_member(x[3])
embedVar.add_field(name=x[1], value="owned by: {0}\nbrackets: {1}\navatar url: {2}".format(proxyMember.name, x[0], x[2]), inline=False)
msg = await ctx.send(embed=embedVar)
await msg.add_reaction("🛑")
await msg.add_reaction("⬅️")
await msg.add_reaction("➡️")
def check(reaction, user):
if int(user.id) == int(ctx.author.id):
return True
else:
return False
while True:
try:
reaction, user = await uranium.wait_for("reaction_add", timeout=60.0, check=check)
except asyncio.TimeoutError:
break
else:
userCheck = check("nothing", user)
if userCheck == True:
if reaction.emoji == '🛑':
await msg.delete()
elif reaction.emoji == '⬅️' or reaction.emoji == '➡️':
if reaction.emoji == '➡️':
literalPageCount = pageCount + 1
if literalPageCount == len(proxies):
pageCount = 0
else:
pageCount += 1
else:
if pageCount == 0:
pageCount = len(proxies) - 1
else:
pageCount -= 1
embedVar = discord.Embed(
description="A total of {0} isotope(s) matches your search. Page {1}/{2}.".format(proxyCount, pageCount + 1, len(proxies))
)
for x in proxies[pageCount]:
proxyMember = ctx.guild.get_member(x[3])
embedVar.add_field(name=x[1], value="owned by: {0}\nbrackets: {1}\navatar url: {2}".format(proxyMember.name, x[0], x[2]), inline=False)
await msg.edit(embed=embedVar)
@uranium.command()
async def showmsg(ctx, user=None):
if user == None:
getReply = ctx.message.reference
reply = await ctx.fetch_message(getReply.message_id)
try:
userID, brackets = showProxyMessage(ctx, reply.id)
except:
return
if userID != False:
proxyName, proxyAvatar = parseProxy(ctx, brackets.strip(), userID)
embedVar = discord.Embed(
title="Show Message", color=0x20FD00
)
embedVar.set_thumbnail(url=proxyAvatar)
embedVar.add_field(name="Isotope Information", value="Name: {0}\nBrackets: {1}\nAvatar: {2}".format(proxyName, brackets.strip(), proxyAvatar), inline=False)
embedVar.add_field(name="User Information", value="This proxy was sent by:\nID: {0}\nUser: <@{0}>".format(userID), inline=False)
embedVar.set_footer(text="Message ID: {0}".format(reply))
await ctx.send(embed=embedVar)
else:
try:
userID, brackets = showProxyMessage(ctx, ctx.message.id)
except:
return
await ctx.message.remove_reaction("❓", user)
if userID != False:
proxyName, proxyAvatar = parseProxy(ctx, brackets.strip(), userID)
dmChannel = await user.create_dm()
embedVar = discord.Embed(
title="Show Message", color=0x20FD00
)
embedVar.set_thumbnail(url=proxyAvatar)
embedVar.add_field(name="Isotope Information", value="Name: {0}\nBrackets: {1}\nAvatar: {2}".format(proxyName, brackets.strip(), proxyAvatar), inline=False)
embedVar.add_field(name="User Information", value="This proxy was sent by:\nID: {0}\nUser: <@{0}>".format(userID), inline=False)
embedVar.add_field(name="Message Content", value=ctx.message.content, inline=False)
embedVar.set_footer(text="Message ID: {0}".format(ctx.message.id))
await dmChannel.send("Here's that information you wanted.", embed=embedVar)
@uranium.command()
async def isotope(ctx, *, name):
isotope = parseProxyByName(ctx, name.strip("\""))
embedVar = discord.Embed(
title="Show Isotope", color=0x20FD00
)
embedVar.set_thumbnail(url=isotope[2])
embedVar.add_field(name="Isotope Information", value="Name: {0}\nBrackets: {1}\nAvatar: {2}".format(isotope[1], isotope[0], isotope[2]), inline=False)
await ctx.send(embed=embedVar)
f = open("token", "r")
token = f.read()
uranium.run(token)