forked from RektorDK/invitemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvite.py
50 lines (43 loc) · 1.7 KB
/
invite.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
import discord
client=discord.Client()
@client.event
async def on_ready():
global role_list
print('Logged in as: '+client.user.name)
print('Bot ID: '+client.user.id)
await client.change_presence(game=discord.Game(name='TZ!invites - Hej!'))
print('------\n')
for server in client.servers:
role_list=dict((role.name,role) for role in server.roles)
@client.event
async def on_member_join(new_member):
invites=await client.invites_from(new_member.server)
for member in new_member.server.members:
if member.bot==False:
uses=0
prole=None
for invite in invites:
if invite.max_age==0 and invite.inviter==member:
uses += invite.uses
for role,used in role_ranks.items():
if uses in used and role_list[role] not in member.roles:
for mrole in member.roles:
if mrole.name in role_ranks.keys():
await client.remove_roles(member,mrole)
await client.send_message(member,"Congratulations {}, you have been promoted to **{}**!".format(member.mention,role))
await client.add_roles(member,role_list[role])
@client.event
async def on_message(message):
if message.content=='TZ!invites':
total_uses=0
embed=discord.Embed(title='__Invites from {}__'.format(message.author.name))
invites = await client.invites_from(message.server)
for invite in invites:
if invite.inviter == message.author and invite.max_age==0:
total_uses += invite.uses
embed.add_field(name='Invite',value=invite.id)
embed.add_field(name='Uses',value=invite.uses)
embed.add_field(name='Expires',value='Never')
embed.add_field(name='__Total Uses__',value=total_uses)
await client.send_message(message.channel,embed=embed)
client.run('NzAxMDk2NjAyMjgyMDk4Njg4.Xpshlw.cl5Y9vpWrt108xHzerz1e0svK30')