mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 06:03:03 -04:00
Fix some plugins displaying legacy discriminators (username#0000)
This commit is contained in:
parent
214c101740
commit
d7ac418e05
8 changed files with 71 additions and 35 deletions
|
@ -17,9 +17,9 @@
|
|||
*/
|
||||
|
||||
import { MessageObject } from "@api/MessageEvents";
|
||||
import { findByPropsLazy, findLazy } from "@webpack";
|
||||
import { ChannelStore, ComponentDispatch, GuildStore, MaskedLink, ModalImageClasses, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { Guild, Message } from "discord-types/general";
|
||||
import { findByCodeLazy, findByPropsLazy, findLazy } from "@webpack";
|
||||
import { ChannelStore, ComponentDispatch, GuildStore, MaskedLink, ModalImageClasses, PrivateChannelsStore, SelectedChannelStore, SelectedGuildStore, UserUtils } from "@webpack/common";
|
||||
import { Guild, Message, User } from "discord-types/general";
|
||||
|
||||
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
||||
|
||||
|
@ -99,3 +99,28 @@ export function openImageModal(url: string, props?: Partial<React.ComponentProps
|
|||
</ModalRoot>
|
||||
));
|
||||
}
|
||||
|
||||
const openProfile = findByCodeLazy("friendToken", "USER_PROFILE_MODAL_OPEN");
|
||||
|
||||
export async function openUserProfile(id: string) {
|
||||
const user = await UserUtils.fetchUser(id);
|
||||
if (!user) throw new Error("No such user: " + id);
|
||||
|
||||
const guildId = SelectedGuildStore.getGuildId();
|
||||
openProfile({
|
||||
userId: id,
|
||||
guildId,
|
||||
channelId: SelectedChannelStore.getChannelId(),
|
||||
analyticsLocation: {
|
||||
page: guildId ? "Guild Channel" : "DM Channel",
|
||||
section: "Profile Popout"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique username for a user. Returns user.username for pomelo people, user.tag otherwise
|
||||
*/
|
||||
export function getUniqueUsername(user: User) {
|
||||
return user.discriminator === "0" ? user.username : user.tag;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue