Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 10 months ago.
Improve this question
I have the id of the message, the id of the guild, and the channel id i just want to know how to delete a message with just those three things
I have looked everywhere and haven't found something that works
"I have looked everywhere and haven't found something that works."
Did you not look at the djs docs? I found the answer to your question on the docs in seconds. Not to mention, dozens of other StackOverflow questions found in one google search, such as this one. Regardless, I'll show you how to do it.
All you really need is the ID of the message and channel. And the client instance. You don't even need the guild ID. Here's the code:
const channelId = "insert channel id here";
const messageId = "insert message id here";
client.channels.fetch(channelId).then(channel => {
channel.messages.delete(messageId);
});
That code is the easiest way to delete a message by ID, assuming you only have access to the client. If you have access to a channel instance already (e.g. message.channel), the only code you need to do is the code within the .then() shown above.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
How can I check if an id it's inside my firebase collection?
I need to check if item.id it's inside the collection "favorites" that contains multiple ids.
I need to assign to a value true if it's inside or false if there is not a value with the same id.
As far as I know, there is no way to "check" if a document exists inside a collection without actually fetching it. When you attempt to get the document, it returns a doc - with a exists variable.
So you can check if a document exists or not like this (using Promises):
const doesDocExist = (docID) => {
return firestore().collection("cities").doc(docID).get().then((doc) => {
return doc.exists
})
}
//Call the function to check if doc exists:
let doesSanFranciscoExist = await doesDocExist("SF")
Note that in the above function, you are attempting to fetch the document with the ID.
Alternatively, if you want to check the existence of multiple documents with just one read, you can maintain a list of document ids elsewhere in your database using Cloud Functions.
Get a document in Firestore
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Ok, I am trying to make a record and send an email notification/acknowledgement that the record has been recorded. I have a many to many relationship between a Players model and a Lessonhours model. The User model has a one to many with the Players model.
I have run my 'store' method with several different modifications and I finally get my email to send. The problem is that I can't get the array of players that exist and send each an email. The multiple selections from my form are being properly inserted in their respective tables. When it comes to collecting the email data, I have come closest with the following code. The problem with THIS is that I only get one player instead of two or more when they exist. I hope this makes sense. Screenshots below.
Code and screenshot of $request array:
Players Model:
I am not very experienced with this and I am finding it difficult to pinpoint which documentation example to use. How can I get all of the emails addresses for sending after the insertion of record? I appreciate all help offered.
Lessonhours Model:
Store Lessonhours form
User Model
I'm not sure why you're putting an array inside an array for whereIn clause but if request players is already coming through as an array then your should just be able to do:
whereIn('id', $request->players)
Next you're only ever going to be sending one email because you're returning from inside the loop so it's going to send the first player one email and then return a response. To save have a temporary variable that you're not using again you could do:
Players::with('users')->whereIn('id', $request->players)->get()
->each(function ($player) use ($lesshours) {
Mail::to($player->users)->send(new ThankYouForLessonPackagePurchase($lesshours));
});
return back()->with(['success' => 'Player is enrolled in new Lesson Package.']);
You don't have to do the above it's just another way to write it.
Lastly, if you're always going to require player ids to be sent then you might as well add it to the validation array:
'players => 'required',
'players.*' => 'exists:players,id',
Hope this helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to extract a bunch of urls from a db (the db contains a large set of urls), when a user searches for a particular keyword, for example "seattle dentist". I understand that the basic approach is to look for the page title, meta description, keywords and body text.
How can I do this with more accuracy that returns relevant result?
For example, I have two websites in question:
seattledentist.com (which is a dentist website and has the title
"seattle dentist")
abcxyz.com/dentist-seattle (a wordpress blog
page that has the word "seattle dentist" in its title)
For me, the first website is relevant and I want to show this site to a user when he searches for "seattle dentist".
The second website is just a blog post that describes the dentistry profession in seattle and is not relevant for the user.
So my question is, what would be a better strategy(algorithm) for filtering out this type of non-relevant urls from a whole bunch of urls?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
As I want to add data to my database, I wanted to use "Add" method but there isn't.
Methods to add to database are only "AddObject" and "AddTo". Even if I choose "AddTo", it suggest to me to use "Add" methods which I don't have it.
This is also same for "remove" method
What is the reason that I don't have "Add" in my method collection?
To add my database to VB.NET I use Entity Model Code Generator which makes a file with the name of "Model1.edmx" in Solution Explorer
AddObject is what your looking for. That method allows you to add records to the tables, and they all follow this pattern.
Using db As New model 'or what ever you model is called
Dim obj As tableName = tableName.CreateTableName({params that are not null})
db.tableNames.AddObject(obj)
db.SaveChanges()
End Using
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have an e-commerce website writen by yii framework. I want to rebuild with woocommerce on wordpress. And I want to keep old database (all table, rows). But wordpress save data on a different way (metadata).
what is solution in this case, how to import old database and custom field same my old database?
P/s: thanks for advance and sorry about my english.
Unfortunately, there is no easy way to do this:
First, you must create the post using wp_insert_post:
wp_insert_post( $post, $wp_error );
http://codex.wordpress.org/Function_Reference/wp_insert_post
Second, you must add the appropriate metadata using add_post_meta:
add_post_meta($post_id, $meta_key, $meta_value, $unique);
http://codex.wordpress.org/Function_Reference/add_post_meta
What you end up with is something like this psuedo-code:
$yii_products = (get products from yii db. Perhaps init a new PDO connection to connect to that db.)
foreach($yii_products as $product)
{
//Create post array from existing datatype in yii
$post = array(
'title' => $product->title,
...
);
//Save post
$post_id = wp_insert_post($post);
//Add metadata
//some_yii_field_name could be 'color', 'size' or whatever woocommerce uses
add_post_meta($post_id, 'some_yii_field_name', $product->some_yii_field_name);
}
This will create all of your new post types and with the appropriate metadata. I would put this code into a throw-away plugin used only for migration.
Good luck!