#development

1 messages ยท Page 940 of 1

hasty sparrow
#

You could potentially promisify this, but run risks of promises hanging if not receiving a response

modest maple
#

@viral spade Do you cache all ur querys btw

viral spade
#

what do you mean exactly? i cache only info that is necessary. and i think the mysql engine caches queries per default.

#

@modest maple

hasty sparrow
#

You might not have to pass discord entities by using some js magic

pale vessel
#

you can also use ```js
${member}

modest maple
#

I mean do you actually Prepare all your statements rather than sending the DB a query string every time

viral spade
#

nope, but thanks for that top i will look at it

modest maple
#

bruhhhhhh

#

thats like

#

Speed DBs 101 lol

#

Preparing Querys reduce the number of round trips to the DB server per request

#

especially when you're calling alot of querys

viral spade
#

thats a nice optimization

#

but i am still not sure about the basic infrastructure

modest maple
#

thats the SQL version

#

MySQL's prepared system is dumb af tho lol

#

Compared to Other systems where you can store it as Vars and just do execute some_name and then some values with just one query request

wild mist
viral spade
#

Yeah but what about the base infratsructure?
assume 2000 shards. Assume each bot server can handle 100 shards, so 20 bot servers, each database server handles 200000 guilds, so 10 database servers. And 1 coordination server that holds the guild to database locations info, which are then cached to clients guild objects.

I have to retrieve and cache each guildmember on first text or voice activity.

How would you assemble these connections between shard and guild db? @modest maple

modest maple
#

i wouldnt assume a single instance can take 100 shards

viral spade
#

okey so how many?

modest maple
#

200,000 Guilds could easily be handled by a single Server and a DB server with cache db partnering it

viral spade
#

okey then imagine the same question, but with changed values, like 40 bot servers and 10 database serves..

How would you assemble these connections between shard and guild db?

still merlin
#

can someone help-
my code

client.on("message", (message) => {
  if (message.author.bot) return;
  if ([message.author.id])
    [message.author.id] = {
      xp: 0,
      level: 0,
    };
  db[message.author.id].xp++;
  let userInfo = db[message.author.id];
  if (userInfo.xp > 100) {
    userInfo.level++;
    userInfo.xp = 0;
    message.reply("Congratulations, you level up");
  }
  const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  const cmd = args.shift().toLowerCase();
  if (command === "info") {
    let userInfo = db[message.author.id];
    let member = message.mentions.members.first();
    let embed = new Discord.RichEmbed()
      .setColor(0x4286f4)
      .addField("Level", userInfo.level)
      .addField("XP", userInfo.xp + "/100");
    if (!member) return message.channel.sendEmbed(embed);
    let memberInfo = db[member.id];
    let embed2 = new Discord.RichEmbed()
      .setColor(0x4286f4)
      .addField("Level", memberInfo.level)
      .addField("XP", memberInfo.xp + "/100");
    message.channel.sendEmbed(embed2);
  }
  fs.writeFile("./database.json", JSON.stringify(db), (x) => {
    if (x) console.error(x);
  });
});

is getting a error (will paste in now) the bot powers online just fine but when someone is suppost to level up my terminal says:

#
[WS => Shard 0] Heartbeat acknowledged, latency of 277ms.
C:\Users\Jon\Desktop\SpiderBot Project\index.js:383
    [message.author.id] = {
                        ^

TypeError: undefined is not a function
    at Client.<anonymous> (C:\Users\Jon\Desktop\SpiderBot Project\index.js:383:25)
    at Client.emit (events.js:224:7)
    at MessageCreateAction.handle (C:\Users\Jon\Desktop\SpiderBot Project\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Jon\```
earnest phoenix
#

what library is that?

still merlin
#

discord.js

earnest phoenix
#

version?

modest maple
#

If i was scaling across machines i would use a SQL server farm and a load balancer between the DBs

still merlin
#

12.2.0

modest maple
#

combined with a Cache DB

#

However

#

I would mostly just Make Auto Scaling Database running on a single Dedi

earnest phoenix
#

an array?

modest maple
#

and have the other Multi machine bot connections go to the Api

earnest phoenix
#

try that

still merlin
#

nvm its fixed

earnest phoenix
#

kk

modest maple
#

assuming each cluster group had its own Cache DB like Reddis that API could scale to insane numbers

earnest phoenix
#
  fs.readdir("./parts/", (err, files) => {
  if (err) console.log(err);
  let jsfile = files.filter(f => f.split(".").pop() === "js" && f !== "Part.js");
  if (jsfile.length <= 0) {
    console.log("Couldn't find parts.");
    return;
  }
    let indexn = Math.floor(Math.random() * jsfile.length);
    part = jsfile[indexn];
    console.log(jsfile, jsfile.length, indexn);
});
```Little help here? It only logged jsfile and the rest is undefined. Any idea why?
wild mist
#

K thanks

lucid mesa
#

Who uses DiscordGo here ?

viral spade
#

@modest maple and have the other Multi machine bot connections go to the Api what do you mean by this? Why do you need an api? i mean you can directly connect to the databases, also redis, no?

still merlin
#

in discord.js @earnest phoenix ?

modest maple
#

Assuming Each Machine had its own Cache Db

#

the API could be anything

#

its just a general term for interacting with the DB

viral spade
#

Ok and with cache db, you mean a db on localhost? on disk or memory? Does this have to be a db or do you also mean stuff like a simple in-code javascript collection with this?

modest maple
#

i Mean an actual Cache DB

viral spade
#

like redis?

modest maple
#

yh

#

You would send all requests to the cache DB for reads, if the Cache hasnt got a recent value for the request it fetched from the DB server

viral spade
#

ok and the one "backup" db behind the api is also redis, with persistency or what would you take there?

modest maple
#

the DB in that diagram would be somthing like postgres or Mongo etc...

#

which is not cache

#

The Cache Dbs (Assuming for multi machine scaling you would be on some big dedis) would be using alot of ram

#

so they would handle 95% of all read write traffic

#

reducing the overall requests a sec on the DB itself

viral spade
#

why writes? writes need to go to the api, no?

#

(bundeled in transaction ofc)

modest maple
#

Depends what Cache Db u use

earnest phoenix
#

guess i will post later since my question is 99% gotta ignored because of a conversation happening

modest maple
#

Some support Writing also and then manages sending it to the main DB anyway

#

which would work along the lines of every X amount of minutes it would bundle all writes its had and execute a bulk query to the Db

viral spade
#

Okay that sounds nice. thank you very much so far.
What i still dont see.. When a guildowner resets the stats of a guild in my bot, it deletes all data of all guildmembers and this takes some time, as its possibly hundrets of thousands of rows. i cannot image how this works out with only one single persistent database.

modest maple
#

It would Dump all the data for the Guild in the Cache DB (Which cuz cache takes seconds) and then the Cache DB can control dumping data from the main Db

#

things like PostgreSQL support bulk deleting rows in single querys

viral spade
#

i am deleting in a single query, and it takes long and i think it is normal to take that long for hundrets of thousands of rows.

i think it is so expensive, because the primary key is clustered, so it needs to rearrange the rows on the disk. idk

modest maple
#

I think that just comes down to Size of Data and MySQL's lack of efficency

viral spade
#

Also, with the reset, i do not really save much by writing it to cache first. Yes i can even out the update progress, but i dont have less to delete, aside maybe a few who in the meantime wrote something.

modest maple
#

Refers more to downtime

#

Cache can Dump data faster than IO bound DB

#

which gives the Db a buffer period

#

I mean IDK how you have you system setup

viral spade
#

thats what i meant with even out the update process. still i dont have less to delete, the deletes take long and theres reset commands coming in every minute.

#

so that will be every second in not so long

modest maple
#

How big are the datasets per guild?

viral spade
#

like 1 mb on average

#

more 0.5

#

but there should be room for new features too

fickle arch
#

i tried to make bot status it usually like

    console.log('Your Text Here');
    client.user.setActivity('Text here', { type:"WATCHING"}).catch(console.error);
});```
but my new code has delete const client instead of 
```const {
  Client,
  Client: { plugin }
} = require("");```
after i using that my bot activity not shown up.
#

but if i tried putting const client back it still the same not showing up, i tried change client.once to plugin.once but it shown error about not a function.

nocturne grove
#

what are you even trying to do?

earnest phoenix
#
let parts = ["Zeta", "0"];
let indexn = Math.floor(Math.random() * parts.length);
let part = parts[indexn];
    console.log(parts, part, indexn);
``` little help here? only parts can be defined using console.log and I don't quite get why
hasty sparrow
#

What?

earnest phoenix
#

?

hasty sparrow
#

only parts can be defined using console.log and I don't quite get why

earnest phoenix
#

i mean like the console only outputs the parts variable

#

part and indexn are both ignored

hasty sparrow
#

Ah

robust moth
zenith terrace
#

Permissions.every is not a function

balmy knoll
#

Hi, in discord.js, how can i get an user object by user id?

elder vine
#

If you're using v12 discord.js

client.users.fetch(user_id_here)

balmy knoll
#

Thanks

earnest phoenix
#

how i can hide a link behind a text

#

You need more commands, or you have some idea. Join the [Support server](https://discord.gg/Q2eZs6A) and Tell us

#

i tried this but not working

#

i called the text from a json file

#

oh

#

oof

zenith terrace
#

Noice

sudden geyser
#

Fun fact: You can send links like that in plain text through webhooks.

digital ibex
#

hi, i'm a big confused how i need to do this

#

i'm trying to do something like, {repeat:text-here} and then my bot will send text-here, how would i do that?

#

ik i have to do something with regex, not sure how though

#

in js btw

white anvil
#

split the instruction to operation and operand (via the :), parse out the brackets and send the operand

digital ibex
#

oh

#

thats easier than i thought

#

ty

#

@white anvil , i'm a bit confused, i came up with js '{repeat:eeeee}'.split(':')[1].split('}')[0] but what would i put where eeee is?

grizzled raven
#

oops

#

meant to backspace

still merlin
#

why did you tag me

grizzled raven
#

it was a mistake

#

๐Ÿ˜ค

#

well now that you've seen my mistake i can remove it and clear up the chat

amber fractal
#

why not just parse it as a js object (if it's json)?

#

why go through the hassle of splitting

digital ibex
#

its not json

turbid bough
#

you can only await in an async function

rain jacinth
#

lol

#

????

#

so

#

i need an async

digital ibex
#

yes

amber fractal
#

Why is it structured exactly like {repeat:text} then

rain jacinth
#

where.... on line 33???

turbid bough
#

idk whats line 33

digital ibex
#

i'm doing it for my custom commands

rain jacinth
#

the error

digital ibex
#

so its like

rain jacinth
#

@turbid bough line 33 is where the error is

digital ibex
#

cc create helllo {repeat:ee} e

turbid bough
#

the beginning of the function

#

thats where you add your async

digital ibex
#

oh wait

#

i'm dumb

#

hahaha lol

rain jacinth
#

line 33 is the beginning of the function...

digital ibex
#

that won't work at all lmfao

turbid bough
rain jacinth
molten coral
#

Hi can someone help ? I'm trying to use better-sqlite3 but i can't find any tuto and i don't understand anything TwT

#

Pls T-T

pale vessel
#

docs

molten coral
#

Yea but it doesn't work

pale vessel
#

tell us more than "it doesn't work". read the channel topic

#

give details

molten coral
#

yea

pale vessel
#

how are we going to help you

molten coral
#
db.prepare('INSERT INTO test (name, age) VALUES (@name, @age)')
   ^
SqliteError
#

ยฐ-ยฐ"

digital ibex
#

hi, quick question. how can i make my bot still respond? i mean like if i do !ping it will respond, if i do !ping ee it won't respond. how can i make it respond even wid `ee on the end?

pale vessel
#

use startsWith

molten coral
#

yea

digital ibex
#

kk, thanks

molten coral
#

I've also put ```sql
sql.prepare("CREATE TABLE scores (name TEXT, age INTEGER);").run()

digital ibex
#

ok, so

molten coral
#

^-^

rain jacinth
#

I'm just dumb ๐Ÿ˜ฆ

earnest phoenix
#

can I use a forEach on channel.updateOverwrite

digital ibex
#

i done js if (args.join(' ').startsWith(a)) { /* & message.content.startsWith(a) */ /* do whatever i want here */ } but nothing responds, any ideas why? before i was just doing ```js
if (a) {
/* do whatever i want here */
}

#

yes @earnest phoenix

earnest phoenix
#

aight

digital ibex
#

@pale vessel any ideas why?

pale vessel
#

a is command name right?

digital ibex
#

yeah

pale vessel
#

and the args don't contain the prefix

digital ibex
#

nope

pale vessel
#

you can console.log a and args.join()

#

let me know the values

digital ibex
#

kk

#

when i do ;;ping, args.join(' ') logs ping

#

when i use a cc, like ;;p it logs { name: 'p', response: 'p' }

#

otherwise a logs undefined

pale vessel
#

what even is a lol

digital ibex
#

guild.commands.find((e) => args.join(' ') === e.name)

#

when i was just doing if(a).. it would work fine

#

when i do if(args.join(' ').startsWith(a)) and if(message.content.startsWith... nothing responds

pale vessel
#

that's an odd way of doing that

digital ibex
#

i'm trying to allow more than 0 arguments

#

ยฏ_(ใƒ„)_/ยฏ

pale vessel
#

uh

#

only you know how your system works

still merlin
#

I made a setNSFW command and i have no errors and it says "The channel is now NSFW" but its not? my code is:

client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");

  switch (args[0]) {
    case "setNSFW":
      if (!message.member.hasPermission(["MANAGE_CHANNELS", "ADMINISTRATOR"]))
        return message.channel.send(
          "**error** You need the manage channels permission!"
        );
      message.channel.setNSFW;
      message.channel.send("โ˜… I have set the channel to NSFW! โ˜…");

      break;
  }
});
digital ibex
#

won't message.channel.setNFSW be a function?

pale vessel
#

setNSFW is a method, if that's even a thing

#

yeah

still merlin
#

I was typing message.channel. and it had auto fill and setNSFW was a option

#

so i created a new command for setNSFW

pale vessel
#

i meant three lines before the break

still merlin
#

wdym

#

is there a reason my command isnt working

pale vessel
#

setNSFW should be a method

#

/function

still merlin
#

oh so i need a function insted of setNSFW

digital ibex
#

do u know why my thing aint responding? no clue why its not

#

no @still merlin

#

setNFSW is a function

still merlin
#

ok

robust moth
amber fractal
#

replace doesn't do all

#

use /_/g

#

It's regex and the g means global

sudden geyser
#

You sure you don't want to make all those permissions a bit more readable? Such as making it in title case form?

opaque seal
#

<style> html, body { background:#232323; } </style>

I've tried to use that to change my bot page background but it isn't working?

still merlin
#

omg tysm!

stuck scaffold
#
bot.shard.broadcastEval(`this.users.cache.get("335490587740471297").send("${embed}")`)```
2 times sending messages
#

I want it to send 1 time

zenith orchid
#

I think the User has different shards

stuck scaffold
#

How can I get the bot to send 1 message

#

no

#

2 shards

pale vessel
#

idk, return?

#

oh don't

zenith orchid
#

Where do you use?

stuck scaffold
#

eval

zenith orchid
#

You can get some guild (includes the User), get the user then send message.

devout turtle
#

hmm

viral spade
#

When implementing a simple cache for guild settings and i am starting up a shard, then big guilds will cause the cache load "at the same time" as one event comes in before the other events cache load is finished.

What is the best practice to prevent this? should i not care and simply let it overwrite? or introduce a "loadingGuildIds" set (events getting ignored if the guild is currently loading)?

haughty night
#

or just add !important

earnest phoenix
#

I am trying to learn discord-akario

knotty steeple
#

pls just use normal css

earnest phoenix
#

what do i do with this code?

knotty steeple
#

ur using background when its supposed to be background-color

#

read

earnest phoenix
#

where should i put it?

knotty steeple
#

when u want to load the commands

earnest phoenix
#

class PingCommand extends Command {
    constructor() {
        super('ping', {
           aliases: ['ping'] 
        });
    }

    exec(message) {
        return message.reply('Pong!');
    }
}

module.exports = PingCommand;```
#

i make ping command

knotty steeple
#

ok

earnest phoenix
#

where should i put it?

knotty steeple
#

why is ur alias the same as the command name

#

did u read the docs at all?

earnest phoenix
#

ยฏ_(ใƒ„)_/ยฏ

knotty steeple
#

or example

earnest phoenix
#

yeah i'm read

knotty steeple
#

doesnt seem like u did

#

cuz u cant even use a framework which does everything for u

topaz fjord
#

ew

#

framework

knotty steeple
#

u use the loadall function when u want to load all the commands

#

????

topaz fjord
#

I use my own

knotty steeple
#

same

earnest phoenix
#

sorry my bad english

knotty steeple
#

even tho its just a command handler

earnest phoenix
#

i'm from turkey

#

i'm not understand you

#

๐Ÿ˜ฆ

indigo flax
#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
#

whats wrong with the code, its not working

nocturne grove
#

error maybe?

zenith terrace
#

Version?

#

@indigo flax

earnest phoenix
#

And error logs?

indigo flax
#
  "name": "beats",
  "version": "1.0.0",
  "description": "Beats bot.",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Austin",
  "dependencies": {
    "beautify": "0.0.8",
    "discord.js": "^11.4.2",
    "fs": "0.0.1-security",
    "js-beautify": "^1.11.0",
    "util": "^0.12.3"
  }
}
#

thats package

zenith terrace
#

11.4

#

Ok

nocturne grove
#

and I thought it's never RichEmbed(), but
v11: Discord.RichEmbed()
v12: Discord.MessageEmbed()

#

ok use Discord.RichEmbed(), not just RichEmbed()

earnest phoenix
#

Still, any errors?

zenith terrace
#

U can do it like {} this iirc

indigo flax
#

ok @nocturne grove ill try

nocturne grove
#

oww yes that works, oops

#

@indigo flax no don't change it

indigo flax
#

const { RichEmbed } = require("discord.js");

nocturne grove
#

yes leave that

indigo flax
#

discord isnt defined

nocturne grove
#

what is it doing and what does it not do?

indigo flax
#

i gave u the scri[t

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new Discord.RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new Discord.RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
earnest phoenix
#

What's the error

indigo flax
#

embed

earnest phoenix
#

Give me some kind of error log

indigo flax
#

k

#
                          ^^^^^^^^^
SyntaxError: Unexpected identifier
    at new Script (vm.js:80:7)
    at createScript (vm.js:274:10)
    at Object.runInThisContext (vm.js:326:10)
    at Module._compile (internal/modules/cjs/loader.js:664:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)```
amber fractal
#

why is there a d

stuck scaffold
#

@indigo flax d.RichEmbed()

indigo flax
#

k

zenith terrace
#

d wouldnt be define tho

indigo flax
#

d.richembed

#

it wouldnt be defined

nocturne grove
#

just do RichEmbed what you always did

zenith terrace
#

I dont think it needs to be there if you only defined RichEmbed

nocturne grove
#

don't do the d

zenith terrace
#

Remove the d.

amber fractal
#

because you just deconstruct Discord

stuck scaffold
#

const d = require("discord.js");
d.RichEmbed()

zenith terrace
#

They defined RichEmbed itself

indigo flax
#

yeah it wont work still

#

my current script is

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
nocturne grove
#

error?

indigo flax
#

logs say

#

let embed = new .RichEmbed()
^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

haughty night
#

remove the dot

nocturne grove
#

yes but I don't see a dot in your code ๐Ÿค”

haughty night
#

its coming from somewhere

indigo flax
#

there is no dot

#

^

earnest phoenix
#

There's one

zenith terrace
#

maybe add the . zoomeyes

indigo flax
#

this correct tho

#

message.channel.send(embed);

#

right?

#

SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

zenith terrace
#

Yes thats correct

indigo flax
#

omg whats wrong

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
#

i dont understand

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
zenith terrace
#

@earnest phoenix I don't get where u sre saying the .

still merlin
earnest phoenix
#

you gotta actually enter a file name afaik

still merlin
#

i dont use that on my other bots

#

i just go node . on my index.js and it turns online-

earnest phoenix
#

read a tutorial on how to run node programs

still merlin
#

right so node index.js

#

ok

#

I did node index.js and same error

#

still same error

#

did i install node.js wrong. (i had to reinstall)

earnest phoenix
#

plottwist: he doesnt have node installed pogey

still merlin
#

maybe thats the case

earnest phoenix
#

go ahead and install it then

still merlin
#

I'm actuccly asking for a friend- they sent that error but no one responded and so i asked for them

toxic jolt
earnest phoenix
#

cannot read property of undefined, explains it all

#

discordjs version?

white anvil
#

check that you have node in your PATH variables

#

@still merlin

toxic jolt
#

"discord.js": "^11.5.1",

white anvil
#

if its installed then this could be the problem

toxic jolt
#

Should I use "message" instead of "msg"?

frail ocean
#

No since you defined it as msg.

#

It'd make no difference,

still merlin
#

my friend dosen't have a path and dosen't know what that means

frail ocean
#

It could be since the message was a DM, rather than in the server.

still merlin
#

but they have node modules file

earnest phoenix
still merlin
#

Me and my friend are rly happy rn thank u for that link!

toxic jolt
#

how do i fix it?

#

hmm

#

if (msg.guild.id === '264445053596991498') return console.log('Will it be like this?')

golden condor
#

Hi, I am trying to using shoukaku, how do I search for a song?

earnest phoenix
golden condor
#

I couldn't see it there

mystic ice
#

anyone use mongodb?

#

if so, can you use find without filter

indigo flax
#

it still doesnt work

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
#

ID

#

idk

#

it doesnt work

#

:/

#

let embed = new .RichEmbed()
^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

#

there is no .richembed

#

???

#

look at the code

#
const beautify = require("beautify");

module.exports = {
  name: "eval",
  aliases: ["e"],
  description: "Eval command.",
  usage: "<code to eval>",
  execute:  (bot, message, args) => {
    if (message.author.id !== "503641535342968832") {
      return message.channel.send("You don't have permission to use this command.")
      .then(m => m.delete(5000));
    }
    
    if (!args[0]) {
      message.channel.send("You need to eval _**SOMETHING**_, please?")
        .then(m => m.delete(5000));
    }
    
    try {
      if(args.join(" ").toLowerCase().includes("token")) {
        return;
      }
      
      const toEval = args.join(" ");
      const evaluated = eval(toEval);
      
      let embed = new RichEmbed()
        .setColor("#00FF00")
        .setTimestamp()
        .setFooter(bot.user.username, bot.user.displayAvatarURL)
        .setTitle("Eval")
        .addField("To evaluate:", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
        .addField("Evaluated:", evaluated)
        .addField("Type of:", typeof(evaluated));
      
      message.channel.send(embed);
    } catch (e) {
        let embed = new RichEmbed()
          .setColor("FF0000")
          .setTitle("\:x: Error!")
          .setDescription(e)
          .setFooter(bot.user.username, bot.user.displayAvatarURL);
      
      message.channel.send(embed);
    }
  }
}```
earnest phoenix
#

example from the discordjs docs

indigo flax
#

where is there .richembed

earnest phoenix
indigo flax
#

doesnt work

golden condor
#

What is the search method in shoukaku?

indigo flax
#

idk

#

ill upload to glitch

#

does anybody have glitch

earnest phoenix
mystic ice
#

please ping if u know something about mongodb/mongoose

golden condor
#

I can't see where it is

earnest phoenix
#

you're really not checking are you?

golden condor
#

@earnest phoenix I am tryna

indigo flax
#

@earnest phoenix add me, can we discuss in dms?

golden condor
#

I can't see it

earnest phoenix
#

check in the commands presumably?

golden condor
#

Is it the rest thing?

earnest phoenix
#

could be

golden condor
#

Is it this

#

const result = await node.rest.resolve(query);

earnest phoenix
golden condor
#

Can you just give me a straight answer ffs

indigo flax
#

now index is having an error

#
    at Client.emit (events.js:189:13)
    at MessageCreateHandler.handle (/rbd/pnpm-volume/9fa0b08b-19da-4e92-aaac-b7e3b1931a40/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/rbd/pnpm-volume/9fa0b08b-19da-4e92-aaac-b7e3b1931a40/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
    at WebSocketConnection.onPacket (/rbd/pnpm-volume/9fa0b08b-19da-4e92-aaac-b7e3b1931a40/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
    at WebSocketConnection.onMessage (/rbd/pnpm-volume/9fa0b08b-19da-4e92-aaac-b7e3b1931a40/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
    at WebSocket.onMessage (/rbd/pnpm-volume/9fa0b08b-19da-4e92-aaac-b7e3b1931a40/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:189:13)
    at Receiver.receiverOnMessage (/rbd/pnpm-volume/9fa0b08b-19da-4e92-aaac-b7e3b1931a40/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/websocket.js:789:20)```
golden condor
#

Client.bot ?

earnest phoenix
#

do i look like someone who knows/uses discordjs/Shoukako

#

i just look at the docs and understand it

glossy pollen
#

Thank you Hope, The link worked perfectly! ๐Ÿ˜„

#

(the one about the node .)

earnest phoenix
golden condor
#

i'll try that see if it works

indigo flax
#

OMG

#

IM SO FUSTERATED

#

its not working

earnest phoenix
#

plus the codeblock the error refers to

red terrace
#

Is there a way to check where your bot is in the verification queue?

mossy vine
#

no

red terrace
#

Guess more patience it is.

earnest phoenix
#

if you submitted it and haven't recieved any dms from @gilded plank apart from the "your bot was submitted" one, it wasn't reviewed yet

#

unless you're talking about Discord verification, then nope

red terrace
#

No, I'm talking about the verification in this server. I've only received the submission message from Luca. Any idea how long they take on average? Not that I expect everything to be verified instantly because there's definitely a high influx of usermade bots.

mossy vine
#

1 week or more

red terrace
#

Aha. That makes sense, thank you.

still merlin
#

My bot is being a bit buggy-
I have the the code

client.on("message", (message) => {
  let args = message.content.substring(prefix.length).split(" ");

  switch (args[0]) {
    case "setNSFW":
      if (!message.member.hasPermission(["MANAGE_CHANNELS", "ADMINISTRATOR"]))
        return message.channel.send(
          "**error** You need the manage channels permission!"
        );
      message.channel.setNSFW(true);
      message.channel.send("โ˜… I have set the channel to NSFW! โ˜…");
      if (!message.channel.NSFW)
        message.channel.send("**error** This channel is already NSFW!");

      break;
  }
});

and i have a channel called testing and its marked NSFW and my bot sends channel is already nsfw as well as set channel to nsfw? anyone know why? (bots response:

earnest phoenix
#

you're checking if the channel is nsfw right after you set it

#

so it obviously returns that message because you just set it to nsfw

still merlin
#

ohH so i need to put the checking thing before?

zenith terrace
#

I mean u could try

} else {
if (!message.channel.NSFW)
//rest of code
}
};```

I havent used `} else {` in a while so could be wrong could be right
#

Wait no it is wrong

#

Nvm

#

Ignore that then

fickle arch
#

is there a way to make the bot filtered all possible way of saying bad words like Dyno ?

#

because typing every possible words is a little bit tiring.

still merlin
#

i suppose you could get like a internet pre-list of every bad word

#

and then paste that list into your not allowed words thing

earnest phoenix
fickle arch
#

oh god thanks a lot.

earnest phoenix
#

what is scope?

fickle arch
#

@earnest phoenix I already put module.exports = require ("./words.json") but it still doesn't work.

#

download the npm package to already.

earnest phoenix
#

remember

#

All words are lowercased.

red terrace
#

what is scope?
when you create your oauth2 key, it can be used for a whole lot of different purposes

earnest phoenix
#

thanks

red terrace
fickle arch
red terrace
#

Discord offers these scopes. scope=bot means that that oauth2 key is used to authenticate a bot

earnest phoenix
#

u have if(!message.content.startsWith(prefix)) return; ? @fickle arch

fickle arch
#

use the scope as bot and put permission on admin.

#

no why ? @earnest phoenix

earnest phoenix
#

yo

steel drum
#

@fickle arch you should only ask for the permission your bot actually needs

fickle arch
#

what that mean ?

earnest phoenix
#
if(!message.member.hasPermission("ADMINISTRATOR")) {
      const n = new MessageEmbed()
      .setColor("#ff9900")
      .setDescription(":no_entry_sign: **You don't have the required permission to do that!**");

      message.channel.send(n);

      return;
    }
    let rChannel = message.guild.channels.cache.get(args[0]) || message.mentions.channels.first();
    if(!rChannel) {
      const n = new MessageEmbed()
      .setColor("#ff9900")
      .setDescription(":no_entry_sign: **You need to specify a channel to do that!**")
      .addField("Corect Usage", "lt!prefix [channelMention/channelID] [announce]");

      message.channel.send(n);

      return;
    }

    let ann = message.content.split(`${bot.prefix}announce ${rChannel.id} `).join("")
    if(!ann) {
      const n = new MessageEmbed()
      .setColor("#ff9900")
      .setDescription(":no_entry_sign: **You need to specify what announce do you want to make!**")
      .addField("Corect Usage", "lt!prefix [channelMention/channelID] [announce]");

      message.channel.send(n);

      return;
    }

    const _ = new MessageEmbed()
    .setTitle("**New announcement!**")
    .setColor("#ff9900")
    .setDescription(`${ann}`)
    .setImage('https://cdn.discordapp.com/attachments/711268662048456785/713840607575015504/announcement-wordpress-plugins.png')
    .setThumbnail(message.guild.iconURL({ dynamic: true }));

    rChannel.send(_);
    message.delete();

Why everytime a use the command the bot said that i didn't specify a channel even if i did

limber flume
#

hello

earnest phoenix
#

just

#

ask

limber flume
#

i did ask

earnest phoenix
#

just say your problem then

limber flume
#

ok

#

111py

#
@bot.event
async def on_member_join(member):
    with open('data.json', 'r') as f:
        users = json.load(f)
 
 
    await update_data(users, member)
 
   
    with open('data.json', 'w') as f:
        json.dump(users, f)
 
 
 
@client.event
async def on_message(message):
    if message.author.bot == False:
        with open('data.json', 'r') as f:
            users = json.load(f)
 
 
        await update_data(users, message.author)
        await add_experience(users, message.author, 5)
        await level_up(users, message.author, message)
   
   
        with open('data.json', 'w') as f:
            json.dump(users, f)
 
 
async def update_data(users, user):
    if not f'{user.id}' in users:
        users[f'{user.id}'] = {}
        users[f'{user.id}']['experience'] = 0
        users[f'{user.id}']['level'] = 1
 
 
async def add_experience(users, user, exp):
    users[f'{user.id}']['experience'] += exp
 
async def level_up(users, user, message):
    experience = users[f'{user.id}']['experience']
    lvl_start = users[f'{user.id}']['level']
    lvl_end = int(experience ** (1/4))
    if lvl_start < lvl_end:
        await message.channel.send(f'{user.mention} has leveled up to level {lvl_end}')
        users[f'{user.id}']['level'] = lvl_end
#

this makes my other commands not work

#

but ^ it works fine with the exp

next escarp
#

@old plinth-bot

primal slate
#

@limber flume you need to add await self.bot.process_commands(message) at the end of your on_message block

#

otherwise it stops commands from processing

#

oh, and also you seemed to use a client decorator in one place, and a bot decorator in another place?

#

(also, just a little nitpick but for the level_up function there's no point in defining message and message.author because author is an attribute of message, so you can just pass message and still extrapolate message.author)

fickle arch
limber flume
#

thanks @primal slate

#

@primal slate

#

says self is not defined

primal slate
#

self is only within cogs, my bad

#

remove the self

limber flume
#

ok

#

@primal slate now this happens

#

File "C:\Users\xdswe\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 426, in on_message
await level_up(users, message.author, message)
File "bot.py", line 451, in level_up
function()
NameError: name 'function' is not defined

#

oh i did that

#

nvm

primal slate
#

lmao

limber flume
#

i was trying something lmao

#

it worKS

primal slate
#

np ๐Ÿ˜Š

limber flume
#

u make me have best day

still merlin
#

In discord.js: Is there a remove NSFW by any chance as ik there is setNSFW but i tried removeNSFW and it dosn't exist

earnest phoenix
#

you can simply use true or false for that

still merlin
#

oh, so if i go .setNSFW false would that remove NSFW from a existing nsfw chat?

earnest phoenix
#

yep

still merlin
#

ok tysm

earnest phoenix
#

if the docs are correct tho GWowoHehe

still merlin
#

it works tysm!

earnest phoenix
#

np GWgoaMonikaSmug

astral yoke
#

if im using quick.db (yes ik its trash dont bring it up) why is my friend and i recieving this error

#

(node:29852) UnhandledPromiseRejectionWarning: SqliteError: file is not a database

earnest phoenix
#

@astral yoke delete json.sqlite idk why when you delete it, its fixing. (your friend's and your datas are there, so be careful about deleting)

astral yoke
#

ty

fleet mason
#

Hey can someone help with with extracting the invite link code with regex?
like after the discord gg and when it comes /<code> eg => "/dsadsa" But the message can be like

www invite gg/dasda hello plz click
digital ibex
#

@fleet mason u can split it, its not regex but its more simpler

fleet mason
#

yea, could work and i would have to split / and " "

astral yoke
#

we deleted it then reinstalled quick.db and same error @earnest phoenix

digital ibex
#

wut

fleet mason
#

tf was that?

digital ibex
#

ffs

#

if u wanna use regex imma try and find a way, otherwise its just 'discord.gg not a discord link'.split('/')[1]

#

there

earnest phoenix
#

@astral yoke idk then :3

fleet mason
#

XD

digital ibex
#

@fleet mason u wanna use regex or ^^?

fleet mason
#

gotta love the bots

#

imma try that, keeping it simple is the best tbh

digital ibex
#

ye

fleet mason
#

i can just use regex to test before then do that

digital ibex
#

wait @fleet mason

#

r u gonna need some regex in it

#

uhhhh

#

2 secs

still merlin
#

can someone help me please?

digital ibex
#

we can't help much as we can't see the lines

#

what line is 410

fleet mason
#

Oh i do

still merlin
dreamy tide
digital ibex
#

ok @fleet mason idk lol

#

amazrisf, change line 410 to }});

still merlin
#

ok ty

fleet mason
#

I got it to work

#
    let invite = (msg.content).split("/")[3];
    invite = invite.split(" ")[0];```
#

boom

digital ibex
#

nice

still merlin
digital ibex
#

what error r u getting

robust moth
#

@still merlin )})}}) put it in end

digital ibex
#

wh

coral stirrup
#

what the hell have you done how can it look like that

quartz kindle
#

if you properly indent your code, you wont have problems like that lol

white anvil
#

magic trick: right click -> format document

coral stirrup
#

Hold up that exists

white anvil
#

yes it does

quartz kindle
#

in vsc yes

#

idk if hes using vsc, from the looks of it, it seems hes using sublime

coral stirrup
#

Well im only using vsc for about a week now but how have i not noticed

white anvil
#

it took me way longer than a week trust me

coral stirrup
#

nah thats vsc

white anvil
#

i was relying on eslint for too long

quartz kindle
#

i never got eslint to work, it always screams at me that some dependency or config file is missing

coral stirrup
#

im killing myself, i always went to beautifer io LMAO

nocturne dagger
#

How would I add a cooldown pre guild in Discord.JS i have done some searching online and couldn't find anything.

Example(User runs a command in a guild. Another user cannot run the same command for a certain amount of time in the same guild.)

white anvil
#

create new map

#

key is guild id, value is command+timestamp

turbid bough
#

a double map

white anvil
#

check current time against the timestamp for the command

#

wait nvm yea it would probably have to be a doubled up map

turbid bough
#

is for users, but you can definetly apply the same way on guilds

nocturne dagger
#

Ok, thanks. I didnt see that when I was looking.

turbid bough
nocturne dagger
#

yep

low bolt
#

There is a problem in Discord now?

I'm trying to get users from a message reaction, here is my code:
D.JS Version: v11.6.4

const channel = message.guild.channels.get("673268507999207479");
const msg = channel.messages.get("711062341097357422");
const reaction = msg.reactions.find(r => r.emoji.name === ":tada:");

reaction.users.array() // Output: []
reaction.users.size // Output: 0
reaction.users.length // Output: undefined
reaction.count // Output: 23 (23 reacted)
summer torrent
#

log reaction.users to console

low bolt
#

Collection [Map] {}

turbid bough
#

can you try fetch(), so it can get all the users?

#

oh wait you use 11

pale vessel
#

upgrade

turbid bough
#

.fetchUsers();

low bolt
#

upgrade
@pale vessel soon I will. It is problem because of v11?

pale vessel
#

no because v11 will stop working soon

low bolt
#

thanks

earnest phoenix
#

client.ws.ping have fun

#

Little help here please? I am trying to get all the files in the parts folder into an array. The array is formed but parts.length somehow is undefined.

#

getting a ping is not that hard

#

so basically client.ws.ping returns the ping to discord from your client

#

you can implement that to display delay between recieving and sending

turbid bough
plucky obsidian
#

-]

fickle arch
#

can someone help me with klasa i got error saying my "exported structure is not a class"

turbid bough
#

thats alot of random info you sent there

fickle arch
#

the class fixed.

sudden geyser
#

What is music

fickle arch
#

what.

turbid bough
#

what is music

fickle arch
turbid bough
sudden geyser
#

Are you sure msg.guild.music is a property.

fickle arch
#

only msg.guild.

pale vessel
#

then

fickle arch
#

oh wait.

quartz kindle
#

how do you define your queue?

earnest phoenix
#

How do I check an arrayโ€™s length if array.length doesnโ€™t work? (JavaScript)

turbid bough
#

you can't

quartz kindle
#

array.length does work

turbid bough
#

unless its a collection

#

it is count

earnest phoenix
#

it doesnโ€™t for me sometimes

mossy vine
#

wdym if array.length doesnt work are you sure its an array lmfao

quartz kindle
#

then you're doing something wrong

earnest phoenix
#

parts.length returns undefined

turbid bough
#

i cant see shit

fickle arch
turbid bough
#

you mean jsfiles.length?

quartz kindle
#

@fickle arch you define guild.music somewhere, right?

earnest phoenix
#

neither jsfile.length or parts.length work

#

i also did Array.isArray(parts) and its a true

fickle arch
#

i guess so

quartz kindle
#

where do you define guild.music?

turbid bough
#

he does not define it anywhere i bet

fickle arch
pale vessel
#

???

turbid bough
#

still not defining

#

where do you do msg.guild.music = music?

sudden geyser
#

@earnest phoenix when you console.log(parts, part, indexn), what does it say?

quartz kindle
#

@earnest phoenix an array length cannot ever be smaller than zero, so no point checking if its smaller than 0
you're multiplying something by array.length, which if zero, will return 0, and if 0, the index 0 will be undefined anyway

earnest phoenix
#

@sudden geyser ["Zeta", "0โ€]

fickle arch
#

i think i didn't define the msg.guild.music = music yet.

quartz kindle
#

then of course anything under guild.music will throw an error

fickle arch
#

i need to adding it above it ?

copper cradle
#

it's big brain time

turbid bough
#

big copy time

earnest phoenix
#

msg.guild.music = {playing: true, ...whatever properties here} @fickle arch

#

maybe try that?

turbid bough
#

uuh, you trying to break something?

#

we have no idea what that could do to the bot

quartz kindle
#

@fickle arch if guild.music doesnt exist, guild.music.whatever will throw an error, because guild.music doesnt exist, and you cannot get whatever from something that doesnt exist

earnest phoenix
fickle arch
#

i already define it as const { music } = msg.guild.music = music but now it shown error about "Cannot access 'music' before initialization"

turbid bough
#

no u dont

quartz kindle
#

because you're trying to access it

turbid bough
#

there is no such thing as msg.guild.music in the normal docs, unless you are assigning it before run(msg)

#

in the command handler for example

quartz kindle
#

also { music } there makes no sense

#

because doing {music} = guild.music is exactly the same as doing music = guild.music.music

fickle arch
#

let me read the docs i'm kinda confused because my friend told me about this.

turbid bough
#

did your friend tell you to "copy this code"?

fickle arch
#

no he suggest me about the code.

turbid bough
#

isnt that the same?

#

is that the only file you only deal with music?

#

what have you added on startsWith?

#

You said your command responds to any prefix? then it would be something wrong with your prefix detection

#

sure, just send it in this channel

quartz kindle
#

you never check if the message starts with the prefix

turbid bough
#

message.content.startsWith(config.prefix)

quartz kindle
turbid bough
#

where you think it would be appropriate

quartz kindle
#

did you write the rest of your code, or did you just copy it?

#

then it should be easy to find out

turbid bough
#

did you write without reading a guide?

quartz kindle
#

just think like this

turbid bough
quartz kindle
#

if message starts with prefix, continue the command, else stop the command and return

#

no, in your message event

neat ingot
#

if you read a guide, and used the exact code from the guide, then the answer was 'yes' ~ you did copy the code.

quartz kindle
#

btw

#

the guide literally shows you how to do it

#

guess what this line does

turbid bough
#

idk how he copied it wrong either

quartz kindle
hollow basin
#

Does anyone know how to make bot commands case insensitive with discord.py 0.16.12 ?

naive mantle
#

can someone tell me how to install discord.js again i forgot

steel drum
#

you could try lower()

naive mantle
#

i have node installed

steel drum
#

@naive mantle npm i discord.js

naive mantle
#

i wanna install version 11.0.4

steel drum
#

oh

hollow basin
#

@steel drum I just don't know where to put

naive mantle
#

also my node keeps giving me error messages when i download it

#

"bundleDependencies": false,

#

Array of package names that will be bundled when publishing the package.

Incorrect type. Expected "array".

steel drum
#

@hollow basin when you're checking to see if the command exists

#

you could throw a (lower)

#

there

naive mantle
#

someone help

steel drum
#

try placing an empty array?

naive mantle
#

i uh

#

forgot

#

its been a while-

steel drum
#

LOL we all have brainfarts

#

ive nvr ran into this problem but just basedo n the error type and whats there

naive mantle
#

its been like months and i still only knew basics lmaoo

steel drum
#

i think a [] should fix the problem

naive mantle
#

ok

steel drum
#

id try googling around though

quartz kindle
#

which version of node did you install?

#

do node --version

naive mantle
#

omg hi tim

#

i remember you

steel drum
#

hes active here

quartz kindle
#

lol hi

naive mantle
#

"bundleDependencies": ["false"],

#

its not giving an errror

#

also i just it

#

npm install

#

wait

#

i said

#

npm i node.js

#

i dont know the version

quartz kindle
#

node --version

naive mantle
#

ok

#

v13.11.0

quartz kindle
#

ok

naive mantle
#

i wanna install discord js version 11.0.4

quartz kindle
#

and you want to install discord.js 11.0.4? why?

naive mantle
#

because a lot of the commands that i remember and that i was taught dont work in v12

#

or whatever

#

version

#

we are on

quartz kindle
#

discord.js v11 will stop working in october

naive mantle
#

heck

#

ok how do i install the latest

#

npm i discord.js@latest?

quartz kindle
#

npm install discord.js

naive mantle
#

ok

sudden geyser
#

When in October?

naive mantle
#

ty

#

i feel like i should have more files

quartz kindle
#

it will stop working when discord makes intents mandatory, and afaik they said they would make them mandatory when they make verification mandatory

naive mantle
#

i only have 3

quartz kindle
#

but idk what they will actually do

naive mantle
#

index.js package-lock.json and node_modules

steel drum
#

id recommend setting up intents while developing your bot

naive mantle
#

is it just those three? or

steel drum
#

those are the only ones you need

naive mantle
#

ok

#

i know that

#

command files and stuff

steel drum
#

but its generally accepted to break your code up among different files

#

for example, i have all my commands placed in a plugins folder so its much more modular and i have alot of globally used functions in a tools.js folder

naive mantle
#

is there a way to look at your copy history

#

like all the things you previously copied

#

or smthn

steel drum
#

and a database.js folder for communicating with my database

#

not sure, thats something you should google

naive mantle
#

oh

#

you press windows button + v

#

and it shows your clip board

astral yoke
#

so i have this code right ```const { Utils } = require("erela.js");
const { RichEmbed } = require("discord.js");
var servers = {};
const ytdl = require("ytdl-core");
module.exports = {
config: {
name: "play",
description: "play a song",
aliases: ["p", "pplay"]
},
run: async (bot, message, args) => {
let premium = bot.db.get(premium_${message.guild.id})
if(!premium) return message.reply("sorry! This server doesn't own premium! Buy it today!")
if(premium) {
function play(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(
ytdl(server.queue[0], { filter: "audioonly" })
);
server.queue.shift();
server.dispatcher.on("end", function() {
if (server.queue[0]) {
play(connection, message);
} else {
connection.disconnect();
}
});
if (!args[0]) return message.reply("sorry. I need a link!")

if (!message.member.voiceChannel) return message.reply("join a voice channel!")
if (!servers[message.guild.id])
  servers[message.guild.id] = {
    queue: []
  };
var server = servers[message.guild.id];
server.queue.push(args[0]);
if (!message.guild.voiceConnection)
  message.member.voiceChannel.join().then(function(connection) {
    play(connection, message);
    let embed = new RichEmbed()
    .setColor('RED')
    .setDescription(`๐ŸŽถ Now playing ${args[0]}.`)
    .setFooter(bot.user.username, bot.user.displayAvatarURL)
    .setThumbnail(bot.user.displayAvatarURL)
  });
}

}

}
}

#

anyone know why

#

oh

#

it kinda dosent send the embed

#

yeah im a dumbass

sudden geyser
#

did you ever call play()

steel drum
#

@astral yoke

    if(!premium) return message.reply("sorry! This server doesn't own premium! Buy it today!")
    if(premium) {
#

this is kind of repetitive

#

if the server isn't premium, the function will exit because of the return keyword

astral yoke
#

I see

#

actually

#

even though I sent the embed

#

It dosent work

digital ibex
#

hi

pale vessel
#

yo

vivid ravine
#

how can i do big letters

#

when i add the bot

pale vessel
#

make them big

vivid ravine
#

how

pale vessel
#

please explain it again

#

because i can't quite catch that lol

digital ibex
#

how can i create something like, {+role:role id} and it'll add a role to a user, idk if i'm making sense, so i like, {+role:123456789} and it adds that role

pale vessel
#

why not the traditional way of adding roles? (a method)

#

you can make a function for that but it would be pointless is it not?

vivid ravine
#

i am typing the description to add my bot

#

and i want large letters

#

but idk how to do it

pale vessel
#

use capitalized letters or toUpperCase()

quartz kindle
#

you mean your bot description in top.gg?

#

look into css font-size

digital ibex
#

well, yeah. although i'm confused on something, so, i don't want to use only the ids, so i can also do {+role:@role}, {+role:name-name} and so on, and i'm gonna need a role resolver, which isn't hard. my one is message.channel.guild.roles.find((e) => e.name === args[whatever]

#

and with a cusotom command, when creating it its something like

#

;;cc create command-name command-response and anywhere in the command-response they can have it

#

so, idk which args its gonna be

#

which is the bit i'm very confused about

pale vessel
#

or you mean headers? use # for markdown and <h(1-6)> for html

quartz kindle
#

you mean you want users to be able to add a custom command and have the custom command add roles?

digital ibex
#

yeah, if they want to add that

pale vessel
#

get the id from the object

digital ibex
#

i don't think the isue is the me giving the role, its just idk which args i'm meant to look for the role

quartz kindle
#

i think the easiest way would be to define a bunch of placeholders

digital ibex
#

they can do ;;cc create command this is a test command which will giv u verified role, {+role:verified} or they can do ;;cc create command {+role:verified} this is a test command which will giv u verified role

#

oh

neat ingot
#

i really would avoid giving users the ability to add their own code to my bot ~ without first adding severe restrictions and limitations on the ccode that can be used.

quartz kindle
#

for example ;;cc create addrole %ADDROLEFROMINPUT%

#

and you can simply define a bunch of those placeholders as building blocks for several functions

digital ibex
#

i'm not giving users the ability to add their own code to my bot btw

#

yeah

#

is there an easier way to do it without hardcoding it?

#

cuz my role resolver is kinda big and its just gonna get a lot spammy

quartz kindle
#

there are tons of ways you can come up with

#

why is it big?

digital ibex
#

looks for role name, id, name, names includes & its lower case

#

its not that big, only like, 4 or 5 lines

quartz kindle
#

you can make all of that into a one-liner

neat ingot
#

and that takes more than 10 lines?

#

lol

digital ibex
#

wdym?

#

how

pale vessel
#

||

digital ibex
#

yeah

#

thats what i do

#

lol, but the prettier extension i use makes it go onto a new line

digital seal
#

i need help

digital ibex
#

it makes my code looks nice, thats y i use it

pale vessel
#

what do you need help with

quartz kindle
#

guild.roles.get(arg) || guild.roles.find(role => role.name.toLowerCase() === arg.toLowerCase() || role.name.toLowerCase().includes(arg.toLowerCase()))

digital ibex
#

OH

digital seal
#

@pale vessel

pale vessel
#

go to their support server

digital seal
#

ุŸ

#

?

#

where

digital ibex
#

I never knew i can do args instead of args[4] or something like that, i was thinking of something like js const role = guild.roles.find((e) => e.name === args[2] || guild.roles.find((e) => e.name === args[3] || guild.roles.find((e) => e.name === args[4] || guild.roles.find((e) => e.name === args[5] || guild.roles.find((e) => e.name === args[6] and so on

#

i'm dumb lol

pale vessel
#

click the support server button on their topgg page

digital ibex
#

thank u tim

pale vessel
#

that looks bad lmao

digital ibex
#

yeah

quartz kindle
#

@digital ibex i mean

#

if you have a bunch of different args

#

then, no you cant check them all at once like that

#

you need to check which of the args is supposed to be the role

#

and you need your command builder to identify that

digital ibex
#

oh

#

thats where i was getting a bit confused ๐Ÿคฆโ€โ™‚๏ธ

#

would i need to use regex?

quartz kindle
#

let the user define the command like this ;;cc commandname %datatype% %datatype% %datatype% for example, then resolve those data types to their position

sudden geyser
#

no

quartz kindle
#

if datatype is let say roleinput then assign that arg number to your role resolver

#

if data type is a channel input, assing that arg number to a channel resolver

neat ingot
#

lol, dont think your supposed to try promote your bot here ๐Ÿ˜„

quartz kindle
#

and so on

digital ibex
#

oh

quartz kindle
#

basically, what you're trying to do is quite complex

#

but there are a lot of ways you can accomplish something like that

digital ibex
#

i'm kinda just thinking of creating a dashboard for my bot tbh

#

i don't want to tho

neat ingot
#

wth for some reason my cronjob didnt automatically renew my ssl ๐Ÿ˜ข

digital ibex
#

it would make these kind of things a lot easier :((

#

anyways, i'm going to try that out for like

#

the next couple of hours and see where i get to

#

thanks again tim

quartz kindle
#

good luck

neat ingot
#

fml, and now my embeds arent showing the images from my site cause previoiusly the ssl was 'insecure' (out of date) :/

quartz kindle
#

didnt you get an email about it?

amber fractal
#

do you use certbot?

neat ingot
#

yea i got an email saying it was due for renewal like last week, but not one saying it had expired. i didnt renew manually cause cronjob shoulda did it itself

#

yea certbot

amber fractal
#

why not use certbot's auto renewal instead of a cronjob?

quartz kindle
#

if you get an email saying renewal is due, that means the autorenew failed

amber fractal
#

oh

#

were you?

neat ingot
#

my certbot runs in a docker container, the cronjob launches container is all.

quartz kindle
#

autorenew renews i think 30 days before expiring

#

they only send you emails like 1-2 weeks before expiring, it only gets there if renewal fails

neat ingot
#

interesting. idk you could just leave certbot running and it would auto renew :/

quartz kindle
#

it does autorenew, but its not always easy to setup

#

i had to change my cronjob a couple times for it to work

neat ingot
#

everything i read when setting it up suggested i had to manually renew myself, and it was best to have cron do it for me ๐Ÿ˜›

#

like, cron launches the certbot container, which only renews the ssl and then dies for another few weeks

quartz kindle
#

i dont use containers so idk how those are supposed to be setup

neat ingot
#

tbh its probably more hasstle than its worth if you already have a dedicated machine for things, but for making things easy to port to new hosts, its super useful

#

~ docker that is.

quartz kindle
#

this is my sudo crontab -e:
43 6 * * * /home/username/certbot-auto renew --nginx-ctl /usr/sbin/nginx --nginx-server-root /etc/nginx --renew-hook "systemctl reload nginx" >> /home/username/cert.log 2>&1

#

lmao

neat ingot
#

just got that pm wth?

quartz kindle
#
  • docker
#

~ docker

neat ingot
#

oh, maybe lol

quartz kindle
#

yup

#

~

neat ingot
#

๐Ÿ˜„

quartz kindle
#

responds to

#

~

#

which mod is online

neat ingot
#

that embed is so badly written

#

an dank meme?

#

ok...

vivid crescent
#

Parmesan is online

neat ingot
#

which runs a docker container for certbot

#

which runs that certbot command at launch, then turns off again.

quartz kindle
#

welp idk, never used docker before

neat ingot
#

ehh, its all good, it took 2 seconds to manually launch the container and have it renew my ssl

#

there are a number of reasons it could have failed atm tbh

#

the host its currently on is trash af

#

1core,1gb ramz. ๐Ÿ˜

#

so the machine is constantly running out of ram and crashing lol

quartz kindle
#

mine is 1c 1gb too

#

runs fine with 3 bots

neat ingot
#

i've been rewriting the bot, and the database also, and havent bothered moving it to my new host till ive finished the changes, cause database needs migrated also

#

o0 wth lol

#

almost all of my ram is taken from my 1 bot

quartz kindle
#

my bots are hyperoptimized lol

#

how many guilds?

neat ingot
#

like 80...

#

lol

quartz kindle
#

wth

neat ingot
#

83*

quartz kindle
#

1gb for 80 guilds?

neat ingot
#

idk exact lemme see

vivid crescent
#

Must be caching a lot of things

quartz kindle
#

are you using fetchAllMembers:true?

neat ingot
vivid crescent
#

Mine is 20mb with 18

neat ingot
#

atm 350 mb of ram for my bot

quartz kindle
#

ah that sounds more normal

neat ingot
#

your bot isnt using 20mb of ram

#

i mean, it might be, but its highly unlikely ๐Ÿ˜„

quartz kindle
#

if its node.js then yeah no

#

node.js by itself uses 40-50mb ram

neat ingot
#

could be calculating wrong

vivid crescent
neat ingot
#

calculating ram and processing power in node is a pain

vivid crescent
#

Using java

quartz kindle
#

ah java

#

java is more lightweight

vivid crescent
#

JDA has options to disable the cache completely which helps lol

neat ingot
#

does discord js have options to disable cache? or would i have to change to something like your lightweight d.js thing @ tim?

quartz kindle
#

there are some caches you can control

#

for example message caching can be controlled in client options

#

presences can be disabled by using intents

neat ingot
#

asteroids api?

#

is that the space positioining thing?

#

or a game?

#

lol

quartz kindle
#

yeah its for the positioning thing

neat ingot
#

what do you use for a database?

quartz kindle
#

sqlite

neat ingot
#

its on the same machine?

quartz kindle
#

each bot has its own sqlite instance

neat ingot
#

interesting

quartz kindle
#

on the same machine yes

vivid crescent
#

Like schema? Or full instance

quartz kindle
#

full instance

neat ingot
#

hell, my mongodb container uses almost as much ram as your entire bot when its been sitting idle for a bit ๐Ÿ˜„

quartz kindle
#

isnt mongodb configured to use like a minimum of half the machine's ram by default?

grizzled raven
#

what

#

cant be letting mongo use 8gb of ram

#

oh wait do you mean for cache?

neat ingot
#

mine has never used that much lol

#

yea im thinking the ram must be from some sort of cacheing

quartz kindle
neat ingot
#

ooft

grizzled raven
#

so let say 20gb of ram, it will use max 11gb

#

huh

neat ingot
#

12

#

that is excessive af

#

lol

#

tbf, mongo is used by some big companies running some big data

quartz kindle
#

well, mongo is designed to be a primary remote database which is supposed to be sitting by itself in a single dedicated machine

grizzled raven
#

hhhhhhh

neat ingot
#

yea thats also fair

#

but you could say that about most databases

quartz kindle
#

yes, except sqlite

neat ingot
#

flex

#

๐Ÿ˜„

quartz kindle
#

xD

grizzled raven
#

man

neat ingot
#

ive never looked much at sqlite, whats the benefits of it compared to regular mysql?

grizzled raven
#

this is why i would like to stick with sqlite

#

its faster as its on your hard drive

quartz kindle
#

sqlite is designed to be used on a per-app basis, built into the app's process

#

there is no connection, no remote, no server

neat ingot
#

o0

#

interesting

#

so its basically just a module for writing to and getting data from files?

grizzled raven
#

arent all db's like that?

quartz kindle
#

yes, a stupidly optimized one

grizzled raven
#

or am i be bad

quartz kindle
#

pretty much most dbs are like that

#

its all about indexes and caching hot data in memory

neat ingot
#

yea all db's do that in some way, but how they do it is what makes the difference

quartz kindle
#

which they have been perfecting for decades

grizzled raven
#

nah i still be bad

neat ingot
#

tbh sqlite is probably a better option for a discord bot

quartz kindle
#

yes, unless your bot grows into multi-machine scale

grizzled raven
#

i wanna use mongo but im not cool enough to understand anything like dbs on different servers so lmao

neat ingot
#

im just so used to using mongo now so i'll be sticking with it ๐Ÿ˜„

quartz kindle
#

you can limit its max cache size

neat ingot
#

tbh im probably still a total mongo nub ๐Ÿ˜„

quartz kindle
neat ingot
#

ahh nice ๐Ÿ˜„

grizzled raven
#

i know but i feel like im not doing things the optimal way

neat ingot
#

ty โค๏ธ

grizzled raven
#

but whatever i'll just

neat ingot
#

i was planning to look at the wired tiger stuff when im moving to my new host as whenever i build my container is gives me warnings about the wired tiger engine and w.e

quartz kindle
#

fuck its already 3am

grizzled raven
#

yeah i'll just try it out, cant be worse than what i currently do

#

oh wait it is