-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
65 lines (52 loc) · 2.04 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
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright: GregTCLTK 2018-2021.
# Contact Developer on https://discord.gg/nPwjaJk (Skidder#8515 | 401817301919465482)
import discord
import asyncio
import json
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
cfg = open("config.json", "r")
tmpconfig = cfg.read()
cfg.close()
config = json.loads(tmpconfig)
token = config["token"]
guild_id = config["server-id"]
logs_channel = config["logs-channel-id"]
invites = {}
last = ""
async def fetch():
global last
global invites
await client.wait_until_ready()
gld = client.get_guild(int(guild_id))
logs = client.get_channel(int(logs_channel))
while True:
invs = await gld.invites()
tmp = []
for i in invs:
for s in invites:
if s[0] == i.code:
if int(i.uses) > s[1]:
usr = gld.get_member(int(last))
eme = discord.Embed(description="Just joined the server", color=0x03d692, title=" ")
eme.set_author(name=usr.name + "#" + usr.discriminator, icon_url=usr.avatar_url)
eme.set_footer(text="ID: " + str(usr.id))
eme.timestamp = usr.joined_at
eme.add_field(name="Used invite",
value="Inviter: " + i.inviter.mention + " (`" + i.inviter.name + "#" + i.inviter.discriminator + "` | `" + str(i.inviter.id) + "`)\nCode: `" + i.code + "`\nUses: `" + str(
i.uses) + "`", inline=False)
await logs.send(embed=eme)
tmp.append(tuple((i.code, i.uses)))
invites = tmp
await asyncio.sleep(4)
@client.event
async def on_ready():
print("ready!")
await client.change_presence(activity=discord.Activity(name="joins", type=2))
@client.event
async def on_member_join(meme):
global last
last = str(meme.id)
client.loop.create_task(fetch())
client.run(token)