Store data in discord message for button component - discord

I want to make a simple bot that does some things when someone clicks a list item.
To make this possible I need to store the list item's id in the message. I didn't see any ways to store data in a message without showing it, so I added it to the footer and when the button triggers it gets the first embed's footer in the interaction's message.
My problem with this solution is that it looks bad.
Collectors are not an option because these list items are sent to a channel once when the channel is created, and if the bot restarts the collectors won't trigger.
How would you guys solve this?
Thanks!

Okay I solved this. I don't know how I've never thought of this before.
Basically I created a table in my database that has 2 columns:
discord message id
data
When I send the message to the channel I just store the data with the message's id. When the user clicks the button I just retrieve the data by the message id.

Related

Discord.js Animated Emojis

I have a bot, and I want to use it to send a animated emoji.
I have the emoji ID, <:rgb_lego:993606148580184154>
but whenever I make it send the message, it just says
Pong! 🏓 The round trip took 76ms. ⚡:rgb_lego:
what am I doing wrong?
It depends on what server (guild) you sent it and how exactly you do it.
Guess you need to check & fetch the requested custom emojie from server and then sent it.
You might wanna check Discord.js docs for that. But if I remember it correctly, emojies should be accessed by bot via:
client.guild.emojis.[methodName] via GuildEmojiManager
The second problem could be relevant to the server, where you want to sent it, doesn't have the required emojie, so in that case it has been delivered as a text ref, not an emojie itself or the bot account doesn't have premium features required for using emojies or so on.

New to Azure Event Grid - trying to react to *any* object being created, deleted or modified

I'm completely new to Event Grid, but have been tasked with creating a way to track anytime any object is created, deleted, or modified within a subscription (additional noise filtering to be added later). Does this sound like I'm on the right track?
Logic App -> Workflow Designer:
When a resource event occurs:
Resource Type - Microsoft.Resources.Subscriptions
Resource Name - (subscription being watched)
Event Type Item - 1
Microsoft.Resources.ResourceDeleteSuccess
Event Type Item - 2
Microsoft.Resources.ResourceWriteSuccess
What I'm completely unclear on is how to output the object deleted/created/modified. Like write to a log or send an email "X" object was deleted by Y user. If anyone has a clue on that, I would greatly appreciate it. Or if there is an easier way to accomplish this, rather than using Event Grid, I'm open to suggestions.
WAY-1
Here is my Logic App flow
I'm using Outlook 365 Connector with Send an Email Action
The Event Data gives whole information on What, When and Who created/modified/Deleted the resource.
Here is the screenshot of the mail that I received.
you can add as many events as possible by clicking Add New Item
WAY-2
You can add logs to your storage account and check the details from there as below.
WAY-3
You can check it in the logs from Overview pane which gives complete details on particular Run Triggers.

ExtJS synchronize record between clients

I'm trying to do something fun: I'd like to send the record changes from one client to another and have the second client updated to show these changes. Basically collaborative viewing. The second client is disabled from making changes, he can only watch.
Simple fields like strings, numbers, checkboxes, etc. are easy, that worked right away.
The references are the problem. If I have a combo that uses another model as it's source, I am unable to update it on the second client.
I tried setting just the id, then the entire referenced object, I tried various set options, but simply no dice.
The record does change, I see that the data is updated, I was even able to manually modify the _ reference attributes, but the UI keeps showing the old values for those fields.
Is there a way to send the record from one client to another and have the other client just take over all values and display them in the UI? (it would be better to send just the changes, but I'd be very happy if I could get it to work with the entire record)
EDIT: I'm using SailsJS with socket.io, so the p2p connection is not the issue.
I'm getting the data like this:
var data = record.getData(true);
broadcastRecord(data);
And on the other side I tried:
record.set(data);
A code example for the receiving side would be appreciated, if anyone has an ide how to solve this...
I think your problem is related to associations and comboboxes.
Let's say you have a model User with a field group that references model Group, and that you have a User form with a Group combobox.
In the receiver client, you are probably getting only the group id. record.set(data) updates the bound combobox calling setValue(groupId).
This setValue will try to find the corresponding record inside its store, but it won't ask server-side for that record. Instead, it will create a new record with the passed id (showing an empty combobox).
If possibile, you can set remoteFilter:false to the store and queryMode:'local' on the combobox and preload all the data from that store.
Otherwise, I think you'll have to override the combobox setValue method to get the record remotely.

How to retrieve message based on uuid in PUBNUB?

How can we get the list of incoming messages to a particular user based on uuid ?
What need is to show the list of message for a particular user based on uuid , from all the channel the user is subscribed?
The requirement is to list the incoming message of a particular user. Same as the one we see in facebook message icon on right side
The available solution what i got is
1) get the channellist with uuid
PubNub.ngWhereNow()
2) get message from the channels return from the ngWhereNow
I need help to sort out whether there is any single api to get all the incoming message to based on uuid
The easiest thing to do is to create a unique channel name, based on the UUID (or that maps to the UUID). Then you could subscribe to this channel to get messages for that user, pull history on it for later, etc.
Would that work for you?

Display Alert box through the trigger - salesforce

Is it possible to display an alert message (not error message) through a trigger? I have written a trigger that checks for duplicate accounts in the system. The trigger at the moment gives an error message to the user telling that there is a duplicate account. But, if the user changes the value of a field "Is record near to duplicate?" to YES, the trigger allows the user to save the record.
But, I want to display the error message in an alert pop up box like "Account with this Name exists,are you sure you want to continue" and then user clicks Yes and the record gets created. Any thoughts on how I can do this. My code is below:
for(Account account: System.Trigger.New)
{
if(accountMap.containsKey(account.Physical_Street__c)==accountMap2.containsKey(account.Phone))
if(accountMap.containsKey(account.Physical_Street__c)==accountMap3.containsKey(account.Name))
if(account.Is_record_near_to_duplicate__c.equals('No'))
{
account.addError('Account with this Name,Street and Phone Number already exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');
}
}
If you really need an alert box then you could create a custom javascript button that uses the ajax toolkit to replace the standard save button.
However, as Baxter said you are getting pretty far from standard salesforce look and feel. I would recommend instead to add an error on the checkbox field instead of the object so it is clear to the user what they need to select.
if(account.Is_record_near_to_duplicate__c.equals('No'))
{
account.Is_record_near_to_duplicate__c.addError('Agency with this Name, Physical Street and Phone Number already exists. If you still wish to create the agency change the value of field "Is Record Near To Duplicate" to YES');
}
Unless you write a custom visualforce page that processes the error message and then displays it as a popup there's no way to do this.
If you wanted the alert to modify the data you may look at using the ajax api to set the Is_record_near_to_duplicate__c field to 'Yes' but either way you're getting pretty far from the standard functionality and interface with this.
It is not straight forward to implement a pop-up alert for a trigger error, and pop-ups went out-of-fashion a long time ago. If you are going through the hassle, you might as well implement a custom soultion on a VF page.
Throw a custom exception(for dupe accounts) from the trigger, and catch it in your controller. When you catch this exception, you can dynamically displayed section on the page which asks the user to confirm his/her action. When the user confirms the action, the page will do the rest.
Hope this makes sense!
Anup

Resources