-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add copy discord id button to player menu #829
Conversation
doesn't player cache also include identifiers? we could probably remove the entire serverside portion of this, check if the player has a discord id available and then display the button and copy it to clipboard, i dont think we would really need a permission to do that |
It does cache but it's an array of idents - maybe we can just have a cachedplayers.discord or something similar for ease of access because otherwise we'd have to get the idents, then loop and handle if it's present or not |
for i,identifier in pairs(CachedPlayers[playerId].identifiers) do
if string.sub(identifier,1,8)=="discord:" then
local copyDiscordItem = NativeUI.CreateItem(GetLocalisedText("copydiscord"), "")
thisPlayer:AddItem(copyDiscordItem)
copyDiscordItem.Activated = function(ParentMenu, SelectedItem)
copyToClipboard(string.gsub(identifier, "discord:", ""))
TriggerEvent("EasyAdmin:showNotification", GetLocalisedText("copiedtoclipboard"))
end
end
end only issue i can think of is that this would break for clients that dont have access to cache (e.g. missing |
Take a look at those commits - it pulls the discord from the cache as requested, also cleaned up some un-needed loops in favour of quick local tables |
awesome! i'll quickly get fivem running on my windows partition and give it a whirl. By the way, do you plan to do any more PRs in the near future -- just so i know if i should delay 7.2 until that's done or not. |
No worries, i ran this on my local didn't notice any initial issues - and i'm not sure honestly i just get random ideas or for this case someone asked me for my code on this copy discord id as i have it in my server on a local fork and i was like might as well put it public as i assume many will want it - i wouldn't delay anything for now |
sounds good! i'll merge this within the hour and then push 7.2 in the coming days, thank you for your continued contributions, they are much appreciated! |
No problem, thanks for your time - i've just managed to get into your discord as the invite wasn't working before, mind checking for me? |
Adds a simple copy discord id button to the player menu inside player management.
Easy, convenient and helpful for server staff - primary identifier for most servers and allows staff to quickly find said player in a server log or if they need to assist them.
Adds new permission
player.copydiscord
but it doesn't even really need one as identifiers of players are public via theplayers.json
endpoint - so up to you if we keep this permission, can be easily removed of course.