thecatcore / Fabric---Discord-Link

MIT License
75 stars 31 forks source link

Tellraw not displaying in Discord [MC1.18.1] #185

Closed LloydThinks closed 2 years ago

LloydThinks commented 2 years ago

Describe the bug Using tellraw does not print to Discord. Every other expected message works: Minecraft to Discord and Discord to Minecraft.

This issue looks identical to #115 but I wasn't sure if a new issue was better than necro.

Reproduction steps Install fabric-discord fresh, atATellRaw is true, send a tellraw command in console (tellraw @a {"text":"Testing"}), discord does not show that message.

Expected behaviour Discord should print the tellraw to the connected discord channel.

Additional context

fdlink.json

{
  "token": "removed",
  "chatChannels": [
    "removed"
  ],
  "logChannels": [],
  "webhook": {
    "url": "",
    "mentions": {
      "everyone": false,
      "roles": false,
      "users": true
    }
  },
  "ignoreBots": true,
  "activityUpdateInterval": 120,
  "minecraftToDiscord": {
    "general": {
      "enableDebugLogs": false
    },
    "chatChannels": {
      "commandPrefix": "-",
      "allowDiscordCommands": false,
      "serverStartingMessage": true,
      "serverStartMessage": true,
      "serverStopMessage": true,
      "serverStoppingMessage": true,
      "customChannelDescription": false,
      "minecraftToDiscordTag": false,
      "minecraftToDiscordDiscriminator": false,
      "playerMessages": true,
      "teamPlayerMessages": true,
      "joinAndLeaveMessages": true,
      "advancementMessages": true,
      "challengeMessages": true,
      "goalMessages": true,
      "deathMessages": true,
      "sendMeCommand": true,
      "sendSayCommand": true,
      "adminMessages": false,
      "atATellRaw": true,
      "achievementMessages": true
    },
    "logChannels": {
      "serverStartingMessage": true,
      "serverStartMessage": true,
      "serverStopMessage": true,
      "serverStoppingMessage": true,
      "customChannelDescription": false,
      "minecraftToDiscordTag": false,
      "minecraftToDiscordDiscriminator": false,
      "playerMessages": false,
      "teamPlayerMessages": false,
      "joinAndLeaveMessages": true,
      "advancementMessages": false,
      "challengeMessages": false,
      "goalMessages": false,
      "deathMessages": true,
      "sendMeCommand": true,
      "sendSayCommand": true,
      "adminMessages": true,
      "atATellRaw": false,
      "achievementMessages": true
    }
  },
  "discordToMinecraft": {
    "pingLongVersion": false
  },
  "emojiMap": [
    {
      "name": "example_name",
      "id": ":example_id:22222222"
    },
    {
      "name": "example_name2",
      "id": ":example_id2:22222222"
    }
  ],
  "version": 9
}
LloydThinks commented 2 years ago

After some testing I think I have narrowed down what is wrong. The command tellraw @a {"text":"Testing"} does not work, but the command /tellraw @a {"text":"Testing"} does. It appears that the Fabric-Discord-Link mod is somehow explicitly checking for commands with the / in front of it, even though through the server console and datapacks you can invoke tellraw without the /.

Is this something that can be easily fixed? I'm trying to look through the jar now but I am not a Java person.. I'll let you know if I find anything.

LloydThinks commented 2 years ago

Alright I was able to modify a single line to get it working for my use case. I was able to re-build the Gradle project and test the Jar on my server. Everything works as expected now.

I'm not sure if you want this change in the code base, but all you have to do is edit this line in the code: https://github.com/arthurbambou/Fabric---Discord-Link/blob/c6be852deb4c36d5dfe33f35b6e99719c5c8f220/versions/fabric/1.16.5/src/main/java/fr/arthurbambou/fdlink/mixin_1_16/MixinTellRawCommand.java#L50

to be this: if (commandContext.getInput().replace("/tellraw ", "").startsWith("@a") || commandContext.getInput().replace("tellraw ", "").startsWith("@a"))

I would open a pull request but I am not familiar enough with Java, Gradle, or Mod development to assume my requested change doesn't impact anything else. Hopefully someone else can make the change, run the tests, integrate, whatever else.

Lloyd

thecatcore commented 2 years ago

WoW thx for finding out the cause of the issue. If you pr your changes I'll surely merge them.