Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question #3

Closed
dariuskis opened this issue Feb 28, 2021 · 9 comments
Closed

question #3

dariuskis opened this issue Feb 28, 2021 · 9 comments

Comments

@dariuskis
Copy link

its about config.json
{
"prefix": "!",
"token": "",
"required_role": {
"use": true,
"name": "trusted"
}
}

where to put role i cant get it is "trusted" ?

@nlssn
Copy link
Owner

nlssn commented Feb 28, 2021

Yes, the name of the authorized role is called 'trusted'.

You can change it to another name of a role that you have on your Discord - just make sure it's an exact match, capitalization and all.

If you would like to let anyone use the commands, just set 'use' to false.

@dariuskis
Copy link
Author

and how to connect bot to server? i cant get how does it works
const script = exec('.././vhserver restart');

@dariuskis
Copy link
Author

and backup its not of all server , only of vhserver.db witch is located in /home/vhserver/.config/unity3d/IronGate/Valheim/worlds that it would do a zip with a date in tar.gz

@nlssn
Copy link
Owner

nlssn commented Mar 1, 2021

and how to connect bot to server? i cant get how does it works
const script = exec('.././vhserver restart');

The code you are referencing is for restarting the Valheim server.

The bot automatically connects when you run it, by typing npm run start in a console.

You do need a Discord bot account/application set up and its token added to the config.json. Would you like instructions on how to do that?

@nlssn
Copy link
Owner

nlssn commented Mar 1, 2021

and backup its not of all server , only of vhserver.db witch is located in /home/vhserver/.config/unity3d/IronGate/Valheim/worlds that it would do a zip with a date in tar.gz

As of right now I'm just executing the commands that LinuxGSM provide.

I think it would be great to have a way to just back up the world. Perhaps separat the functionality with an argument like !backup world.

I have very limited time to work on this. So if you are interested in writing some code for a solution, I would gladly accept a pull request 🙂

@dariuskis
Copy link
Author

and backup its not of all server , only of vhserver.db witch is located in /home/vhserver/.config/unity3d/IronGate/Valheim/worlds that it would do a zip with a date in tar.gz

As of right now I'm just executing the commands that LinuxGSM provide.

I think it would be great to have a way to just back up the world. Perhaps separat the functionality with an argument like !backup world.

I have very limited time to work on this. So if you are interested in writing some code for a solution, I would gladly accept a pull request 🙂

Here it is from another bot and it works.
case 'backup':
if (message.member.hasPermission('ADMINISTRATOR')) {
// back back back it up
try {
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const dateFmt = ${year}-${month}-${day};
const newFile = ${backupPath}/${process.env.backupFileName}-${dateFmt}.tar.gz;
const { stdout, stderr } = await exec(
tar -cvzf ${newFile} ${db} ${fwl}
);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
message.channel.send(
World successfully backed up as ${process.env.backupFileName}-${dateFmt}.tar.gz
);
} catch (err) {
console.log('Error backing up world.');
console.log(err);
message.channel.send('Oops... I broke it.');
}
} else {
message.channel.send('YOUR NOT MY DAD!');
}
break;

  here is all source code raw https://raw.githubusercontent.com/JacobMillner/valheim-discord-bot/trunk/main.js

@dariuskis
Copy link
Author

and for me its not working it writes :
Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency

@nlssn
Copy link
Owner

nlssn commented Mar 2, 2021

and for me its not working it writes :
Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency

The bot starts running even tough that error gets shown.

A quick google tells me this is a problem when using Node v14. Downgrading to v12 LTS will fix the problem. I'll add it as a low prio bug.

@nlssn
Copy link
Owner

nlssn commented Mar 2, 2021

Closing this as all questions have been answered and new issues have been created instead.

@nlssn nlssn closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants