[Release] D2FiveM - Control your FXServer with Discord

Updated to v1.1.0



  • Added chkcon as a command to check if the connection succeed
  • Added ban as a command to instantly ban player
  • Added a lang.json to translate the discord messages
  • Added the option to send a chat message when a player gets kicked/banned
  • Added the option to change the name of the Bot In-Game


Download in the First Post!

Added!

There is now an toggle for this in the config.lua

There is now a new value for this in the config.json

I added a lang.json to make it easy to translate the discord messages

Awesome update! Nice to see you’re taking suggestions from the community too. :grinning:

Wow… you really are a legend!!!

not sure if someone told you already but you dont need to include the node_modules folder.
npm install will install all modules and dependencies listed in the packages.json file.

also multiple server support would be nice

I know, but I wanted to make it more use friendly :sweat_smile:
But if this could cause any problems, tell me please and I will change it.

Do you mean multiple Discord or FX Server?

fx

i removed ip and port from your json config and added an object of different servers for it
eg

	"servers" : {
		"mountains" : {
			"ip": "",
			"port" : ""
		},
		"tracks" : {
			"ip": "",
			"port" : ""
		},
		"default" : {
			"ip": "",
			"port" : ""
		}
	},

and to not mess too much with your code, i added a function

	function returnServer(server) {	
		if (server == undefined || server == "") {
			return message.channel.send("no server specified.")
		}
	
		var accessjson = "config.servers." + server
		accessjson = eval(accessjson)

		if (accessjson == null || accessjson == "" || accessjson == "{}"  || accessjson.ip == undefined || accessjson.port == undefined){
			message.channel.send("no server specified or wrong data")
			return false
		} else {
			for (variable in accessjson) {
				config[variable] = accessjson[variable]
			}
			return accessjson
		}
  }

far from perfect and just a quickly made code
but now i can just specify a server like !!kick <SERVER> [SERVER_ID] [REASON]

the function will get the data out of the servers object and make two new key:value in the first “level” (config.ip, config.port)

at the end of the “client.on(“message”)” function, ill just delete the pair again with delete config.ip

what i wish for the future

  • command limitations to one or more specific channels
  • multiple fx server support
  • kick and ban messages to be displayed in a bot-specific channel
    • EG: $user$ got kicked by $author$ \nReason: $reason$

i already did the first and second thing for myself but if you would include that - that would be much more clean. Also tried to do the last point and had some trouble because of the asynchronous nature of the code.

id like to see a little more clean code, a few more functions here and there to not rewite code all the time and stuff like that. :slight_smile:

Noted! That may take some time, but I will try my best…

You probably already noticed, but that is my first script in Javascript :sweat_smile:
Still learning the basics

1 Like

for your first script its very solid :slight_smile:

1 Like

Your bot token is wrong…

I cant find

DiscordToFiveM Bot Password

set DTF_Password “ENTER_A_PASSWORD_HERE”

Where is it at? What file?

Are you guys even reading or just posting dumb questions?

I mean, I WROTE WHAT TO DO!

f08071b22d494b43fc842018494eab7d

Does it matter what line we put it in the .cfg file, should it be at top, bottom or does it not matter?

That doesn’t really matter

Sounds good man, im trying to get the bot to work rn, its not going online! But thanks!

I dont get that part

Got this bot working great, my only question is:

How can I set this up to auto start when the server starts? rather than having to manually start it every time

You could create a batch (Windows) / sh (linux) file and autostart it at system start.

Please use google for more information.