mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Support mentions for offline members
This commit is contained in:
parent
5dc1c01db4
commit
105fe24a40
@ -176,6 +176,20 @@ def get_channel_webhook_url(guild_id, channel_id):
|
|||||||
webhook = discord_api.create_webhook(channel_id, name)
|
webhook = discord_api.create_webhook(channel_id, name)
|
||||||
return webhook["content"]
|
return webhook["content"]
|
||||||
|
|
||||||
|
def get_all_users(guild_id):
|
||||||
|
users = db.session.query(GuildMembers).filter(GuildMembers.guild_id == guild_id, GuildMembers.active == True).all()
|
||||||
|
mem = []
|
||||||
|
for u in users:
|
||||||
|
mem.append({
|
||||||
|
"id": str(u.user_id),
|
||||||
|
"avatar": u.avatar,
|
||||||
|
"avatar_url": generate_avatar_url(u.user_id, u.avatar, u.discriminator, True),
|
||||||
|
"username": u.username,
|
||||||
|
"nickname": u.nickname,
|
||||||
|
"discriminator": u.discriminator
|
||||||
|
})
|
||||||
|
return mem
|
||||||
|
|
||||||
@api.route("/fetch", methods=["GET"])
|
@api.route("/fetch", methods=["GET"])
|
||||||
@valid_session_required(api=True)
|
@valid_session_required(api=True)
|
||||||
@abort_if_guild_disabled()
|
@abort_if_guild_disabled()
|
||||||
@ -393,10 +407,11 @@ def process_query_guild(guild_id, visitor=False):
|
|||||||
emojis = get_guild_emojis(guild_id)
|
emojis = get_guild_emojis(guild_id)
|
||||||
roles = get_guild_roles(guild_id)
|
roles = get_guild_roles(guild_id)
|
||||||
guest_icon = get_guild_guest_icon(guild_id)
|
guest_icon = get_guild_guest_icon(guild_id)
|
||||||
|
all_users = get_all_users(guild_id)
|
||||||
if visitor:
|
if visitor:
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
channel["write"] = False
|
channel["write"] = False
|
||||||
return jsonify(channels=channels, discordmembers=discordmembers, embedmembers=embedmembers, emojis=emojis, roles=roles, guest_icon=guest_icon, instant_invite=widget.get("instant_invite", None))
|
return jsonify(channels=channels, discordmembers=discordmembers, embedmembers=embedmembers, allusers=all_users, emojis=emojis, roles=roles, guest_icon=guest_icon, instant_invite=widget.get("instant_invite", None))
|
||||||
|
|
||||||
@api.route("/query_guild", methods=["GET"])
|
@api.route("/query_guild", methods=["GET"])
|
||||||
@valid_session_required(api=True)
|
@valid_session_required(api=True)
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
var notification_sound_setting; // nothing, mentions, newmsgs - to control what new sound it makes
|
var notification_sound_setting; // nothing, mentions, newmsgs - to control what new sound it makes
|
||||||
var display_richembeds; // true/false - if rich embeds should be displayed
|
var display_richembeds; // true/false - if rich embeds should be displayed
|
||||||
var guild_roles_list = []; // List of all guild roles
|
var guild_roles_list = []; // List of all guild roles
|
||||||
|
var all_users = []; // List of all the users in guild
|
||||||
|
|
||||||
function element_in_view(element, fullyInView) {
|
function element_in_view(element, fullyInView) {
|
||||||
var pageTop = $(window).scrollTop();
|
var pageTop = $(window).scrollTop();
|
||||||
@ -496,6 +497,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prepare_guild(guildobj) {
|
function prepare_guild(guildobj) {
|
||||||
|
all_users = guildobj.allusers;
|
||||||
global_guest_icon = guildobj.guest_icon;
|
global_guest_icon = guildobj.guest_icon;
|
||||||
emoji_store = guildobj.emojis;
|
emoji_store = guildobj.emojis;
|
||||||
update_emoji_picker();
|
update_emoji_picker();
|
||||||
@ -1471,12 +1473,12 @@
|
|||||||
var template = $('#mustache_usermentionchoices').html();
|
var template = $('#mustache_usermentionchoices').html();
|
||||||
Mustache.parse(template);
|
Mustache.parse(template);
|
||||||
var users = [];
|
var users = [];
|
||||||
for (var i = 0; i < discord_users_list.length; i++) {
|
for (var i = 0; i < all_users.length; i++) {
|
||||||
var usr = discord_users_list[i];
|
var usr = all_users[i];
|
||||||
if (usr.username.toLowerCase().indexOf(lastWord.toLowerCase()) > -1 || (usr.nick && usr.nick.toLowerCase().indexOf(lastWord.toLowerCase()) > -1)) {
|
if (usr.username.toLowerCase().indexOf(lastWord.toLowerCase()) > -1 || (usr.nickname && usr.nickname.toLowerCase().indexOf(lastWord.toLowerCase()) > -1)) {
|
||||||
var displayname = usr.username;
|
var displayname = usr.username;
|
||||||
if (usr.nick) {
|
if (usr.nick) {
|
||||||
displayname = usr.nick;
|
displayname = usr.nickname;
|
||||||
}
|
}
|
||||||
users.push({
|
users.push({
|
||||||
id: usr.id,
|
id: usr.id,
|
||||||
@ -1715,6 +1717,14 @@
|
|||||||
discord_users_list.push(usr);
|
discord_users_list.push(usr);
|
||||||
fill_discord_members(discord_users_list);
|
fill_discord_members(discord_users_list);
|
||||||
}
|
}
|
||||||
|
all_users.push({
|
||||||
|
"id": usr.id,
|
||||||
|
"avatar": usr.avatar,
|
||||||
|
"avatar_url": generate_avatar_url(usr.user_id, usr.avatar),
|
||||||
|
"username": usr.username,
|
||||||
|
"nickname": usr.nickname,
|
||||||
|
"discriminator": usr.discriminator
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("GUILD_MEMBER_UPDATE", function (usr) {
|
socket.on("GUILD_MEMBER_UPDATE", function (usr) {
|
||||||
@ -1722,6 +1732,19 @@
|
|||||||
update_socket_channels();
|
update_socket_channels();
|
||||||
socket.emit("current_user_info", {"guild_id": guild_id});
|
socket.emit("current_user_info", {"guild_id": guild_id});
|
||||||
}
|
}
|
||||||
|
var updatedUser = false;
|
||||||
|
for (var i = 0; i < all_users.length; i++) {
|
||||||
|
if (usr.id == all_users[i].id) {
|
||||||
|
var u = all_users[i];
|
||||||
|
u.avatar = usr.avatar;
|
||||||
|
u.avatar_url = generate_avatar_url(usr.user_id, usr.avatar);
|
||||||
|
u.username = usr.username;
|
||||||
|
u.nickname = usr.nickname;
|
||||||
|
u.discriminator = usr.discriminator;
|
||||||
|
updatedUser = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (var i = 0; i < discord_users_list.length; i++) {
|
for (var i = 0; i < discord_users_list.length; i++) {
|
||||||
if (usr.id == discord_users_list[i].id) {
|
if (usr.id == discord_users_list[i].id) {
|
||||||
discord_users_list.splice(i, 1);
|
discord_users_list.splice(i, 1);
|
||||||
@ -1734,14 +1757,30 @@
|
|||||||
}
|
}
|
||||||
discord_users_list.push(usr);
|
discord_users_list.push(usr);
|
||||||
fill_discord_members(discord_users_list);
|
fill_discord_members(discord_users_list);
|
||||||
|
if (!updatedUser) {
|
||||||
|
all_users.push({
|
||||||
|
"id": usr.id,
|
||||||
|
"avatar": usr.avatar,
|
||||||
|
"avatar_url": generate_avatar_url(usr.user_id, usr.avatar),
|
||||||
|
"username": usr.username,
|
||||||
|
"nickname": usr.nickname,
|
||||||
|
"discriminator": usr.discriminator
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("GUILD_MEMBER_REMOVE", function (usr) {
|
socket.on("GUILD_MEMBER_REMOVE", function (usr) {
|
||||||
|
for (var i = 0; i < all_users.length; i++) {
|
||||||
|
if (usr.id == all_users[i].id) {
|
||||||
|
all_users.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (var i = 0; i < discord_users_list.length; i++) {
|
for (var i = 0; i < discord_users_list.length; i++) {
|
||||||
if (usr.id == discord_users_list[i].id) {
|
if (usr.id == discord_users_list[i].id) {
|
||||||
discord_users_list.splice(i, 1);
|
discord_users_list.splice(i, 1);
|
||||||
fill_discord_members(discord_users_list);
|
fill_discord_members(discord_users_list);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user