Commands with Special Characters

Hello,
if i create a command with special characters i get a error message in /logs/core-error/ that says “java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x8C\xB8 U…’ for column ‘value’ at row 1”.
I found out that i somehow need to activate utf8mb4 in java, but how do i do this? I use MySQL as database system and not SQLite. Could i also just log in phpmyadmin and change the table row to utf8mb4? Or will this break the bot?
And also since i tried to create the command with special characters the database did not save the command. It is just not in the database but the command works in chat with all the special characters. So what is the problem?

Thanks for all help

Change your MySQL Instance settings to default to the character set utf8mb4.

In MySQL Workbench this would be

  1. Connect to server
  2. Select Instance -> Options File in the Navigator pane
  3. Select the General tab
  4. Scroll down to the International section and put a check next to character-set-server
  5. In the character-set-server box put utf8mb4
  6. Click Apply

You can also do this directly in your my.cnf by adding/editing the option character_set_server=utf8mb4 and then reloading the mysql service.

I am not sure how to do this in phpMyAdmin.

If you make this change, the bot should automatically use it after a restart.

1 Like

Thanks for the answer but unfortunately it doens’t work. It was already at utf8mb4 in the my.cnf and i also changed the whole table to “utf8mb4_unicode_ci” and i changed the row where the command texts get saved in also to utf8mb4_unicode_ci. But i get the same error message. I restartet everything the bot and mysql but it doesn’t work. And now i have another question. Yesterday i created a command with !test and then one of the chrome emojis as response. Now after the bot restart the command doesn’t work anymore, obviously because it wasn’t in the database. But… if i try to create a new command with !test it says that the command already exists but it doesn’t how can i clear this?
And here is my server configuration all is mb4
Screenshot_6

Ok i got it to work, somehow xD
So for everyone getting errors when they put in emojis like :heart_eyes: i can tell you what i did:

I added some lines to the my.cnf in /etc/mysql/
At the [client] section i added:
default-character-set=utf8mb4

At the [mysqld] section i added:
character-set-server = utf8mb4
init-connect=‘SET NAMES utf8mb4’
collation-server = utf8mb4_unicode_ci
character-set-client-handshake = FALSE

At the [mysql] section i added:
default-character-set=utf8mb4

Then in phpmyadmin i changed the collation from the whole database to utf8mb4_unicode_ci and also from phantombot_command table. Then you have to change the row “value” in phantombot_command from latin1_swedish_ci again to utf8mb4_unicode_ci.

I don’t know everything i did in the last hour trying to get it to work, but i think this changes were the reason why it works now.

And the problem were also some “stuck” commands. If the bot doesn’t accept emojis, then the commands get created but they are not in the database. Then you have to create them manually in the database and delete them with the phantombot panel. I kept ketting an error spam in the logs because some were “stuck”. After you cleared the stuck commands and changed everything all should work fine.