Use actual discord invites

This commit is contained in:
Jeremy Zhang 2017-05-24 03:41:12 +00:00
parent cd3864a6a4
commit 566a4d4be1
3 changed files with 7 additions and 5 deletions

View File

@ -232,8 +232,7 @@ def filter_guild_channel(guild_id, channel_id):
return chan return chan
return None return None
def get_online_discord_users(guild_id): def get_online_discord_users(guild_id, embed):
embed = discord_api.get_widget(guild_id)
apimembers = list_all_guild_members(guild_id) apimembers = list_all_guild_members(guild_id)
apimembers_filtered = {} apimembers_filtered = {}
for member in apimembers: for member in apimembers:
@ -379,10 +378,11 @@ def query_guild():
guild_id = request.args.get('guild_id') guild_id = request.args.get('guild_id')
if check_guild_existance(guild_id): if check_guild_existance(guild_id):
if check_user_in_guild(guild_id): if check_user_in_guild(guild_id):
widget = discord_api.get_widget(guild_id)
channels = get_guild_channels(guild_id) channels = get_guild_channels(guild_id)
discordmembers = get_online_discord_users(guild_id) discordmembers = get_online_discord_users(guild_id, widget)
embedmembers = get_online_embed_users(guild_id) embedmembers = get_online_embed_users(guild_id)
return jsonify(channels=channels, discordmembers=discordmembers, embedmembers=embedmembers) return jsonify(channels=channels, discordmembers=discordmembers, embedmembers=embedmembers, instant_invite=widget.get("instant_invite"))
abort(403) abort(403)
abort(404) abort(404)

View File

@ -163,6 +163,7 @@
fill_discord_members(guildobj.discordmembers); fill_discord_members(guildobj.discordmembers);
fill_authenticated_users(guildobj.embedmembers.authenticated); fill_authenticated_users(guildobj.embedmembers.authenticated);
fill_unauthenticated_users(guildobj.embedmembers.unauthenticated); fill_unauthenticated_users(guildobj.embedmembers.unauthenticated);
$("#instant-inv").attr("href", guildobj.instant_invite);
run_fetch_routine(); run_fetch_routine();
} }
@ -461,6 +462,7 @@
fill_discord_members(guildobj.discordmembers); fill_discord_members(guildobj.discordmembers);
fill_authenticated_users(guildobj.embedmembers.authenticated); fill_authenticated_users(guildobj.embedmembers.authenticated);
fill_unauthenticated_users(guildobj.embedmembers.unauthenticated); fill_unauthenticated_users(guildobj.embedmembers.unauthenticated);
$("#instant-inv").attr("href", guildobj.instant_invite);
fetchtimeout = setTimeout(run_fetch_routine, 5000); fetchtimeout = setTimeout(run_fetch_routine, 5000);
}); });
} else { } else {

View File

@ -47,7 +47,7 @@
<li><a class="subheader">Actions</a></li> <li><a class="subheader">Actions</a></li>
<li><a href="{{ url_for("user.administrate_guild", guild_id=guild['id']) }}" class="waves-effect" target="_blank" id="administrate_link" style="display: none;">Manage Guild Embed</a></li> <li><a href="{{ url_for("user.administrate_guild", guild_id=guild['id']) }}" class="waves-effect" target="_blank" id="administrate_link" style="display: none;">Manage Guild Embed</a></li>
<li><a href="https://discordapp.com/channels/{{ guild['id'] }}/" class="waves-effect" target="_blank">Open Server on Discordapp</a></li> <li><a id="instant-inv" href="#" class="waves-effect" target="_blank">Open Server on Discordapp</a></li>
<li><div class="divider"></div></li> <li><div class="divider"></div></li>