Ramy Hazem
Ramy Hazem

Reputation: 130

Get user to set role ID

Im trying to setup a system where the user can change the role ID for staff but every time i restart my bot the ID resets back. Here is my code:

this is estaff.js

const roles = require("./roles");

module.exports = {
  name: "estaff",
  callback: ({ message, args }) => {
    if (args.length === 0)
      message.channel.send(`Current estaff role is <@&${roles.EstaffRole}>`);
    else {
      roles.EstaffRole = args[0];
      message.channel.send("Successfully changed estaff role");
    }
  },
};

this is the roles.js file:

const roles = {
  HstaffRole: "956109121550168114",
  GstaffRole: "956112990116134953",
  EstaffRole: "932558453203943434",
};

module.exports = roles;

Upvotes: 0

Views: 153

Answers (1)

SamSJackson
SamSJackson

Reputation: 81

I think you are misunderstanding how data is stored in this case.

This is not permanent storage, for a problem like this then you would require a database/storing system.

To help you understand, what you currently are doing is:

const roles = require("./roles");

This will get you a reference to the array in roles.js.

Assuming the call has the necessary arguments, you then

roles.EstaffRole = args[0];

This is going to change the array in roles, but not the files in roles.js.

Perhaps you could run this while looking at your roles.js and realise that you are not really changing anything, it will only work as long as your server/program is running.

Upvotes: 2

Related Questions