Mention system

Are you tired of pinging users in commands? Me too. That's why MaryuBot has his own mention system!



With MaryuBot, you don't need to ping users anymore. Instead, you can use:




Fun fact: Did you know that pings are formatted IDs? Go to a Discord chat, ping a user and put a \ (backslash) in front of it. There you have the user's ID! (It'll still ping the user though)





How does this work?

For all of you who think that we'll publish the code here... no, sorry. We'll tell you how it works, but you need to get the code running on your own :P



All commands only use four lines of code to identify the user! First, define what the users enters. Then, this input gets pushed into a function which returns the user. Next, if the function returns an error, stop the command. And if the function returns nothing, tell the user that that's an invalid user. Done!

Welp, actually you can't put such a complex mention system into four lines of code. Right at the top of the bot, there's the function that does all the work. And that isn't four lines long - it's 30 times as long. And that "little" function does a lot.

We start with the traditional mention system which is at the top of the function. This is used in +ship and +lovecalc, where you need to mention two users. The current mention system doesn't work there, therefore we need to use an alternative - ping the users. If the user is pinged, run a little piece of code to get the user and send it to the command. Done.

But of course, pinging is not the thing we want for all other commands. So, we'll now get the list of all users in the server. Ignore capitalization, get all usernames, tags, nicknames, IDs and pings and make a list. If the user input matches a list entry, give that user to the command. Else, ask the message author which user they mean. Then get that user and give it to the command. Done!

Well, the actual code is much more complicated than this. But, we don't want to annoy you with how that works. Let's go on with what happens when there are multiple users with the same name.





Multiple users with the same name

This is another important part of the mention system. The famous "Sorry, which user do you mean?" message. Here we'll tell you everything about it.



[GIF] Demo of the multiple user selection - https://www.maryubot.maryu.eu/assets/mention-system-multiple-users-demo.gif

If you have used MaryuBot already, you probably have seen this message. This is the user selection. This GIF has been recorded on a private server, where we got two MaryuBots. The original MaryuBot and the Alpha (our testing bot). The problem is: They are both named MaryuBot. The mention system now has two different users and therefore asks the message author for assistance.

You probably want to know what to do now. How about... read the message the bot sent. All you need to do is to write a new message with the number next to the user. In this example, 1 refers to MaryuBot and 2 refers to MaryuBot Alpha. Easy!

But you can also type in the user's full name instead of the number. MaryuBot#2563 would work as well.


[GIF] What you need to do when the bot throws this message at you - https://www.maryubot.maryu.eu/assets/mention-system-multiple-users-solve.gif




What happens if I do nothing?



If you do not reply within the next 45 seconds, the bot will cancel the selection.


[Image] The selection timer ran out - https://www.maryubot.maryu.eu/assets/mention-system-multiple-users-45seconds.png

You can also abort the selection on your own. Just tell it to "stop".


[Image] You aborted the selection - https://www.maryubot.maryu.eu/assets/mention-system-multiple-users-abort.png



Security

The mention system also has some security mechanisms which guarantee MaryuBot's functionality.



The thing with @everyone and @here


You know that guys who run +cookie @everyone or +hug @here out of nowhere? Since @everyone and @here aren't users, the command won't be executed. The mention system detects if @everyone or @here are being used.

In case you don't have permission to use the actual @everyone / @here:


[Image] You may not use @everyone and @here here - https://www.maryubot.maryu.eu/assets/mention-system-everyone-nopermission.png

And if you actually ping @everyone:


[Image] You should not use @everyone and @here in my commands - https://www.maryubot.maryu.eu/assets/mention-system-everyone-permission.png

Roles ping and channels ping

Sometimes, you (accidentally) ping the bot's role instead of the user. MaryuBot detects if the ping is a role or a channel and will tell you that only user pings are allowed.


[Image] Channel and role pings - https://www.maryubot.maryu.eu/assets/mention-system-nonuserpings.png



Issues and limitations

This system cannot be used on all commands (yet). Here are all the limitations.



This system cannot be used in +ship and +lovecalc because these commands need more than one user to work. To use those commands, ping the users. We're working on this issue and hope that we can fix it soon.

If a user's username consists 𝚘𝚞𝚝 𝚘𝚏 ꜱᴩᴇᴄɪᴀʟ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ 𝓵𝓲𝓴𝓮 𝓽𝓱𝓮𝓼𝓮 𝓱𝓮𝓻𝓮, the mention system won't always accept the user's input. We cannot fix this issue, so please ping users with special characters in their name.

If there are more known issues, we will list them here.