"custom" songrequest command possible? - explained in thread

#1

PhantomBot Version: current
OS Version:win10 current
Java Version:current
Browser and Version (for Panel Support):chrome current
Stock PhantomBot: Yes

OK this is a pretty niche thing and I’m not sure if it’s possible but I’m taking a shot.

I want to start doing more regular guitar hero streams, and I have a very large list of songs i’ve modded into the game in a google sheet. [sheet here for reference https://docs.google.com/spreadsheets/d/1SLmEWE8s9-2F74yTPqjkXK_3nS6lB95NAulur7VprRc/edit?usp=sharing ]

What I want any viewer to be able to do during stream is basically the same as the current !songrequest system except instead of being able to request videos from youtube they can add to a list that I can view during stream and play the songs requested as I go. ideally they would enter:

![GHsongrequestcommandname] [copy/paste any row from that google sheet]

and that would result in that being fed to a list that i can view and pull the top item from one by one or a queue that i can take the top one from with another command.

I looked through the commands list and i see that there is the !queue command but it seems to only add usernames. I could use that system if the !queue command allowed viewers to add text as well but it seems to only add their username and nothing else. The only workaround I see is just using !queue and then when someone’s turn comes up then they post what song they want, but IMO that’s a bit janky and will slow down the flow of the stream. I’d like to avoid that if possible.

ANY help on this is appreciated.

#2

You can make do with the queue system, or you can create a custom script to handle what you want. Though, I don’t know how it’d communicate with google.

Anyways, no where does it say only a username can be entered in the queue. The dialogues are just set up for usernames. The idea is the person is supposed to enter their gamertag/etc when joining a queue, as it tends to differ from their twitch. That doesn’t prevent anyone from typing something else.

Here’s the line that is sent on the queue opening:

$.lang.register('queuesystem.open.normal', 'The $1 queue is now opened! Use !joinqueue [optional gamertag] to join it!');

All you’d have to do is change it to something like:
$.lang.register('queuesystem.open.normal', 'Song requests are now open! type !yourcmdname [songname here]');

And then use an alias:
!aliascom yourcmdname joinqueue

You could even go so far as to making the “optional” argument required; but that requires an edit of the script.

More information on editing lang files can be found here:

#3

ahhhh thank you! i looked through the command list and not the actual scripts, it just says username will be added to the queue but not the [optional text] part. I can absolutely use that, but I’m a little iffy about modifying the javascript. which file exactly do i edit, and how do i keep from having to re-do this every single time there’s a bot update?

#4

If you follow the guide on the lang files, you should only need to move the “custom” folder over each time for the lang file.

As for the javascript, you’d have to either copy/paste the file over again, or redo the edits.

To make the edits to the JS script:

(make a backup first)

Open the file /scripts/system/queueSystem.js

Search for function join(username, action, command) {

You should see:

/*
 * @function join
 *
 * @param {String} username
 * @param {String} action
 */
function join(username, action, command) {
	if (queue[username] !== undefined) {
		$.say($.whisperPrefix(username) + $.lang.get('queuesystem.join.error.joined'));
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (info.size !== 0 && (info.size <= Object.keys(queue).length)) {
		$.say($.whisperPrefix(username) + $.lang.get('queuesystem.join.error.full'));
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (isOpened === false) {
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	}

	queue[username] = {
		tag: (action === undefined ? '' : action),
		position: Object.keys(queue).length,
		time: new Date(),
		username: username
	};

	var temp = { 'tag' : String((action === undefined ? '' : action)), 'time': String(date(new Date(), true)), 'position': String(Object.keys(queue).length), 'username': String(username) };
	$.inidb.set('queue', username, JSON.stringify(temp));
}

Replace with:

/*
 * @function join
 *
 * @param {String} username
 * @param {String} action
 */
function join(username, action, command) {
	if (action === undefined) {
		$.say($.whisperPrefix(username) + 'No song name entered. Try !cmdname song-name');
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (queue[username] !== undefined) {
		$.say($.whisperPrefix(username) + $.lang.get('queuesystem.join.error.joined'));
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (info.size !== 0 && (info.size <= Object.keys(queue).length)) {
		$.say($.whisperPrefix(username) + $.lang.get('queuesystem.join.error.full'));
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (isOpened === false) {
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	}

	queue[username] = {
		tag: (action === undefined ? '' : action),
		position: Object.keys(queue).length,
		time: new Date(),
		username: username
	};

	var temp = { 'tag' : String((action === undefined ? '' : action)), 'time': String(date(new Date(), true)), 'position': String(Object.keys(queue).length), 'username': String(username) };
	$.inidb.set('queue', username, JSON.stringify(temp));
}

Don’t forget to edit this text: 'No song name entered. Try !cmdname song-name' but keep it within those quotes. If you use a similar quote, like for the word “don’t” you need to put \ directly before it, like this: don\'t

#5

this is awesome. thank you so much. i think i’ll try it tonight.

#6

THANK YOU! this worked beautifully, there’s just one minor issue and I cannot for the life of me figure it out.

I’ve aliased joinqueue to !sr, and it is adding people to the queue totally fine, but there is no in-chat message letting them know that the song was added. i don’t know where to add a line or what to put in it to get that acknowledgement to display.

also it doesn’t actually have the song as mandatory, but that’s not really that big a deal, if someone doesn’t add it i can always ask when they come up or just skip them. the important bit for me is the acknowledgement of being added

1 Like
#7

Try this:

/*
 * @function join
 *
 * @param {String} username
 * @param {String} action
 */
function join(username, action, command) {
	if (action === undefined || action === null || action.trim().length < 1) {
		$.say($.whisperPrefix(username) + 'No song name entered. Try !cmdname song-name');// edit here
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (queue[username] !== undefined) {
		$.say($.whisperPrefix(username) + $.lang.get('queuesystem.join.error.joined'));
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (info.size !== 0 && (info.size <= Object.keys(queue).length)) {
		$.say($.whisperPrefix(username) + $.lang.get('queuesystem.join.error.full'));
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	} else if (isOpened === false) {
		$.returnCommandCost(username, command, $.isMod(username));
		return;
	}

	queue[username] = {
		tag: (action === undefined ? '' : action),
		position: Object.keys(queue).length,
		time: new Date(),
		username: username
	};

	var temp = { 'tag' : String((action === undefined ? '' : action)), 'time': String(date(new Date(), true)), 'position': String(Object.keys(queue).length), 'username': String(username) };
	$.inidb.set('queue', username, JSON.stringify(temp));
	$.say($.whisperPrefix(username) + 'your song has been added to the queue');// and here
}
#8

this actually didn’t work, no messages were being returned at all by the bot BUT i used my extremely limited coding knowledge and guesswork to figure it out. here’s what i did

/*

  • @function join

  • @param {String} username

  • @param {String} action
    */
    function join(username, action, command) {
    if (action === undefined || action === null || action.trim().length < 1) {
    $.say($.whisperPrefix(username) + $.lang.get(‘queuesystem.failempty’));
    $.returnCommandCost(username, command, $.isMod(username));
    return;
    } else if (queue[username] !== undefined) {
    $.say($.whisperPrefix(username) + $.lang.get(‘queuesystem.join.error.joined’));
    $.returnCommandCost(username, command, $.isMod(username));
    return;
    } else if (info.size !== 0 && (info.size <= Object.keys(queue).length)) {
    $.say($.whisperPrefix(username) + $.lang.get(‘queuesystem.join.error.full’));
    $.returnCommandCost(username, command, $.isMod(username));
    return;
    } else if (isOpened === false) {
    $.returnCommandCost(username, command, $.isMod(username));
    return;
    }

    queue[username] = {
    tag: (action === undefined ? ‘’ : action),
    position: Object.keys(queue).length,
    time: new Date(),
    username: username
    };

    var temp = { ‘tag’ : String((action === undefined ? ‘’ : action)), ‘time’: String(date(new Date(), true)), ‘position’: String(Object.keys(queue).length), ‘username’: String(username) };
    $.inidb.set(‘queue’, username, JSON.stringify(temp));
    $.say($.whisperPrefix(username) + $.lang.get(‘queuesystem.songsuccess’));
    }

and then also added two lines to \scripts\lang\custom\systems\systems-queueSystem.js
$.lang.register(‘queuesystem.failempty’, ‘404 SONG MISSING! Use this: !sr [paste song info]. Use !GH command for all song info’);
$.lang.register(‘queuesystem.songsuccess’, ‘Song added successfully!’);

tested and IT WORKS!

I honestly have no idea why what you had didn’t work, there’s no reason it shouldn’t have… but anyway THANK YOU a billion times. there is ZERO chance I would have even known where to look or had any idea of how to proceed without your help.

1 Like
closed #9

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