I'm trying to make a confirmation portion of my command where if you activate the command, you need to say "yes" before the code activates. The reoccurring problem is that the code right after the message that says
Confirmed... Please wait.
After this, it completely skips over the code and does nothing. When I was writing the code in VSC, the async
portion of the code wasn't highlighted with yellow, but more of a darker yellow.
I've tried removing this portion of the code
const async = async () => {
But the code with await cannot run unless it's connected to async.
I've tried changing how the async is ran.
async () => {
Still the same result.
Removing the beginning async code will also just result in the command breaking.
I've placed the big chunk of code outside of the then(collected
code, but after a few seconds of waiting when the command activates, it immediately runs, then brings up a value error. But I want it so that code activates when the author says "Yes"
async run(message, args){
if (message.channel instanceof Discord.DMChannel) return message.channel.send('This command cannot be executed here.')
let replyMessage = message.reply('Please make sure that my integration role "Synthibutworse" is above the default role used for this server. Is this correct? [Reply with "YES"] if so. Will expire in 20 seconds...');
let filter = msg => msg.author.id == message.author.id && msg.content.toLowerCase() == 'yes';
message.channel.awaitMessages(filter, {max: 1, time: 20000}).then(collected => {
message.reply('Confirmed... Please wait.');
const async = async () => {
if(!message.member.guild.me.hasPermission(['MANAGE_WEBHOOKS'])) return message.channel.send('I don\'t have the permissions to make webhooks, please contact an admin or change my permissions!')
if(!message.member.guild.me.hasPermission(['MANAGE_ROLES'])) return message.channel.send('I don\'t have the permissions to make roles, please contact an admin or change my permissions!')
if (!message.member.hasPermission(['MANAGE_WEBHOOKS'])) return message.channel.send('You need to be an admin or webhook manager to use this command.')
if (!message.member.hasPermission(['MANAGE_ROLES'])) return message.channel.send('You need to be an admin or role manager to use this command.')
const avatar = `https://cdn.discordapp.com/attachments/515307677656678420/557050444954992673/Generic5.png`;
const name2 = "SYNTHIBUTWORSE-1.0WOCMD";
let woaID = message.mentions.channels.first();
if(!woaID) return message.channel.send("Channel is nonexistant or command was not formatted properly. Please do s!woa #(channelname)");
let specifiedchannel = message.guild.channels.find(t => t.id == woaID.id);;
const hook = await woaID.createWebhook(name2, avatar).catch(error => console.log(error))
await hook.edit(name2, avatar).catch(error => console.log(error))
message.channel.send("Please do not tamper with the webhook or else the command implied before will no longer function with this channel.")
var role = message.guild.createRole({
name: `Synthibutworse marker v1.0`,
color: 0xcc3b3b,}).catch(console.error);
specifiedchannel.send("Created role...");
if(message.guild.roles.name == "Synthibutworse marker v1.0") {
role.setMentionable(false, 'SBW Ping Set.')
role.setPosition(1)
role.setPermissions(['CREATE_INSTANT_INVITE', 'SEND_MESSAGES'])
.then(role => console.log(`Edited role`))
.catch(console.error)};
message.channel.send("Role set up...");
const sbwrID = message.guild.roles.find(`Synthibutworse marker v1.0`);
let specifiedrole = message.guild.roles.find(r => r.id == sbwrID.id)
message.channel.send('Created Role... Please wait.');
message.guild.specifiedchannel.replacePermissionOverwrites({
overwrites: [
{
id: specifiedrole,
denied: ['SEND_MESSAGES'],
allowed: ['VIEW_CHANNEL'],
},
],
reason: 'Needed to change permissions'
});
var bot = message.client
bot.on('message', function(message) { {
if(webhook.name == `Synthibutworse marker`) return
if(message.channel.id == webhook.channelID) return
{let bannedRole = message.guild.roles.find(role => role.id === specifiedrole);
message.member.addRole(bannedRole)};
}});
}});
}};
module.exports = woa;
I expect the command to run with the async and continue with the code when the message author says "yes", and doesn't stop at the Please wait.
message.
What actually happens is the code doesn't run right after the Please wait
message.