ShowMeYourName: Option to use display names instead of usernames (#1634)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
3b8b43c7e0
commit
c79e065d09
1 changed files with 10 additions and 3 deletions
|
@ -40,6 +40,11 @@ const settings = definePluginSettings({
|
||||||
{ label: "Username only", value: "user" },
|
{ label: "Username only", value: "user" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
displayNames: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Use display names in place of usernames",
|
||||||
|
default: false
|
||||||
|
},
|
||||||
inReplies: {
|
inReplies: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -50,7 +55,7 @@ const settings = definePluginSettings({
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ShowMeYourName",
|
name: "ShowMeYourName",
|
||||||
description: "Display usernames next to nicks, or no nicks at all",
|
description: "Display usernames next to nicks, or no nicks at all",
|
||||||
authors: [Devs.dzshn],
|
authors: [Devs.dzshn, Devs.TheKodeToad],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: ".withMentionPrefix",
|
find: ".withMentionPrefix",
|
||||||
|
@ -63,9 +68,11 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
renderUsername: ({ author, message, isRepliedMessage, withMentionPrefix }: UsernameProps) => {
|
renderUsername: ({ author, message, isRepliedMessage, withMentionPrefix }: UsernameProps) => {
|
||||||
if (message.interaction) return author?.nick;
|
|
||||||
try {
|
try {
|
||||||
const { username } = message.author;
|
let { username } = message.author;
|
||||||
|
if (settings.store.displayNames)
|
||||||
|
username = (message.author as any).globalName || username;
|
||||||
|
|
||||||
const { nick } = author;
|
const { nick } = author;
|
||||||
const prefix = withMentionPrefix ? "@" : "";
|
const prefix = withMentionPrefix ? "@" : "";
|
||||||
if (username === nick || isRepliedMessage && !settings.store.inReplies)
|
if (username === nick || isRepliedMessage && !settings.store.inReplies)
|
||||||
|
|
Loading…
Reference in a new issue