Use Discord global_name as sim user displayname
This commit is contained in:
parent
999276e407
commit
44f90cbb5f
4 changed files with 57 additions and 2 deletions
|
@ -97,7 +97,7 @@ async function ensureSimJoined(user, roomID) {
|
||||||
*/
|
*/
|
||||||
async function memberToStateContent(user, member, guildID) {
|
async function memberToStateContent(user, member, guildID) {
|
||||||
let displayname = user.username
|
let displayname = user.username
|
||||||
// if (member.nick && member.nick !== displayname) displayname = member.nick + " | " + displayname // prepend nick if present
|
if (user.global_name) displayname = user.global_name
|
||||||
if (member.nick) displayname = member.nick
|
if (member.nick) displayname = member.nick
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
|
|
|
@ -22,6 +22,26 @@ test("member2state: without member nick or avatar", async t => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("member2state: with global name, without member nick or avatar", async t => {
|
||||||
|
t.deepEqual(
|
||||||
|
await _memberToStateContent(testData.member.papiophidian.user, testData.member.papiophidian, testData.guild.general.id),
|
||||||
|
{
|
||||||
|
avatar_url: "mxc://cadence.moe/JPzSmALLirnIprlSMKohSSoX",
|
||||||
|
displayname: "PapiOphidian",
|
||||||
|
membership: "join",
|
||||||
|
"moe.cadence.ooye.member": {
|
||||||
|
avatar: "/avatars/320067006521147393/5fc4ad85c1ea876709e9a7d3374a78a1.png?size=1024"
|
||||||
|
},
|
||||||
|
"uk.half-shot.discord.member": {
|
||||||
|
bot: false,
|
||||||
|
displayColor: 1579292,
|
||||||
|
id: "320067006521147393",
|
||||||
|
username: "@papiophidian"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test("member2state: with member nick and avatar", async t => {
|
test("member2state: with member nick and avatar", async t => {
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
await _memberToStateContent(testData.member.sheep.user, testData.member.sheep, testData.guild.general.id),
|
await _memberToStateContent(testData.member.sheep.user, testData.member.sheep, testData.guild.general.id),
|
||||||
|
|
34
test/data.js
34
test/data.js
|
@ -222,6 +222,40 @@ module.exports = {
|
||||||
},
|
},
|
||||||
mute: false,
|
mute: false,
|
||||||
deaf: false
|
deaf: false
|
||||||
|
},
|
||||||
|
papiophidian: {
|
||||||
|
avatar: null,
|
||||||
|
communication_disabled_until: null,
|
||||||
|
flags: 0,
|
||||||
|
joined_at: "2018-08-05T09:40:47.076000+00:00",
|
||||||
|
nick: null,
|
||||||
|
pending: false,
|
||||||
|
premium_since: "2021-09-30T18:58:44.996000+00:00",
|
||||||
|
roles: [
|
||||||
|
"475599410068324352",
|
||||||
|
"475599471049310208",
|
||||||
|
"497586624390234112",
|
||||||
|
"613685290938138625",
|
||||||
|
"475603310955593729",
|
||||||
|
"1151970058730487898",
|
||||||
|
"1151970058730487901"
|
||||||
|
],
|
||||||
|
unusual_dm_activity_until: null,
|
||||||
|
user: {
|
||||||
|
id: "320067006521147393",
|
||||||
|
username: "papiophidian",
|
||||||
|
avatar: "5fc4ad85c1ea876709e9a7d3374a78a1",
|
||||||
|
discriminator: "0",
|
||||||
|
public_flags: 4194880,
|
||||||
|
flags: 4194880,
|
||||||
|
banner: "a_6f311cf6a3851a98e2fa0335af85b1d1",
|
||||||
|
accent_color: 1579292,
|
||||||
|
global_name: "PapiOphidian",
|
||||||
|
avatar_decoration_data: null,
|
||||||
|
banner_color: "#18191c"
|
||||||
|
},
|
||||||
|
mute: false,
|
||||||
|
deaf: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pins: {
|
pins: {
|
||||||
|
|
|
@ -75,7 +75,8 @@ INSERT INTO file (discord_url, mxc_url) VALUES
|
||||||
('https://cdn.discordapp.com/emojis/230201364309868544.png', 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
|
('https://cdn.discordapp.com/emojis/230201364309868544.png', 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
|
||||||
('https://cdn.discordapp.com/emojis/393635038903926784.gif', 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc'),
|
('https://cdn.discordapp.com/emojis/393635038903926784.gif', 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc'),
|
||||||
('https://cdn.discordapp.com/attachments/176333891320283136/1157854643037163610/Screenshot_20231001_034036.jpg', 'mxc://cadence.moe/zAXdQriaJuLZohDDmacwWWDR'),
|
('https://cdn.discordapp.com/attachments/176333891320283136/1157854643037163610/Screenshot_20231001_034036.jpg', 'mxc://cadence.moe/zAXdQriaJuLZohDDmacwWWDR'),
|
||||||
('https://cdn.discordapp.com/emojis/1125827250609201255.png', 'mxc://cadence.moe/pgdGTxAyEltccRgZKxdqzHHP');
|
('https://cdn.discordapp.com/emojis/1125827250609201255.png', 'mxc://cadence.moe/pgdGTxAyEltccRgZKxdqzHHP'),
|
||||||
|
('https://cdn.discordapp.com/avatars/320067006521147393/5fc4ad85c1ea876709e9a7d3374a78a1.png?size=1024', 'mxc://cadence.moe/JPzSmALLirnIprlSMKohSSoX');
|
||||||
|
|
||||||
INSERT INTO emoji (emoji_id, name, animated, mxc_url) VALUES
|
INSERT INTO emoji (emoji_id, name, animated, mxc_url) VALUES
|
||||||
('230201364309868544', 'hippo', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
|
('230201364309868544', 'hippo', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
|
||||||
|
|
Loading…
Reference in a new issue