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

Merge with upstream #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ Thumbs.db
UserInterfaceState.xcuserstate

.idea
.idea
/z-bot-config.js
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* [NodeJS](https://nodejs.org/en/)
* [Git](https://nodejs.org/en/) ( Only if you clone the repository, you can do it without git if you download the ZIP )

Version LTS (8.11.4) should be enough and stable.
NodeJS Version LTS (8.11.4) should be enough and stable.

Currently only tested on Mac & Linux but this version should work on windows.

Expand All @@ -30,6 +30,8 @@ If you don't know your [guild id?](https://support.discordapp.com/hc/en-us/artic

Create a [discord app](https://discordapp.com/developers/applications/me) and fill in the key for your bot in the [config.js](https://github.com/DevZupa/Z-Bot-Light/blob/master/config.js).

NEW: at the tab "Privileged Gateway Intents" check all INTENTS for the bot to be able to connect and read your server.

Invite your bot to your Discord server.
```js
https://discordapp.com/oauth2/authorize?client_id=YOURBOTID&scope=bot&permissions=66321471
Expand Down
63 changes: 47 additions & 16 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ module.exports = {

version: "1.0.0",

// The bot's command prefix. The bot will recognize as command any message that begins with it.
// The bot's command prefix (The rcon prefix is lower in config.). The bot will recognize as command any message that begins with it.
// i.e: "!zbot foo" will trigger the command "foo",
// whereas "Z-Bot foo" will do nothing at all.
prefix: "!zbot",

// Your bot's user token. If you don't know what that is, go here:
// https://discordapp.com/developers/applications/me
// Then create a new application and grab your token.
token: "MjUzMTEwNjgwMzYwNTgzMTY5.CzWAWw.DTBgOxa4sQIc68fy7btU09kFoEA", // Test token (Z-Bot (Dev))
token: "NjEzNjgyODk0Nzk1NDQwMTI4.XV0ezg.xxxxxxxxxxxxxxxxxxxxxx", // Test token (Z-Bot (Dev))

encryptionKey: '4zcMONp61gpVDcuckG0u',
encryptionKey: '4zcMONp61gpVDcuckG0u', // leave it be

defaultPlayingStatus: 'RCon',

Expand All @@ -39,6 +39,8 @@ module.exports = {
channel: 'bot-log'
},

ignoreOtherBotMessages: true,

rconReconnect: 30000, // Miliseconds to try reconnect, if server restart or somehow disconnected ( 30 000 = 30 sec )
loginAttempts: 20, // total login attempts every x seconds when connection is lost ( eg: when server restarts. )

Expand All @@ -55,6 +57,16 @@ module.exports = {
log: "bot-log" // to log all your technical bot messages.
},

watcher: [
{
active: false,
channel: 'bot-kill',
directory: 'logs/', // Can also be an absolute path (eg: "C:/Users/server/logs/" )
file: 'KillFeed_*.log', // Supports wilcard (*), this will check all the files with the given filter and takes the last modified one to monitor
// This is done so there can be log rotations in the same folder.
}
],

bercon: {
enabled: true,
colors: true,
Expand All @@ -63,9 +75,24 @@ module.exports = {
name: 'Zupa test server', // Just your
ip: '195.xx.xxx.xxx',
port: 2303,
rconPassword: 'xxxxxxxx',
rconPassword: 'yourpass',
timezone: 2, // must be number, if negative just put -2

rconCommand: '!rcon', // pretext for a command ex: !rcon say all welcome
sendMessagesAsEmbeds: true, // if false, bot posts as code block with coloring. If yes, visual crads with white/black text and channel color as left border.
embedColors: { // Hex color of the embed borders.
side: '#6ABEE7',
direct: '#959AA4',
vehicle: '#DBBD48',
group: '#3A8347',
admin: '#ff0000',
privateadmin: '#ff00ff',
default: '#ffffff',
commands: '#ffffff',
joins: '#92FA4D',
global: '#6ABEE7'
},

actions: [ // actions only for this server.
{
command: '!server ts', // Command that a player can type ingame
Expand All @@ -75,29 +102,33 @@ module.exports = {
}
],
channels: {
default: 'bot-text', // mandatory
side: 'bot-text',
direct: 'bot-text',
vehicle: 'bot-text',
group: 'bot-text',
admin: 'bot-text',
default: 'bot-text',
privateadmin: 'bot-text',
commands: 'bot-text',
joins: 'bot-text'
joins: 'bot-text',
global: 'bot-text'
},
showChannels: {
side: true,
direct: true,
vehicle: true,
group: true,
admin: true,
default: true,
commands: true,
joins: true
side: true, // Arma only
direct: true, // Used in DayZ SA and arma ( In Dayz, these are part of global chat but filtered to separate stream )
vehicle: true, // Arma only
group: true, // Arma only
admin: true, // Used in DayZ SA and arma ( RCON chat that is private or join messages )
privateadmin: true, // Used in DayZ SA and arma ( Text that is sent via rcon to 1 person )
default: true, // Used in DayZ SA and arma ( Fallback for non-mapped messages if there are any )
commands: true, // Used in DayZ SA and arma ( Poeple with the role ( set a bit lower ) can use the given discord channel to type commands.
joins: true, // Used in DayZ SA and arma ( Join messages )
global: true // Used in DayZ SA and arma sometimes ( Global dayz chat )
},
jobs: [
{
time: '0 15 * * * *', // Command that a player can type ingame
text: 'Enjoy your stay!', // Bot response ingame
time: '0 15 * * * *', // CRON Timer - google CRON
text: 'Enjoy your stay!', // Bot chat in game
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
vehicle: true,
group: true,
admin: true,
privateadmin: true,
default: true,
commands: true,
joins: true,
Expand All @@ -16,6 +17,7 @@ module.exports = {
vehicle: 'rcon',
group: 'rcon',
admin: 'rcon',
privateadmin: 'rcon',
default: 'rcon',
commands: 'rcon',
joins: 'rcon',
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/about.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Clapp = require('../modules/clapp-discord');
const Clapp = require("../modules/clapp");

module.exports = new Clapp.Command({
name: "about",
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/disconnect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Clapp = require('../modules/clapp-discord');
const Clapp = require("../modules/clapp");

module.exports = new Clapp.Command({
name: "disconnect",
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/listinfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Clapp = require('../modules/clapp-discord');
var Helper = require('../modules/z-bot-helper');
const Clapp = require("../modules/clapp");
const Helper = require('../modules/helper');

module.exports = new Clapp.Command({
name: "listinfo",
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/liststats.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Clapp = require('../modules/clapp-discord');
var Helper = require('../modules/z-bot-helper');
const Clapp = require("../modules/clapp");
const Helper = require('../modules/helper');

module.exports = new Clapp.Command({
name: "liststats",
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/maker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Clapp = require('../modules/clapp-discord');
const Clapp = require("../modules/clapp");
const Helper = require('../modules/helper');

module.exports = new Clapp.Command({
name: "maker",
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/reload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Clapp = require('../modules/clapp-discord');
const Clapp = require("../modules/clapp");
const Helper = require('../modules/helper');

module.exports = new Clapp.Command({
name: "reload",
Expand Down
39 changes: 15 additions & 24 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
/**
* Load all external dependencies TODO: Move these to the files that need them instead of passing them as properties ( DIRTY ).
*/
const Discord = require('discord.js');
const query = require('game-server-query');
const qs = require("querystring");
const request = require("request");
const bluebird = require("bluebird");
//const redisNode = require("redis");
const { Client, GatewayIntentBits } = require('discord.js');

/**
* Load all internal dependencies
*/
const Clapp = require('./modules/clapp-discord');
const ZBotEvents = require('./modules/z-bot-events');
const ZBotRedis = require('./modules/z-bot-redis');
const Clapp = require('./modules/clapp.js');
const ZBotEvents = require('./modules/events.js');
const cfg = require('../config.js');
const defaultConfig = require('../defaults.js');
const pkg = require('../package.json');

/**
* Create bot instance.
*/
let bot = new Discord.Client({ autoReconnect: true });

/**
* Make the redis functions async.
*/
// bluebird.promisifyAll(redisNode.RedisClient.prototype);
// bluebird.promisifyAll(redisNode.Multi.prototype);
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.MessageContent,
] });

/**
* Initiate Clapp module
* This module is an clean and easy implementation for replying to ! commmands.
* @type {App}
*/
let clapp = new Clapp.App({
const clapp = new Clapp.App({
name: cfg.name,
desc: pkg.description,
prefix: cfg.prefix,
Expand All @@ -59,13 +54,9 @@ let clapp = new Clapp.App({
* This will be your medium between Discord Events and ZBot.
* @type {ZBotEvents}
*/
const events = new ZBotEvents(cfg.token, {
bot: bot,
const zBotEvents = new ZBotEvents(cfg.token, {
bot: client,
cfg: cfg,
clapp: clapp,
query: query,
qs: qs,
request: request,
redisNode: null,
defaultConfig: defaultConfig
});
});
Loading