How do I mention a role with Discord.js? - node.js

I am making a bot and I am trying to Ping a certain role. Here is the relevant code:
let msga = msg.author;
msg.channel.send("#NES Found one!! " + msga);
#NES is the role I am trying to ping/mention.

The currently accepted answer is incorrect. You ping a user with <#id>, not a role.
As stated in this Github issue, for roles, you have to use <#&id> and the role has to be pingable.
So, the correct code for the question would be something like:
msg.channel.send("<#&" + roleId + "> Found one!! " + msga);
Or, using fancy formatted strings:
msg.channel.send(`<#&${roleId}> Found one!! ${msga}`);

Just add an opening and closing angle bracket and use the role id to make the mention.
msg.channel.send("<#id> Found one!! " + msga);
This answer was valid for older versions of discord.js (I believe v11 and under) but is now invalid for v12+ use yummypasta's solution for the newer versions.

It is:
message.channel.send(`<#& id >`);

try this:
msg.channel.send(`<#&${'roleId'}> Found one!! ${msga}`);

Related

Microsoft Graph filter on a displayName with + in it

We have automation code that has been running for quire some time now.
The code retrieves a specified Azure AD Group by displayName. In some cases, the displayName contains a + sign. Until recently, that was not an issue, but now the query returns nothing, it we query the displayName with a + in it.
The uri looks like this:
https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'My Group with a + in it')
If we only query the part up to the + sign, the group is returned as expected.
https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'My Group with a')
This has been working, but we would be more then happy with a solution that enables us to just escape the + sign and get the payload. We have tried url-encoding the uri without any luck.
I can reproduce your issue, to fix it, just url-encode the + sign with %2B, refer to the sample below.
In my sample, my group named joytest+group, I filter it with joytest+g, encode the + sign, then it will be joytest%2Bg.
GET https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'joytest%2Bg')
Test in the Graph Explorer, it works fine.

#DbLookup formula in dialog list: Server error: Entry not found in index

As usual, I am trying to populate my Dialog List field by using #-formula in it:
server:="WPRServer/Un";
dbPath:="Region/Users.nsf";
viewName:="Search_users";
#DbLookup("":"NoCache"; server:dbPath; viewName; "myKey"; 2)
But every time I am getting the error in my field:
Server error: Entry not found in index
I have tryed to use this formula to this field with another database on other server with different key names, but I am getting this error on this field again.
I have updated the views with CTRL + SHIFT + F9.
Tryed to update the current db design.
Recompiled LS and all views.
This is very strange, because I am using the similar formulas in other databases and everything is working fine every time.
Can you please give some small advise what is the way to fix this issue or maybe I am doing something incorrect? Thank you.
Update 17.09.2018:
1. The view Search_users is sorted.
2. I am using Windows server, and tryed to add **\** slashes and It helped to solve this issue, now I am getting this error:
This database is currently in use by another person or process, and cannot be accessed at this time. In order to share a Notes database, it must be accessed via a Domino Server by all users of the database.
I have tryed to reset all current accesses to this database with Domino Administrator tool, nothing helped - still getting this error in my Dialog List.
3. #DbColumn formula works fine with this view.
4. Also, already tryed to compact the database, no changes.
This may show you what the issue is:
server:="WPRServer/Un";
dbPath:="Region/Users.nsf";
viewName:="Search_users";
searchkey := "myKey";
rslt := #DbLookup("":"NoCache"; server:dbPath; viewName; searchkey; 2);
#If(#IsError(rslt); #Text(rslt) + " for:[" + searchkey + "]"; rslt);
Anticipation and handling error conditions.

Docusign API PHP adding listitem to document causes error

I am sure I am not the first to encounter this, but I was unable to find a solution while Googling.
I am trying to add a drop-down list to my document. At the top of my model I am adding these namespaces:
use \DocuSign\eSign\Model\List;
use \DocuSign\eSign\Model\ListItem;
When doing so I get this error because "List" is a reserved word in PHP.
A PHP Error was encountered
Severity: Parsing Error
Message: syntax error, unexpected List (T_LIST), expecting identifier (T_STRING)
Filename: models/Docusign_model.php
Line Number: 19
I tried changing the name of the class from List to Elist but then I got errors from ObjectSerializer that it could not find Elist:swaggerType.
What am I missing on how to add a list to my document?
Thom
#thom I think this is really a "PHP" parsing question as is answered here for you Parse error: syntax error, unexpected (T_STRING), expecting variable (T_VARIABLE)
So I think the $ missing is your real issue as discussed in the referenced article above and below from PHP Manual.
http://www.php.net/manual/en/language.oop5.basic.php
Recommend you look at GIT example from SDK using CustomFieldList at https://github.com/docusign/docusign-php-client/blob/ccc86ac37334f34728361d73b2f8c4592225b8d2/src/Model/CustomFieldsEnvelope.php
excerpt
protected static $swaggerTypes = [
'list_custom_fields' => '\DocuSign\eSign\Model\ListCustomField[]',
'text_custom_fields' => '\DocuSign\eSign\Model\TextCustomField[]'
];
http://www.php.net/manual/en/language.oop5.basic.php
Also, maybe the first place to validate if you even need a specific "use" is by reviewing this PHP sample code from a good friend Ergin https://gist.github.com/Ergin008/d4a8b9210fbea41414b0
As I see it with most of the DocuSign SDK's, you have the client and specific services you want to use per excerpt below:
// Download PHP client: https://github.com/docusign/DocuSign-PHP-Client
require_once './DocuSign-PHP-Client/src/DocuSign_Client.php';
require_once './DocuSign-PHP-Client/src/service/DocuSign_RequestSignatureService.php';
require_once './DocuSign-PHP-Client/src/service/DocuSign_ViewsService.php';
Regardless if I am right or wrong, let us know if this helped you go in the right direction :-)

Gamemaker variable using porals

I am remaking portal in gamemaker for my semester final, I was wondering how you find an object, if I have one portal down, and go into it, the game crashes, as the 2nd portal isn't placed, and it can't get its .x,.y pos. How do I set a variable to fix this?
We don't know how you determine the destination teleporter, you should clarify that. But one variant could be to check whether the amount of portals is >= 2, so you have at least one place to go
if (instance_number(your_portal_name) >= 2)
{
// proceed the portal mechanics
}
I assume that in some event you have a piece of code that does the teleporting. You just have to place this piece of code in an "if" statement that verifies if the second portal exists. This way, you will attempt teleportation only if the needed exit instance exists. You can use the "instance_exists" function
for example :
if ( instance_exists( exit_portal_or_whatever_you_name_it ) )
{
your_teleportation_code;
}
I would say that based on the information you gave us, German Gorodnev's answer is correct. If you only have one portal and you try to get the position of a non-existent portal, then you will get an error. So you should include an if statement that makes sure the needed portals are there before retrieving the positions.

How to translate error messages in Colander

How can I translate the error messages from the colander validators? The documentation just says that it's possible.
def valid_text(node, value):
raise Invalid(node, u"Some error message")
class form(colander.MappingSchema):
name = colander.SchemaNode(colander.String(), validator=valid_text)
I know that deform does it already but I need to use colander on his own.
According to the API documentation, the msg argument to Invalid can be a translation string instance. Information on working with translation strings is here.
Looks like this issue was already addressed and fixed, but it will be part of the next release. I've just added the changes from commit f6be836 and it works like a charm.

Resources