-
Notifications
You must be signed in to change notification settings - Fork 0
/
rank_verify.py
155 lines (109 loc) · 6.34 KB
/
rank_verify.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
import traceback
from database import insert_users_data
from roles import get_rank_role,sfpd_roles
from unit_functions import remove_role_function
import asyncio
async def verify(discord,ctx,data,player_name):
try:
embed = discord.Embed(
title="[🥇] Verified Successfully",
description = "Your rank has been added and it'll be automatically update..." ,
color = discord.Color.random(),
)
embed.set_footer(text="use `!help` to know more |use !suggestions to share your ideas",icon_url="https://cdn.discordapp.com/avatars/491251010656927746/6f81dc8d0bc07ff152b244e0958b5961.png?size=1024")
if(data["other_faction"]==0):
add_data = {
"player_name" : player_name,
"player_discord_id":ctx.author.id,
"player_guild_id":ctx.guild.id,
"faction_name":data["faction_name"],
"faction_rank":data["faction_rank"],
"faction_warn":data["faction_warn"],
}
insertion_result = insert_users_data(add_data)
elif(data["other_faction"]==1):
add_data = {
"player_name" : player_name,
"player_discord_id":ctx.author.id,
"player_guild_id":ctx.guild.id,
"faction_name":"",
"faction_rank":"",
"faction_warn":"",
"other_faction":1,
}
insertion_result = insert_users_data(add_data)
# rank_1_role = ctx.guild.get_role(990485217506631741)
if(insertion_result):
print("Inserted")
if(data["other_faction"]==0):
if(ctx.message.author.id in [ctx.guild.owner_id,339956284205826048,374223751669088256,331861304425971712]):
nick_name_error_embed = discord.Embed(
title="[❗] Error",
description = "Your rank has been added but i don't have permission to change your name." ,
color = discord.Color.random(),
)
nick_name_error_embed.set_footer(text="use `!help` to know more |use !suggestions to share your ideas",icon_url="https://cdn.discordapp.com/avatars/491251010656927746/6f81dc8d0bc07ff152b244e0958b5961.png?size=1024")
guild = ctx.guild
member = guild.get_member(ctx.message.author.id)
await remove_role_function(member,guild)
role_id = get_rank_role(data["faction_name"],data["faction_rank"])
print(role_id)
verified_role = sfpd_roles["verified"]
print(member)
await member.add_roles(ctx.message.guild.get_role(verified_role))
await member.add_roles(ctx.message.guild.get_role(role_id))
guild_owner_message = await ctx.reply(embed = nick_name_error_embed)
else:
guild = ctx.guild
member = guild.get_member(ctx.message.author.id)
await remove_role_function(member,guild)
await ctx.message.author.edit(nick=player_name)
role_id = get_rank_role(data["faction_name"],data["faction_rank"])
print(role_id)
verified_role = sfpd_roles["verified"]
print(member)
await member.add_roles(ctx.message.guild.get_role(verified_role))
await member.add_roles(ctx.message.guild.get_role(role_id))
# await ctx.author.add_roles(ctx.guild,ctx.author,"verified")
await ctx.reply(embed=embed)
elif(data["other_faction"]==1):
guild = ctx.guild
member = guild.get_member(ctx.message.author.id)
await remove_role_function(member,guild)
role = member.guild.get_role(sfpd_roles["other_faction_members"])
await member.add_roles(role)
await member.edit(nick=player_name)
embed = discord.Embed(
title="[🤵] Verified Successfully",
description = "It seems you are from some other factions ,so i have added <@&995214555594625044> role to you and it'll be updated automatically once you entered into SFPD" ,
color = discord.Color.random(),
)
embed.set_footer(text="use `!help` to know more |use !suggestions to share your ideas",icon_url="https://cdn.discordapp.com/avatars/491251010656927746/6f81dc8d0bc07ff152b244e0958b5961.png?size=1024")
await ctx.respond(embed=embed)
else:
print("Error")
except Exception as e:
print(traceback.format_exc())
print("Errors_2")
print(e.__class__)
# embed = discord.Embed(
# title="**Welcome to SFSI Setup portal**",
# description="Click the Accept button to proceed",
# color=discord.Colour.random()
# )
# embed.add_field(name ="Things gonna Add" ,value="SFSI Rank 0 - 6 Roles \nSFSI Weekly Mission Channel")
# embed.set_footer(text="use `!help` to know more |use !suggestions to share your ideas",icon_url="https://cdn.discordapp.com/avatars/491251010656927746/6f81dc8d0bc07ff152b244e0958b5961.png?size=1024")
# await ctx.reply(embed = embed)
# sfsi_manager_accept_button = Button(label="Accept",style=discord.ButtonStyle.primary,emoji="✅",custom_id="acceptButton")
# view = View()
# view.add_item(sfsi_manager_accept_button)
# async def on_accept_button_click(interaction):
# embed = discord.Embed(
# title="test"
# )
# rank_1 = await ctx.guild.create_role(name="Rank 2",colour=discord.Colour(0x18FD08),hoist=True,mentionable=True)
# await ctx.author.add_roles(temp)
# view.clear_items()
# await interaction.response.send_message(temp)
# sfsi_manager_accept_button.callback = on_accept_button_click
# await ctx.reply(embed=embed,view=view)