Get reply after sending slash command #831
Answered
by
TejasLamba2006
TejasLamba2006
asked this question in
Q&A
-
So this is my code app.get('/info', async function(req, res) {
const { user_id } = req.query
if (!user_id) return res.status(400).json({ error: 'Missing user_id' })
if (!client) return res.status(400).json({ error: 'Client not initialized' })
const channel = client.channels.cache.get(process.env.BOT_COMMANDS_ID)
if (!channel) return res.status(400).json({ error: 'Channel not found' })
channel.sendSlash(process.env.PIKA_BOT_ID, 'info', user_id).then((data) => {
res.status(200).json(data)
})
}); and this is wht I get at the api {
"channelId": "1143178119092641863",
"guildId": "234731357903781888",
"sendData": {
"type": 2,
"application_id": "601177246627135507",
"guild_id": "234731357903781888",
"channel_id": "1143178119092641863",
"session_id": "ee27526e0518853fc2e841ceab6f3cb7",
"data": {
"version": "1143846705167597649",
"id": "1143846705167597648",
"name": "info",
"type": 1,
"options": [
{
"type": 6,
"name": "member",
"value": "1076942240791928875"
}
],
"attachments": []
},
"nonce": "1147090059774787584"
},
"id": "1147090057782624317",
"nonce": "1147090059774787584"
} I want to get the data from the embed ran after slash command how to do that? |
Beta Was this translation helpful? Give feedback.
Answered by
TejasLamba2006
Sep 11, 2023
Replies: 2 comments 5 replies
-
You could run a message create listener and check to see if the message that was sent is in the channel and from the bot and if it is then destroy the listener and return the data |
Beta Was this translation helpful? Give feedback.
5 replies
-
So if anyone followed me till here actually you would need to app.get("/info", async function (req, res) {
const { user_id } = req.query;
if (!user_id) return res.status(400).json({ error: "Missing user_id" });
if (!client) return res.status(400).json({ error: "Client not initialized" });
const channel = client.channels.cache.get(process.env.BOT_COMMANDS_ID);
if (!channel) return res.status(400).json({ error: "Channel not found" });
channel
.awaitMessages({
max: 1,
})
.then(async (collected) => {
const d = await channel.messages.fetch(collected.first().id, { force: true });
res.status(200).json(d);
});
channel.sendSlash(process.env.PIKA_BOT_ID, "info", user_id);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TejasLamba2006
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So if anyone followed me till here actually you would need to
fetch
the messages by forceExample