So, I wanted to add command /custom and after that, user would enter they nicknames through messages. Bot should check if ther nickname is in game (async function checkIfSummonerExist(m)) and if it does exist, bot should collect their name and data and push to array (async function getSummonerProfile(m.content)). Now I wanted to add bot reactions to those messages, if nickname exist, it should add one reaction (for example thumbs up), and if name does not exist one should add thumbs down. So I tried with m.react(), but it does not work. I also tried with m.reply("User approved")but I don't get reply. I am new to making discord bot.
const { SlashCommandBuilder } = require("@discordjs/builders");
const { getSummonerProfile } = require("./../functions/summonerData");
const { calculateRank } = require("./../functions/calculateRank");
let arrayOfSummoners = [];
async function checkIfSummonerExist(m) {
const test = await getSummonerProfile(m.content);
if (test) {
return true;
} else {
return false;
}
}
module.exports = {
data: new SlashCommandBuilder()
.setName("custom")
.setDescription(
"Enter the name of the user."
),
async execute(interaction) {
await interaction.deferReply();
// `m` is a message object that will be passed through the filter function
const filter = (m) => checkIfSummonerExist(m);
const collector = interaction.channel.createMessageCollector({
filter,
time: 15000,
});
collector.on("collect", (m) => {
m.reply('User approved');
m.react('😄');
arrayOfSummoners.push(getSummonerProfile(m.content));
});
collector.on("end", (collected) => {
// return interaction.editReply(`Collected ${collected.size} items`);
// calculateRank(arrayOfSummoners);
});
// return interaction.editReply();
},
};