Browse Source

no longer returning undefined for user/guild metadata in logs

tarfeef101 4 years ago
parent
commit
d441db40de
1 changed files with 33 additions and 2 deletions
  1. 33 2
      src/viki.js

+ 33 - 2
src/viki.js

@@ -1,6 +1,30 @@
 // Load up the discord.js library
 const Discord = require("discord.js");
 
+// Load up the shell command library
+var exec = require('child_process').exec;
+
+// Load up the queue library
+const Queue = require('./Queue.js');
+
+// Define a function to execute a command
+
+function execute(command, callback)
+{
+  exec(command, function(error, stdout, stderr)
+  {
+    callback(stdout);
+  });
+};
+
+// Define a new function to search + replace a char in a string
+String.prototype.replaceAll = function(remove, replace)
+{
+    var target = this;
+    return target.split(remove).join(replace);
+};
+
+
 // Initialize the bot.
 const client = new Discord.Client();
 
@@ -8,6 +32,13 @@ const client = new Discord.Client();
 var connection;
 var dispatcher;
 
+// this is the playlist queue for music
+var playlist = new Queue();
+
+// Array of music classes users can call (artist, track, etc)
+const musicTypes = ['track', 'title', 'song', 'artist', 'album'];
+const musicTypesString = "track, title, song, artist, album";
+
 // Here we load the config.json file that contains our token and our prefix values.
 const config = require("./config.json");
 // config.token contains the bot's token
@@ -17,9 +48,9 @@ const config = require("./config.json");
 client.on("ready", () =>
 {
   // This event will run if the bot starts, and logs in, successfully.
-  console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
+  console.log(`Bot has started, with ${client.users.cache.size} users, in ${client.channels.cache.size} channels of ${client.guilds.cache.size} guilds.`);
 
-  console.log(`users: ${client.users}`);
+  console.log(`users: ${Array.from(client.users.cache.values()).map(each => each.username)}`);
 
   // Example of changing the bot's playing game to something useful. `client.user` is what the
   // docs refer to as the "ClientUser".