Removing a user from a array

Hello, I have been working on a queue bot for my friend who streams I am having trouble getting a command such as !leavequeue or !removequeue @user. This is my code

const tmi = require('tmi.js'),
    { channel, username, password } = require('./settings.json');

const options = {
    options: { debug: true },
    connection: {
        reconnect: true,
        secure: true
    },
    identity : {
        username,
        password
    },
    channels: [channel]
};

const client = new tmi.Client(options);
client.connect().catch(console.error);

client.on('connected', () => {
    client.say(channel, `${username} has connected!`);
});

const queue = [];

client.on('message', (channel, user, message, self) => {
    if(self) return;

    if(message == '!joinqueue') {

        client.say(channel, `@${user.username}, Joined The Queue!`);
        
        queue.push(`${user.username}`);

        console.log(queue);

    }

    if(message == '!queue') {

        client.say(channel, `${queue}`);

    }

    if(user.mod || user['user-type'] == 'mod'){

    if(message == `!removequeue @${user.username}`) {
        while(queue > 1) {
        var queueremove = (queue.indexOf(`${user.username}`) > -1);
        queue = queueremove;
        }
        client.say(channel, 'Successfully Removed From The Queue');
    }

    if(message == '!clearqueue') {

        while(queue.length > 1) {
            queue.length = 0
        }

        console.log('Queue Cleared');

        client.say(channel, 'Cleared Queue');
        
    }

    if(message == '!next') {

        queue.shift();

        client.say(channel, `Done The New Queue Is ${queue}`);
    }

    }

    if(message == '!leavequeue') {
        while(queue > 1) {
        var queueremove = (queue.indexOf(`${user.username}`) > -1);
        queue = queueremove;
        }
        client.say(channel, 'Successfully Left The Queue');
    }


});

if anybody knows how I can make it so when one of those commands is used that it removes that ser from the array that would be great thanks.

You should potentially learn the basics of JavaScript before tackiling a bot.
Bot’s are pretty advanced, and you don’t know how to manipulate an array.
You may want to do a JavaScript language primer lesson first such as the one prodvided by code academy

There are a number of ways

https://www.google.com/search?q=how+to+remove+item+from+array+in+javascript

Primary method being splice

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.