From d33180fb0d11ed0aebc42781005a3de5b86bcba7 Mon Sep 17 00:00:00 2001 From: Amit Yadav <88823371+Tyrant670@users.noreply.github.com> Date: Sat, 18 Jun 2022 22:16:18 +0530 Subject: [PATCH] Update slashcommand.cpp --- src/dpp/slashcommand.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/dpp/slashcommand.cpp b/src/dpp/slashcommand.cpp index 9ae30245a3..b6b16d86af 100644 --- a/src/dpp/slashcommand.cpp +++ b/src/dpp/slashcommand.cpp @@ -575,8 +575,23 @@ void from_json(const nlohmann::json& j, interaction& i) { } } j.at("member").get_to(i.member); - i.member.user_id = i.usr.id; - i.member.guild_id = i.guild_id; +// i.member.user_id = i.usr.id; +// i.member.guild_id = i.guild_id; +// Unfortunately, you cannot send a response in a direct message using a slash command. The response will be sent in the same channel as the slash +// command was executed. You can send the response as a normal message. + //You'll have to manually get the member, by either getting it from the cache or fetching it from the API. + +// const user = client.users.cache.get(interaction.member.user.id); +// user.send("Hello").catch(console.error); + + // or you can use this + client.ws.on("INTERACTION_CREATE", async interaction => { + const guild = client.guilds.cache.get(interaction.guild_id); + const user = client.users.cache.get(interaction.member.user.id); + + user.send(`hello, you used the ${interaction.data.name.toLowerCase()} command in ${guild.name}`).catch(console.error); + }); + if (i.cache_policy.user_policy != dpp::cp_none) { /* User caching on, lazy or aggressive - cache or update the member information */ guild* g = dpp::find_guild(i.guild_id);