We're on Discord! Please join our server now if you don't want to miss anything! (More info) | Join the UCC4 contest! (More info)

* WalrusIRC & Discord main room

If you have a forum account, have more than 4 posts and are not part of a restricted usergroup, then you can chat in our main Discord server room directly from here and continue using the forums at the same time. Or you can join our server directly and access many more discussion rooms!

Author Topic: UniChat!  (Read 9824 times)

0 Members and 1 Guest are viewing this topic.

Offline _iPhoenix_

  • Custom title
  • Super User
  • Join Date: Mar 2017
  • Location: Location
  • Posts: 673
  • Post Rating Ratio: +16/-1
  • ███████ ▼ ♪ Best music ♫
    • @dj_iPhoenix
    • @UCytgMNPxAMDsxjimvxHf01w
    • Legend-of-iPhoenix
    • @the-legend-of-iphoenix
    • My website.
  • Gender: Male
Re: UniChat!
« Reply #30 on: December 28, 2017, 01:05:10 am »
I'm having some issues with my own code that I cannot solve. (And to think I'm the person who is supposed to know these things...)

In the bots API, (relevant file, main.js, is here) I'm having some issues where multiple objects (in this case, bots) of the same constructor are sharing properties. (in this case, the name attribute)

In my code, I am creating and initializing bots as per my documentation, but I am initializing two bots, one with the name "iPhoenixBot", and the other with the name "karmaBot". Note that iPhoenixBot is being initialized first, then karmaBot.

The command "~bad" is registered under iPhoenixBot, yet when I execute that command, this happens:

[07:47:52] _iPhoenix_: ~bad
[07:47:53] [karmaBot]: That's so bad, it's almost impressive!
As you can tell, the username is showing up wrong.

The console tells me this:

Callback for bot "iPhoenixBot" triggered with message "bad".
Response from "karmaBot" received. //this should be "iPhoenixBot", not "karmaBot"
Callback for bot "karmaBot" triggered with message "bad".

In the main.js file linked above, I am using the bot_name input from the constructor in the code to determine what name to display.

I initially assumed this was the problem. I thought that the bot_name variable might be changed each time the constructor is called, even though this seems strange.

I changed it to "this.name", which is the bot's name. This works elsewhere, but it didn't work there.

How can I fix this, and what exactly is happening?

I fixed it, but I can't quite explain how I fixed it or how my fix works, but it does.
« Last Edit: December 28, 2017, 01:35:56 am by _iPhoenix_ »
  • Calculators owned: Two TI-84+ CE's
Please spam here: https://legend-of-iphoenix.github.io/spam/

"walruses are better than tuxedo chickens, all hail the great :walrii:" ~ me
Evolution of my avatar:


You can also use the following HTML or bulletin board code to share it on your page or forum signature!

Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games