mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Automatically fetching data with the server
This commit is contained in:
parent
8a441720a0
commit
9527ef53e5
@ -20,7 +20,6 @@ def get_logingreeting():
|
||||
|
||||
@embed.route("/<string:guild_id>")
|
||||
def guild_embed(guild_id):
|
||||
print guild_id
|
||||
if check_guild_existance(guild_id):
|
||||
guild = discord_api.get_guild(guild_id)['content']
|
||||
return render_template("embed.html.j2",
|
||||
|
@ -109,6 +109,8 @@ function prepare_guild(guildobj) {
|
||||
fill_discord_members(guildobj.discordmembers);
|
||||
fill_authenticated_users(guildobj.embedmembers.authenticated);
|
||||
fill_unauthenticated_users(guildobj.embedmembers.unauthenticated);
|
||||
console.log("running fetch routine");
|
||||
run_fetch_routine();
|
||||
}
|
||||
|
||||
function fill_channels(channels) {
|
||||
@ -176,6 +178,34 @@ function _wait_for_discord_login(index) {
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function run_fetch_routine() {
|
||||
var channel_id = guild_id; //TODO: implement channel selector
|
||||
var fet = fetch(channel_id);
|
||||
fet.done(function(data) {
|
||||
console.log(data);
|
||||
|
||||
var guild = query_guild();
|
||||
guild.done(function(guildobj) {
|
||||
fill_channels(guildobj.channels);
|
||||
fill_discord_members(guildobj.discordmembers);
|
||||
fill_authenticated_users(guildobj.embedmembers.authenticated);
|
||||
fill_unauthenticated_users(guildobj.embedmembers.unauthenticated);
|
||||
setTimeout(run_fetch_routine, 10000);
|
||||
});
|
||||
});
|
||||
fet.fail(function(data) {
|
||||
if (data.status == 403) {
|
||||
$('#loginmodal').modal('open');
|
||||
Materialize.toast('Authentication error! You have been banned.', 10000);
|
||||
}
|
||||
if (data.status == 401) {
|
||||
$('#loginmodal').modal('open');
|
||||
Materialize.toast('Session expired! You have been logged out.', 10000);
|
||||
}
|
||||
setTimeout(run_fetch_routine, 10000);
|
||||
});
|
||||
}
|
||||
|
||||
$("#discordlogin_btn").click(function() {
|
||||
lock_login_fields();
|
||||
wait_for_discord_login();
|
||||
|
Loading…
Reference in New Issue
Block a user