Skip to content

refactor: Standardize Mention formatting helpers#379

Open
Kiruyuto wants to merge 6 commits into
NetCordDev:mainfrom
Kiruyuto:feat/add-tostring-override-convenience
Open

refactor: Standardize Mention formatting helpers#379
Kiruyuto wants to merge 6 commits into
NetCordDev:mainfrom
Kiruyuto:feat/add-tostring-override-convenience

Conversation

@Kiruyuto

Copy link
Copy Markdown

No description provided.

@Kiruyuto Kiruyuto changed the title feat: Add mention formatting for RegisteredApplicationCommands refactor: Standardize Mention formatting helpers Jun 29, 2026

@KubaZ2 KubaZ2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it also may be a good idea to add for example Mention.Timestamp and Mention.TryFormatTimestamp overloads. I think they can just call the Timestamp.ToString() and Timestamp.TryFormat methods on the passed Timestamp. It would be just for completeness. There may also be some other methods missing. I think it would be nice to provide all of them via the Mention class, similar to the application command methods, in this refactor.

Comment thread NetCord/Mention.cs Outdated
Comment thread NetCord/Mention.cs Outdated
Comment on lines +166 to +191
public static string ApplicationCommand(string fullName, ulong id)
{
return string.Create(
length: 4 + fullName.Length + CountDigits(id),
state: (Id: id, FullName: fullName),
action: static (destination, state) => TryFormatApplicationCommand(destination, out _, state.Id, state.FullName)
);
}

public static string ApplicationCommand(string name, string subCommandName, ulong id)
{
return string.Create(
length: 5 + name.Length + subCommandName.Length + CountDigits(id),
state: (Id: id, Name: name, SubCommandName: subCommandName),
action: static (destination, state) => TryFormatApplicationCommand(destination, out _, state.Id, state.Name, state.SubCommandName)
);
}

public static string ApplicationCommand(string name, string subCommandGroupName, string subCommandName, ulong id)
{
return string.Create(
length: 6 + name.Length + subCommandGroupName.Length + subCommandName.Length + CountDigits(id),
state: (Id: id, Name: name, SubCommandGroupName: subCommandGroupName, SubCommandName: subCommandName),
action: static (destination, state) => TryFormatApplicationCommand(destination, out _, state.Id, state.Name, state.SubCommandGroupName, state.SubCommandName)
);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the API. I think fullName is quite confusing since there is no overload with just name. I think it may be a good idea to leave the fullName (that is a space separated list of names) an implementation detail and just expose a string ApplicationCommand(string name, ulong id) method. And then create an internal method like string ApplicationCommandCore(string fullName, ulong id) that ApplicationCommandOption. uses. Then the string ApplicationCommand(string name, ulong id) could use it as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but Im not sure if this is what you were aiming for. Leaving the conversation open for now, lmk if this is it

Comment thread NetCord/Mention.cs Outdated
@github-actions

Copy link
Copy Markdown

The documentation preview is available at https://preview.netcord.dev/379.

@Kiruyuto Kiruyuto requested a review from KubaZ2 June 30, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants