What defines a message as 'cached' in discord.js - discord.js

As we all know, in the change from v11 to v12, cache was introduced, however I can't find anything online that explains exactly what it is as a concept. Can anyone explain how it works?

I have just taken a look at the D.JS source and thankfully it is heavily commented.
In many files it suggests that any message that is sent by a user, or any message mentioning a user caches said user. This works in the same way with guilds I believe.
This means that in order to find a user in a server using #get or other fetch methods, the user must have been mentioned, or typed a message.
BaseManager.js source file here
Client.js source file here
GuildManager.js sournce file here

Related

How can I assign permissions with modules to a bot?

I want to setup a discord bot for a friend who mixes music. Using a existing bot I have been able to make it work. However only I can issue commands. Every time I try to define permission as suggested by the creator it returns with a error saying "Don't know user (the actual module permission route command)"
I have tried summarizing the permissions in a lot of ways. Also looked up a lot about .json modules and the syntax. In case the description that came with it was wrong but I was unable to find anything useful. Not experienced with writing a bot but I also looked into maybe making a .js config and put commands etc in that since .js might be easier for me to use. But It seems like a huge workaround for a syntax error. I am not sure what the parent module for commands is so I tried a number of lines based of reflector when reading the .dll.
The commands I gave to the bot following the suggested syntax (aParentModule.aChildModule.aCommand(arg1,arg2,arg3))
"#BOT permissions assign Admin Voice"
Reply:That doesn't look quite right, I will ignore these entries: Voice
I don't know this person.
I tells me the person issue a lot so I think I am not dividing the request properly there. Can't find out how to though.
#BOT permissions assign Yourcall ,voice,join
Reply: That doesn't look quite right, I will ignore these entries: ,voice,join
I don't know this person.
The bot I am using can be found on github for reference: https://github.com/BinkanSalaryman/Discord-Audio-Stream-Bot
Commands from config.json with the permission command
"text": {
"commands": {
"botAgent": "tomoko",
"permissions": {
"defaultPermissions": "!bot.stop() !guild.leave() help.commands(path) !permissions.assign(USER_OR_ROLE,PERMISSIONS) utils.ping(host)",
"userPermissions": {},
"rolePermissions": {}
}
The error I get from the bot "Tomoko.json"
"warning_badUser": "I don't know this person.",
I want to be able to give join and leave command to a specific role and not just the bot creator To do that the bot needs to stop seeing the commands as user names from what I can see based of the response messages.

How does logging in managed VMs work?

I'm reading Google's docs on logging in managed VMs, and they're rather thin on detail, and I have more questions than answers after reading:
Files in /var/log/app_engine/custom_logs are picked up automatically it says – is this path pre-existing or do you also have to mkdir -p it?
Do I have to deal with log rotation/truncation myself?
How large can the files be?
If you write a file ending in .log.json and some bit of it is corrupt, does that break the whole file or will Google pick up the bits that can be read?
Is there a performance benefit/cost to log things this way, over using APIs?
UPDATE: I managed to have logs show up in the log viewer, but only when logging files with the .log suffix, whenever I try .log.json they are not being picked up and I can't see any errors anywhere. The JSON output seems fine, and conforms to the requirement of having one object per line. Does anyone know how to debug this?

what is the best way to debug vCloud client REST applications?

I'm building a vClould client application via the REST APIs, however, the documentation is inconsistent an in some cases just wrong and misleading.
All I really need is a solid debug tool or even a log file. Any recommendations?
You already mentioned you have access to the message stream, which is one of the first steps. Typically if I'm using the Apache HttpClient/HttpComponents I'll go increase the log level so it logs the full HTTP requests.
My next step is usually to cheat and to log into vCD as a system administrator and see what's going on. When vCD was designed there was a very deliberate decision to not reveal infrastructure level problems to tenants of the cloud (normal org users or org admins), as that would break the cloud abstraction. Sadly, that means as an org-level user you're often going to get "contact your cloud admin" error responses. We are aware that this isn't ideal and try to find ways to make it better when we can (IIRC the new 5.5 release that was announced last month does have some improvements in that area).
The last step is usually to cheat even more and to look at the server side logs (vcloud-container-debug.log, specifically). That usually gives me a better clue as to what went wrong. Of course, you may be unlucky and not have access to the vCD cell machine.
My workaround in the latter two cases is to try the operations via the vCD UI and see (1) if they work as expected and (2) if they do, to check the system state via the API and see if I'm sending the wrong request payloads, etc. because the doc or schema reference may not have been clear enough.
In regards to the documentation, please use the feedback links () found on individual doc pages to let us know! Our technical writer reviews all the feedback and tries to address them.
My final suggestion is that you might want to post API questions to the vCloud API community forum VMware has. There are a number of experts (both users and VMware employees) that monitor it and respond to questions.

Receiving / retrieving email in CakePHP

I am developing a basic yet highly customized CRM for a small training centre which has the ability to store student records and also send emails to them. I'm using SwiftMailer following this excellent tutorial in CakePHP to accomplish the sending part.
Of course, students are sometimes going to reply to emails and I'd like to retrieve them within my CRM and store them along with the student record.
However, I cannot find a single reference to doing this. I've tried the following Google searches: "receiving email cakephp" , "retrieving email cakephp" and even "email client cakephp" but all of these queries give results relating to sending mail rather than receiving it -- very frustrating!
Finally, I broadened my search to non-cake solutions and found someone recommending a library called ezComponents. It doesn't seem to have had any active development for about a year, but it includes an email receiving class which is exactly what I want. Unfortunately, I have no idea how to add this to CakePHP and the only post I've been able to find on the entire web on the matter doesn't exactly go into much detail. It's certainly not a step-by-step tutorial on using ezComponents on CakePHP like the SwiftMailer tutorial I mentioned above.
I also found a class on Google Code called php-imap which looks like it would do the job but, again, I haven't the slightest clue how to get it working happily in Cake like SwiftMailer is.
I realize that I may have to learn how to package classes for use in Cake by myself but I'm asking this question first on the off-chance that there is already a Cake-friendly solution to this problem that I just haven't realized :-)
Joseph
Thanks to everyone for your answers, but I've been doing some more searching and it looks like the solution is actually incredibly simple.
Basically, with the help of a plugin, I can set up the mail server in databases.php as a datasource and then write a Model and Controller to interact with it.
Here's the example I found: https://github.com/kvz/cakephp-emails-plugin
Edit: the repo has been deprecated and is now available at https://github.com/kvz/deprecated/tree/cakephp-emails-plugin
You will want to pipe your email to PHP and use stdin:// to read the contents of the email and add the e-mail to your database.
I've done this with cake and the simplest way is to make a Cake console application to handle the parsing. Also using cpanel's account level filtering to generate the pipe is really simple.
http://forums.cpanel.net/f5/piping-mail-php-scripts-howto-checklist-50985.html
http://www.evolt.org/incoming_mail_and_php
Sounds like you want to include SwiftMailer as a Cake plugin, amirite?
http://book.cakephp.org/view/1111/Plugins
-- if you want to package it yourself. Otherwise, a cursory search of the Bakery yielded this result:
http://bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments-and-plugins
Hopefully it will at least get you pointed in the right direction. HTH. :)

Failing to import generated ics file to google calendar and outlook

I'm trying to generate ics-files, see sample here: http://deap.nu/myprogram.ics
It validates alright here: (URL removed: service no longer exists)
but when trying to import it into a google calendar I get the message
"Failed to import events: Unable to process your ical/CSV file."
which isn't very informative. I've tried to slim the file down, and googled a lot but can't find whats wrong. Any input on this is appreciated.
Importing to outlook doesn't work either.
After some sleep and more trial and error I managed to pinpoint the problem to the Organizer elements in the .ics file. So I removed them for now, adding the information to the description instead.
I have another recommandation for a successful import to GCalendar (calendar.google.com). I failed several times to import an ics-File with meaningless error messages.
I tried anything to make the ics-file standard conform, left out all UID rows etc. but nothing helped.
I used Google Chrome, which is my normal every day browser.
I thought: Which browser could be better to use it with Google-Services?
But: When I logged in to google-calendar using Microsoft Edge (Chromium-based) the ics-import just worked out of the box.
Hope it helps others with the same problem...
Then
I just got past a problem with the same description. I could leave Organizer in, but, editing the file with emacs on linux, I noticed that the Description contained carriage returns (^M), whereas the other line breaks had been normalized to linux standard when I had saved the .ics file. I removed the ^Ms and it then imported fine.
I realize this is an old post, but I'm adding this in to help others that might run into issues trying to import an .ics file.
As far as Google Calendar, the errors are not descriptive or outright misleading. I had a permissions error, but that was due to a UID (Unique Event ID) being in the file. As described below from Google's Calendar Community Forum, the solution was to remove that line from the file, save it, then try to import it again. It worked!
some of Google Calendar's error messages are not to be taken at face
value... this particular error often means that your UIDs (unique
event IDs) are not formatted to Google Calendar's liking, so my
question is where was this ics file generated?
I would try opening the file in a good text editor, and deleting every
line starting with UID as they are not needed for inserting new
events, and will cause this error if not formatted correctly.

Resources