Need custom command options for discord bot without using slash commands - discord.js

Can I attach slash command options to a custom command like "?help" and not "/help"?

I’m not entirely sure that I know what you mean, but I’ll try to answer.
?help is something we call a message command. It’s basically a message and is received as a messageCreate event. The bot then filters all message events to only respond to those with the specified prefix (in this case “?”). The only thing a user can submit via a message is the message content, a string, and attachments, which are files. You can access that via .content. You can make the user submit arguments by typing space and then e. g. writing a category name (?help moderation) which you could then recognise with <Message>.content.split(“ “);.
/help is, when registered as such, a slash command (interaction). When received, the interactionCreate event is called. When you register a slash command, you can add options such as string, integer, member and so on. These are registered beforehand and only in because of that, discord knows what options to give the user. And yeah, after that, you can access these options via the interaction.
To sum up (if I understand you correctly), you can’t attach (slash command) options to message commands because they are handled differently by discord. You can, however, utilise spaces to use these options. (Slash Commands are not using spaces but rely only on these options.)
I hope this helps.

Related

Clickable command in text Discord

I saw a YouTube video that shows you a way to display a "slash command" on Discord (see Image 1)
by sending "</any text:0>" (not clickable). I tried with any number at the end and its still working. So I tested </a slash command in my bot:MY BOT ID> and it was still working but it is not clickable.
Does anyone know a way to make a clickable slash command like in verified Discord bot profiles?
I am not sure it's possible but if someone knows how to do it.
Thanx in advance.
You can't control the 'Try my commands' section from appearing on your bot's profile. Discord will generate that section for your bot after a while of your bot being online & used.
In order to put clickable slash command buttons as you've shown you need to use the application command ID, not the bot id. You can find that by clicking on the prompt:
You can then take that ID to form </fast:972289487818334212>, which will be a clickable form of slash command.
Please note that slash command ids are changed randomly and frequently on Discord's end.
For sub-commands, you can do as such:
</cool-bot settings:2046185065514240342>
The command ID can be found under message.data.id, when your server receives a command.

Send multi-line signature to Metamask via web3js

Checked all the similar questions suggested and couldn't find an answer, unfortunately.
Is there a way to send a multi-line message to metamask via web3.eth.personal.sign as the first parameter? (The problem is how to get multiple lines, not how to actually send a message there)
A more eloquent example of my question can be seen in the image attached. There are multiple paragraphs on separate lines: 'Welcome to OpenSea!', 'Click "Sign" to sign in..." etc.
Thanks a lot!
You can either use \n or use instead of '' or "" when you send the message. The option with takes the spacing in the content into consideration (in js).

How to make my discord.js bot show how many servers it is in as it's status

I'd like to have my bot have a status that says how many servers it's in.
For example, in 6753421 guilds. I figure you'd make a separate section of code and add ${} to the status with the name of the function in it.
You need to use client.setActivity() and then use the client.guilds.cache.size value.
For example:
client.setActivity(`serving ${client.guilds.cache.size} servers`);

mail clients stripping part of angular url

I am sending a signup activation email containing a signup confirmation url with a confirmation token that points to an angular front end app:
...
Activate
...
Note that the token is a JWT and is fairly long.
This works find for most users, but for some clicking on the link takes them to https://domain/com only without the confirm-signup?token=...
It seems as though the mail client may be stripping off everything after the #, but I can't find any evidence of others having this problem, nor can I reproduce it.
My best guess so far is that some mail clients are seeing the # and somehow treating the trailing part as an internal anchor and stripping it...?
Has anyone else encountered this sort of problem? If so, have you found any solution short of replacing the whole mechanism with something else?
Some clients treat the hash-link just fine. Others don't. There's a conversation about Outlook being dirty about this here: Outlook strips URL hash from email
What we did to resolve this at our company is simply create a handler on our server that redirects. Your email link would become http://domain.com/email-link?url=https%3A%2F%2Fdomain.com%2F%23%2Fconfirm-signup%3Ftoken%3D1234 and your server side script would grab the query param url and immediately trigger a redirect.
You'd need to make sure that you find all links in your emails and replace them. Here's a PHP function for that, but you could do this in whatever backend language you're using. Regex here may be helpful at least.
function replaceLinks($html,$hash) {
return preg_replace_callback('/<a [^>]*href=[\"\']{1}(.+?)[\"\\\']{1}/', function($matches) use ($hash) {
return str_replace($matches[1],"http://domain.com/email-link?url=".rawurlencode($matches[1]),$matches[0]);
}, $html);
}
Yes I have encountered this issue before because of the #, I was trying to link to a anchor on a landingpage.. My solution ended up using a short.url service to "hide" the # from the html e.g. https://goo.gl/
Looks like you need percent encoding!
A lot of times when your href gets parsed (by angular in this case) it doesn't handle the special characters right, or strips them. Find your problem characters and replace them with %3F for ?, %26 for &, and %23 for #. The rest are in a chart in the link.
Once the encoded address hits the browser the url will be decoded in your url bar.

DotNetNuke Event Logging format

Using DotNetNuke 5.
I am using the EventLogController along with LogInfo to add custom messages to the event logs in dot net nuke.
Within LogInfo we have a method to Add a Property/Value. I am under the assumption that the Controller.AddLog(logInfo) converts the properties & vlaues into XML using the LogInfo->Serialize method for DNN to store it.
My problem is that I want linebreaks in my message. Is there anyway I can add a newline. "\r\n" wouldn't work, wouldn't work, CDATA escaped wouldn't work. Everything gets escaped through the Log function.
How do I pretty print the log message myself?
Regards, V
Sadly, due to the HTML encoding that is done on all messages, you are going to be out of luck trying to do this in the DNN event Log.
Depending on what/where you are, you have a few options.
You can add them as individual detail lines using properties, see my example below.
You could report on something yourself, using a custom log table or something similar
If you are in the context of a Scheduled Job, you can log to that history, which is NOT escaped.
Examples
Log Properties
objLog = new DotNetNuke.Services.Log.EventLog.LogInfo();
objLog.AddProperty("SecureMyInstall", "Phase 2 Error Processing User Accounts");
objLog.LogTypeKey = DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
objLogger.AddLog(objLog);
The content of the logs is displayed as HTML, so you should be able to put <br /> to add line breaks.

Resources