#development

1 messages Β· Page 928 of 1

tight plinth
#

I heard one time about a ode module that can do that, but I can't remember which one

lyric mountain
#

just do the above

halcyon ember
#

im on discordjs and I want a way where a user can do a command, and it saves the info thats after the command. Right now I have it slice off the command part, but i want it to put in a json like

"000id": {
  "ric": xxx
  "btc": xxx
}
#

how can I do that?

quartz kindle
#

show example of the command

earnest phoenix
#

code:

let user = bot.users.get(args[0]);
let fetched = db.fetch(`blacklist_${message.guild.id}_${user.id}`)

error:

Cannot read property 'id' of undefined
quartz kindle
#

in v12 its .cache.get

earnest phoenix
#

i'm still in v11

quartz kindle
#

then the user was not found

earnest phoenix
#

but if it isn't found it should send a message

quartz kindle
#

you dont have any code that checks for that

earnest phoenix
#
if(!user) {
      
      const nulgasesc = new Discord.RichEmbed()
      .setDescription(":no_entry_sign: **Utilizatorul nu este valid!**");
      message.channel.send(nulgasesc);
      
    }
#

i have, but i didn't send it

quartz kindle
#

that code has to be before the fetch code

earnest phoenix
#

it is

#
const db = require("quick.db");
const Discord = require("discord.js");
const config = require("../botconfig.json");
exports.run = async(bot, message, args) => {
  if(message.member.hasPermission("ADMINISTRATOR")) {
    let user = message.mentions.users.first();
    if(!user) {
      
      const nulgasesc = new Discord.RichEmbed()
      .setDescription(":no_entry_sign: **Utilizatorul nu este valid!**");
      message.channel.send(nulgasesc);
      
    }
    
    let fetched = db.fetch(`blacklist_${message.guild.id}_${user.id}`)
    
    if(!fetched) {
      db.set(`blacklist_${message.guild.id}_${user.id}`, true)
      const aprimit = new Discord.RichEmbed()
      .setDescription(":white_check_mark: **Utilizatorul a primit blacklist!**");
      message.channel.send(aprimit);
    }else{ 
      const edeja = new Discord.RichEmbed()
      .setDescription(":no_entry_sign: **Userul este deja pe blacklist!**");
      message.channel.send(edeja);
      
    }
  }else{
    const nuaiacces = new Discord.RichEmbed()
    .setDescription(":no_entry_sign: **Nu ai acces la aceasta comanda!**");
    message.channel.send(nuaiacces);
  }
}

module.exports.help = {
  name: "blacklist"
}


quartz kindle
#

show full code

earnest phoenix
#

this is the full code

quartz kindle
#

that code doesnt even have bot.users.get()

earnest phoenix
#

i tried to change it

#

with message.mentions.users.first()

quartz kindle
#

so your current code is now this?

earnest phoenix
#

yes

quartz kindle
#

looks correct

earnest phoenix
#

i still got the error when i run /blacklist

quartz kindle
#

did you save the file and restart your bot?

earnest phoenix
#

yes

#

it is hosted on glitch, autosave

quartz kindle
#

add a return in your if(!user)

earnest phoenix
#

ok

#

oh, no error now, ty

indigo cloud
#

how do i make my bot run 24/7?

quartz kindle
#

keep the program running

earnest phoenix
#

How to make my bot check everytime if a user is in blacklist ban him?

quartz kindle
#

check the blacklist every time they use a command

#

or on every memberAdd event

mossy vine
#

so im running Array.filter(async d => blablabla) and want to execute something afterwards. is there any way to get rid of this race condition where whatever is after gets called before the filter finishes?

quartz kindle
#

await Promise.all(array.filter())

#

or Promise.all().then()

#

actually no

#

since the filter wont return any of its logic immediately, it wont really filter anything

earnest phoenix
#

@quartz kindle so i need to put in MemberAdd event ```db.fetch(`blacklist_{message.guild.id}_{user.id})```` an then what?

quartz kindle
#

so (await Promise.all(array.map(async item => {bla; return false or null if you want it filtered out}))).filter(Boolean)

mossy vine
#

problem is that im already chaining other stuff on before the filter

#
(await client.getMessages(message.channel_id, 10)).reduce((accumulator, curr) => {
            if (
                curr.author.username !== message.author.username &&
                !curr.author.bot &&
                !accumulator.some(item => curr.author.id === item.i)
            )
                accumulator.push({ u: curr.author.username, i: curr.author.id })
            return accumulator
        }, []).filter(async d => {
            console.log('mm filtering')
            const member = await client.getMember(message.guild_id, d.i)
            console.log(member)
            if (member.roles.includes('710208578413133834'))
                return false
            client.addGuildMemberRole(message.guild_id, d.i, '710208578413133834')
            return true
        })
        console.log('sending msg')```
#

sending msg gets logged before member and that is uncool

quartz kindle
#

change it to .map(), then use Promise.all() on it

mossy vine
#

change what to .map

quartz kindle
#

the filter

mossy vine
#

but i actually want to filter stuff out there

#

can i do that with map

quartz kindle
#

let me test something

#

yeah

#

as i thought

#

you cant use async functions with filter

#

because the async function will always return a promise, which is truthy

#

so it doesnt actually filter out anything

mossy vine
#

oh yikes

quartz kindle
#

so you have to use .map() to convert all items into a promise, then use Promise.all() on the array

#

then you can filter it out with .filter(Boolean)

#

to remove all the falsey results

mossy vine
#

but i cant do that because i need them afterwards

quartz kindle
#

why cant you?

mossy vine
#

like

#

map would overwrite the objects as promises

#

but i need the objects

quartz kindle
#

thats why you use Promise.all()

mossy vine
#

but then i still wont have the original objects, no?

quartz kindle
#

it will have whatever the map redefines them to inside the async function

mossy vine
#

but instead of async t => t i have async original => somethingcompletelydifferent

#

wait

#

member objects have the username and id too

#

okay nevermind i can do that thanks lmao

quartz kindle
#

ah i understand what you're saying

#

yes the only way to filter the original array without modifying it would be a for loop

#

and rebuilding the array in another variable

mossy vine
#

yeah but i realized i can just use your approach

#

as a member object has the properties i need to use

#

and i can just grab them from that

quartz kindle
#

πŸ‘

mossy vine
#

thanks

earnest phoenix
#

code:

bot.on("guildMemberAdd", (member) => { 
  
  let user = member.mentions.users.first()
  
  let blacklisted = db.get(`blacklist_${member.guild.id}_${user.id}`)
  
  if(blacklisted === null) {
    return;
  }
  
  let bReason = "blacklisted";
  
  member.guild(blacklisted).ban(bReason);

Is this right to check if somenone join the server and is on blacklist get banned?

#

@quartz kindle

quartz kindle
#

no

earnest phoenix
#

sorry for mention

#

but ? what is wrong ?

quartz kindle
#

when a member joins, you get a member object

#

there is no member.mentions

#

its not a message

#

instead, you can directly access their id

earnest phoenix
#

uhm, how ? πŸ˜…

quartz kindle
#

members have ids

earnest phoenix
#

ik this

#

i need to check if an user is on blacklist, but how ? ( i'm new at discord.js, sorry for dumb questions )

quartz kindle
#

members have ids

earnest phoenix
quartz kindle
earnest phoenix
#

ty

quartz kindle
#

its the same thing

#

member ids and user ids are the same

earnest phoenix
#

Yes, ty

mossy vine
#

@quartz kindle does async also not work in reduce?

amber fractal
#

tfw member.mentions pepehands

quartz kindle
#

probably not

earnest phoenix
#

@amber fractal don't judge me =))

quartz kindle
#

lmao

mossy vine
amber fractal
#

I mean it's nice to have documentation that explains it all in a really clear way

quartz kindle
#

wait maybe...

#

it does work

#

you just have to always await the accumulator

mossy vine
#

yeah ok ill just do it with your Promise.all lmao

quartz kindle
#

fking discord wont let me upload imgs now

#

and now it does it twice

#

10/10

halcyon ember
#

@quartz kindlethe command would look something like ricaddress <input>

amber fractal
#

lmao tim

quartz kindle
#

how does the input look like

mossy vine
#

@quartz kindle okay i need more help lmao i have no idea how to do this
so first i have an array of messages
then i need to filter out based on criteria and get all unique author objects
then fetch a member from the author id and construct an array based on whether or not the member has a certain role (if doesnt, add it but that doesnt need to be awaited)

quartz kindle
#

is the criteria async?

mossy vine
#

no

quartz kindle
#

i'd construct an object

mossy vine
#

okay now im just getting undefined on the Promise.all result lmao

quartz kindle
#
let obj = {}
for(let message of array) {
  if(!obj[message.author.id]) { // and whatever other criteria
      let member = await guild.members.fetch(message.author.id)
      if(bla) { // member has role
          obj[message.author.id] = message
      }
  }
}
mossy vine
#

hmm yes i suppose that is also a solution

quartz kindle
#

you dont need to use promise all if getMessages already returns the messages

#

unless it returns an array of 10 promises for some reason

mossy vine
#

im not trying to use promise all on getMessages

#

but on getMember

quartz kindle
#

ah lmao

mossy vine
#

(since for some 200 iq reason, messages from getMessages dont have member objects attached wtf discord)

quartz kindle
#

remove the brackets on the async map

#

or return client.getMember

mossy vine
#

alright its working, thank you

narrow kettle
#

[c], anyone have any idea why it crushes at fgets(the end)?

#include <stdio.h>
#include <stdlib.h>

#define CHAR_SIZE 200

typedef struct list list;

struct list {
    char* name;
    char** reasons;
    int num;
};

void print(list list);

int main(void)
{
    char problem[CHAR_SIZE] = { 0 };
    list pro = {"List PRO", 0, 0};
    list con = {"List CON", 0, 0 };
    int option = 0;
    while (option != 4)
    {
        printf("Choose Option: \n1 - Add PRO reason \n2 - Add CON reason \n3 - Print reasons \n4 - Exit\n");
        scanf("%d", &option);
        getchar();

        switch (option)
        {
            case(1):
                pro.num++;
                pro.reasons = (char**)realloc(pro.reasons, (pro.num) * sizeof(char*));
                printf("please enter a reason: ");
                pro.reasons[pro.num - 1] = (char*)malloc(CHAR_SIZE * sizeof(char));
                fgets(*pro.reasons[pro.num - 1], CHAR_SIZE, stdin);
                strtok(*pro.reasons[pro.num - 1], "\n");
                break;
near ether
#

hey, im logging debug info bc of some issues im having, what does this mean? "429 hit on route /guilds/704452210813304925"

mossy vine
#

you got ratelimited

delicate zephyr
#

ratelimited

near ether
#

why is my bot being rate limited? its only launching and i have all commands disabled so theres no activity

#

is there some issue with that guild or is my bot spamming something?

quartz kindle
#

getting rate limited on a guilds route means its something related to those rest endpoints

#

possibly fetching a member, fetching guild information, roles, emojis...

#

or doing stuff like updating roles

crisp talon
#

guys how do I update node.js? I know that I should do it in node.js.org but I host my bot on glitch.com and not on my computer, so I should update it via command I think

quartz kindle
#

@crisp talon in your package.json there is an "engines" field

#

you change the version there, and glitch will do the rest

near ether
#

ahhhhh ok, i am retrieving a custom emoji on a shard and sending the info to all shards

quartz kindle
#

how are you sending the info?

crisp talon
#

@crisp talon in your package.json there is an "engines" field
@quartz kindle uhm there isn't

quartz kindle
#

if there isnt, create one yourself

#

like this:

#
"dependencies": {
  ...
  ...
  ...
 },
"engines": {
  "node":"12.x"
}
near ether
#

its like halfway-ish down the page

crisp talon
#

@quartz kindle and if I do this it automatically updates node?

#

uh so before updating node I got the error: fields.flat is not a function, but now I get TypeError: currentLevel.check is not a function

#

how can I fix it?

quartz kindle
#

@near ether i see what that code is doing, however there is a better way to do it

#

one that doesnt require fetching the entire guild

near ether
#

will you teach me πŸ™

quartz kindle
#

try this

#

(untested)

#

also, you're on v12 right?

near ether
#

yep

quartz kindle
#
client.shard.broadcastEval(`(${findEmoji}).call(this, '${args[0]}')`)
    .then(emojiArray => {
        const foundEmoji = emojiArray.find(emoji => emoji);
        if (!foundEmoji) return message.reply('I could not find such an emoji.');
        let fullEmoji = client.guilds.add({id:foundEmoji.guild_id}, false).emojis.add(foundEmoji,false)
        // use fullEmoji
});
#

following the code from that guide

#

this will construct a guild partial with only the guild id and nothing else, instead of getting a full guild from the api

near ether
#

awesome ty!!

#

also theres one more thing im curious about

#

[WS => Shard 18] Shard did not receive any more guild packets in 15 seconds.
Unavailable guild count: 10

#

is this something i can fix?

quartz kindle
#

nope

near ether
#

ugh

#

is this an issue with the api then?

#

or discord

quartz kindle
#

yeah

#

its when guilds are offline

near ether
#

damn its preventing that shard from launching, which just ends up stopping the launch process entirely

#

it times out and then stops launching the other shards, and doesnt even try to relaunch

quartz kindle
#

it should launch anyway after 15 secods

#

not cancel the process

near ether
#

is this by default or is it an option to be enabled?

#

because when shards time out for me, they dont launch and the entire process just halts entirely

quartz kindle
#

it should be by default

#

try running the shard without using the sharding manager

#

it should turn ready after 15 seconds anyway

#

one thing you can also do

#

is increase this value

#

because the 15 second time limit gets reset for every guild that the shard receives

#

so if a guild is broken for 10 seconds but then works again, the timer will reset and give you a total waiting time of 25 seconds now

#

make the spawnTimeout like 60 seconds

golden condor
#

Hi I am tryna use discord.js Permissins like this and it keeps telling me Bitfield Invalid
Perms = 104188992 in this case. Thanks in advance!

 userPerms: function(guilds){
        const array = []
        for (const guild in guilds) {
            const perms = parseInt(guilds[guild].permissions)
            console.log(perms)
            const permissions = new Permissions(perms)
            console.log(guild)
            if(permissions.has("MANAGE_SERVER")) array.push(guilds[guild])
        }
        return array;
    }```
#

Nvm

lyric mountain
#

why not use permission objects?

golden condor
#

I found why

#

I am stupid

#

I spent 30 mins tryna solve this issue please kill me

#

why not use permission objects?
@lyric mountain Making a dashboard and discord gives me data in that format

lyric mountain
#

ah

livid swallow
#

I started making bots and am using Heroku to host them, but this seems rather expensive (I run out of free 'dynos' quickly). What would you guys suggest as a cheaper alternative?

quartz kindle
#

a vps

earnest phoenix
#

^ facts

#

i'd recommend setting up a private server with another bot sending a message every 5 minutes to a certain channel
then set up an account on WayScript and create a new application with the discord trigger
make there no output for the discord trigger and turn off Ignore Bots
then add a python step
in the requirements put whatever you need. for example:
discord.py
random_word
then paste the code in scratch.py

#

if you don't want to use a vps then this is the next best thing

quartz kindle
#

LOL

earnest phoenix
#

it's what i first used before switching mad

quartz kindle
#

what the actual fuck

earnest phoenix
#

don't ask ok

#

it works well for beginners though so

modest maple
#

the fuck

#

Ive seen people do quite the weird and wonderful shit touse a free host

#

but my god

near ether
#

i gave it a shot and all my shards launched correctly

#

thanks!

#

and one last question about some errors

#

"UnhandledPromiseRejectionWarning: Response: Internal Server Error"

#

what is screwing up here?

livid swallow
#

Well fuck you. All I asked for was suggestions and help to a legitimate question, but got trash instead. If you didn't wish to answer the question, then don't, instead of sending me garbage

earnest phoenix
#

calm down??

#

accept the fact that nothing is ever free and that you cannot use someone else's resources for free and still have them pay the electricity bills

#

@near ether nothing, internal server errors are server sided

quartz kindle
#

i mean, i answered a vps, which is a cheap and good alternative

livid swallow
#

Exactly! Which is why I asked for a CHEAP alternative - NOT FREE ALTERNATIVE

quartz kindle
#

you didnt say it had to be free

earnest phoenix
#

but... a vps is cheap

quartz kindle
#

a vps is the best cheap non-free hosting solution

earnest phoenix
#

there's ones out for like 3€

quartz kindle
#

i pay $3 a month for mine

#

33 a year actually, i get 1 month free

modest maple
#

same

#

tho the 11 month billing triggers me

quartz kindle
#

11 month billing?

#

you get billed every 11 months?w tf

white anvil
#

that is big brain

quartz kindle
#

"pay per year and get 1 month free. but we'll bill you every 11 months"

modest maple
#

ngl ive pre paid one of my servers for the next year lol

livid swallow
#

Ok, thank you for that, but by VPS do you means Microsoft Azure VPS?

modest maple
#

no

quartz kindle
#

no, i mean any vps

modest maple
#

we mean

#

a vps

white anvil
#

vps is a general term for virtual private server

quartz kindle
#

vps means Virtual Private Server, there are hundreds of companies that offer such service

#

prices typically start at 2-3 USD per month, and go up to hundreds of USD per month depending on how much memory, disk and cpu cores you want

white anvil
#

dont pay >Β£40/mo for a vps lol

#

just get a dedi at that stage

modest maple
#

yh

earnest phoenix
#

azure drained all of my student credits for simply having an account open

#

:feelssadman:

quartz kindle
#

rip

modest maple
#

i dont even bother using student credit

#

setting everything up to just burn through it in a month or less is just not wurth

quartz kindle
#

i used google's vps for a year with those $300 credits, only used about 30 before they expired lmao

earnest phoenix
#

i used to use those for minecraft servers

#

spent all of it in 3 months

quartz kindle
#

lmao rip

#

google is expensive af

earnest phoenix
#

then created a new account to get more credits, but they patched the exploit where you can reuse the same debit card over and over again

quartz kindle
#

make throwaway debit cards

#

or virtual debit cards

earnest phoenix
#

if we had those in croatia

#

i forgot the name of the service but there was one i was looking forward to using only to find out it's region locked to US

quartz kindle
#

rip

#

zdravo

earnest phoenix
#

slavic langs - you know one, you know them all (except polish what the fuck is polish)

quartz kindle
#

xD

#

i have an easier time with polish than russian

halcyon ember
#

how do i put a custom emoji in embed title

quartz kindle
#

but i like the sound of russian more

modest maple
#

you cant iirc

#

titles do not support emojis

earnest phoenix
#

^

halcyon ember
#

i swear ive seen a bot do it

quartz kindle
#

you sure it was a custom emoji?

earnest phoenix
#

you're probably confusing an author url and titles

quartz kindle
#

because you can use unicode emojis

halcyon ember
#

the x thing

quartz kindle
#

and yeah you can use author url

#

it kinda looks like a title

halcyon ember
earnest phoenix
#

discord send my message pls

halcyon ember
#

OHHH

#

whats the thing to set author image url

modest maple
#

in what lang

#

discord

halcyon ember
#

discordjs

modest maple
#

fucking send my image plz

#

smfh

halcyon ember
#

ik the images take forever to process

quartz kindle
#

embed.setAuthor?

modest maple
halcyon ember
#

yea thats the naame

#

but how the image

modest maple
#

just any url

#

or attachment

halcyon ember
#

.setAuthor('url','text')?

quartz kindle
#

wait until discord sends my image

halcyon ember
#

can i get an example

quartz kindle
#

and you'll see

halcyon ember
#

ok

quartz kindle
halcyon ember
#

OH

livid swallow
#

Oh ok. Thank you.

earnest phoenix
#

00:13

balmy knoll
#

How can i use a file in assets folder in Glitch?

true ravine
#

What kind of file?

#

And for what?

balmy knoll
#

It is a png file and i have to use it in a canvas-constructor item @true ravine

neat ingot
#

@modest maple yo, I managed to get that netdata thing running in a container and being hidden behind an nginx proxy. but it still seems to be inaccurate with the numbers its displaying. Is it possible I have to configure the settings more for number of cores i have and ram max limit and w.e?

pale vessel
#

you don't put new to require

earnest phoenix
#

^

#

you require the module and then call new on the thing you want to use from that module

neat ingot
#

or your module can return a new instance of that thing ~ less common and probably should be avoided tho

modest maple
#

ehh

#

for netdata

#

i would run it as a uncontainered processes

#

or set docker to give it everything

#

you can still hide it using firewall and route it through nginx

neat ingot
#

you think that could be why its displaying things funkily? i mean, according to all the docs it supports docker/docker-compose

modest maple
#

yeah but if your docker is limiting what it can access for itself it'll change

neat ingot
#

yea i was thinking that also

#

its as though its taking a single containers resource limits as the entire systems

#

however, considering the other approach with cadvisor/prometheus/alert managers etc had me using 7 containers ~ just for monitoring ~ compared to netdatas one... if i can configure it,. i'd rather do that πŸ˜„

rough walrus
#
const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {
    if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("You don't have enough permissions for this command!");
    let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
    if(!args[0] || args[0 === "help"]) return message.channel.send(`Usage: addrole user role`);
    if(!rMember) return message.reply("Couldn't find that user.");
    let role = args.join(" ").slice(22).toLowerCase();
    if(!role) return message.reply("Please specify a person.");
    let gRole = message.guild.roles.cache.find(r => r.name.toLowerCase() === role);
    if(!gRole) return message.reply("Couldn't find that role.");

    if(rMember.roles.cache.has(gRole.id)) return message.reply("That user has the role already.");
    await(rMember.addRole(gRole.id));

    try{
        await rMember.send(`βœ… You have were given the role ${gRole.name}!`)

    }catch(e){
        message.channel.send(`βœ… <@${rMember.id} was given the role ${gRole.name}!`)
  }
}
 module.exports.help = {
     name: "addrole"
}

i don't get terminal errors, but the bot can't find the role that iam trying to add,what's wrong?

#

ping me if you would help, thanks

silent berry
#

Hello, I am running v11.5.1 discord.js and im getting

message.content is not a function

everytime i type

#

please help

#

idk where in my code its doing this as there is no console errors.

pale vessel
#

you're trying to use message.content() instead of message.content

silent berry
#

thank you

pine bear
#

yet for me, it's message is not defined.

rough walrus
#

can anyone help me with my problem above

earnest phoenix
#

@rough walrus add debug logs

near ether
#

the "Unknown Message" error only occurs when the message is deleted and is not in cache, right?

quartz kindle
#

it occurs when editing or fetching a message that was deleted or from a guild/channel that your bot cant access

#

or reacting

earnest phoenix
#

I am working on music commands for my bot and when I use ?play (song link) it says that I am not in a voice channel even though I am. Here is my play.js file

function plya(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();
    })
}

exports.run = (client, message, args) => {
    if (args[1]) {
        message.channel.send('Please provide a link');
        return;
    }
    if (!message.member.voiceChannel) {
        message.channel.send('You must be in a voice channel')
        return;
    }
    if (!servers[message.guild.id]) sevrers[message.guild.id] = {
        queue: []
    } 
    var server = servers[message.guild.id];

    server.queue.push(args[1]);

    if (!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection) {
        AnimationPlaybackEvent(connection, message);
    })
}
acoustic thunder
#

I need some help regarding a problem. I have a function that sends a message, then reacts to its own message and does something when a user reacts to those emojis. However, sometimes (rarely), the bot does not react to its own message, or it reacts halfway then suddenly stops, and then it's just stuck there. There are no error messages or anything.

earnest phoenix
#

@acoustic thunder code

quartz kindle
#

@earnest phoenix discord.js version?

earnest phoenix
#

v12

quartz kindle
#

member.voice.channel

earnest phoenix
#

instead of member.voiceChannel?

quartz kindle
#

yes

earnest phoenix
#

ok

#

I get this error when I try to use the command

   if (!servers[message.guild.id]) sevrers[message.guild.id] = {
        queue: []
    } 
#

whoops

#

thats my code the error is that servers is not defined

neat ingot
#

lol

earnest phoenix
#

oh my god

#

im dumb lmao

acoustic thunder
#

Something like this

msg = await channel.send(embed=embed) # some embed message
await msg.add_reaction('emoji')
await msg.add_reaction('emoji')
try:
  r, u = await client.wait_for('reaction_add', check=check, timeout=120.0)
  if r.emoji == 'emoji':
    do something
  elif r.emoji == 'emoji':
    do something
except asyncio.TimeoutError:
    print(something)
earnest phoenix
#

I got a reference error that says servers is not defined, here is my code

    if (!servers[message.guild.id]) servers[message.guild.id] = {
        queue: []
    } 
neat ingot
#

according to that small piece of code, servers isnt defined. pretty sure you are defining it somewhere?>

earnest phoenix
#
function plya(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();
    })
}

exports.run = (client, message, args) => {
    if (args[1]) {
        message.channel.send('Please provide a link');
        return;
    }
    if (!message.member.voice.channel) {
        message.channel.send('You must be in a voice channel')
        return;
    }
    if (!servers[message.guild.id]) servers[message.guild.id] = {
        queue: []
    } 
    var server = servers[message.guild.id];

    server.queue.push(args[1]);

    if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
        AnimationPlaybackEvent(connection, message);
    })
}
#

this is the file

neat ingot
#

well yea servers isnt defined there

#

server is

#

not servers

#

also, side note: you should use const or let instead of var in javascript moving forward. var is old syntax standards

earnest phoenix
#

ok

neat ingot
#

const is for constants, let is for a variable that will change

amber fractal
#

well not really, it just has different scope

neat ingot
#

no, yes really.

amber fractal
#

var has use cases

neat ingot
#
const vari= 5;
vari= 3 // thros error cause const cannot be changed.```
earnest phoenix
#

i got an error when I changed it

#

I tried const and let

#

ReferenceError: Cannot access 'server' before initialization

neat ingot
#

that means your trying to use the server variable before you have defined it

#

something like javascript server.doathing(); let server = "athing";

amber fractal
neat ingot
#

no, you shouldnt be doing that.

amber fractal
#

according to who

#

you?

neat ingot
#

that is extremely poor use of scoping and defeats the entire point of scope

amber fractal
#

it's a different type of scope

#

which is the point of var

neat ingot
#

ok

#

u do u

#

ill do things properly

earnest phoenix
#

Got an error saying TypeError: Cannot read property '709397361453039718' of undefined. I used this command ?play https://www.youtube.com/watch?v=feA64wXhbjo and this is my code

function plya(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();
    })
}

exports.run = (client, message, args) => {
    if (args[1]) {
        message.channel.send('Please provide a link');
        return;
    }
    if (!message.member.voice.channel) {
        message.channel.send('You must be in a voice channel')
        return;
    }
    if (!server[message.guild.id]) servers[message.guild.id] = {
        queue: []
    } 
    var server = servers[message.guild.id];

    server.queue.push(args[1]);

    if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
        AnimationPlaybackEvent(connection, message);
    })
}
#

ill change var in a sec btw

rough walrus
#

is there a way to change status presence from "dnd" to "Do not disturb"?

neat ingot
#

@earnest phoenix, your still not defining servers anywhere, so it is undefined, so getting a message.guild.id of an undefined object wont work. what makes you think servers would be available there?

#

did you define servers anywhere?

#

in some other file out of the command or such

earnest phoenix
#

var server = servers at the top

neat ingot
#

servers doesnt exist tho

#

thats my point

#

your basically trying to get information from an object that doesnt exist

earnest phoenix
#

so change everything to just server?

neat ingot
#

like, it doesnt matter that you define server, because your trying to set server to servers[guild.id] when servers doesnt exist, thus, it will never have a guild.id property

#

no

#

take a step back

#

what are you trying to do? where did you get server or servers from?

#

like, what made you use/add that code?

earnest phoenix
#

i looked at a tutorial on youtube

neat ingot
#

and there in lies the issue.

#

did you learn from the tutorial? or copy and paste parts here and there?

earnest phoenix
#

basically just coded what I knew and took the rest from the video

neat ingot
#

ok. well the issue is that you are trying to use an object that was never defined. there should be some code somewhere that defines what servers actually is, for example:

const servers = Object.create(Object);```  (not to be copy/pasted)
#

then

#

after you have servers defined

#

there would be some code to setup a guilds defeault server configuration or options or w.e

#

then, after that ~ you can access the servers object

#

for example, 'your' code does server.queue.shift() but since servers isnt defined, the server object will not have any default data or property for 'queue' there will be no queue, nothing to shift.

earnest phoenix
#

ok

#

ill try that thanks

sick cloud
#

i have a plain dumb question, how do you make an object from a classes properties

neat ingot
#

what do you mean? and which language do you use?

digital ibex
#

hi, does anyone know why i'm getting MongoError: Cannot create field 'user' in element {users: []} error?
code: guild.updateOne({$push: {'mute.users.user.id': 'i'}})
guild is the guild in the db, and the model looks like

#
    mute: {
        role: String,
        users: [ { user: { id: String, reason: String, case: Number, mod: String, time: String } } ],
        default: []
    }
sick cloud
#

node.js, and ie

class Thing {
  constructor() {
    this.memes = 1;
  }
}

new Object(Thing) // ???
/*
  {
    memes: 1
  }
*/
neat ingot
#

ooohhh, you mean how to instantiate the class object?

#
const mythinginstance = new Thing()```
#

like that? πŸ™‚

sick cloud
#

no lmao

#

so i can get an object of the classes properties

neat ingot
#

the object is already an object with its class properties...

earnest phoenix
#

I have a client looking for different bots one of which being a subreddit feed bot pm me if you can do it

sick cloud
#

no it isn't

#

it's a class

#

i need to turn it into just an object

neat ingot
#

an instance of the object is

#
for (const key in object) {
    if (object.hasOwnProperty(key)) {
        const element = object[key];
        
    }
}```
sick cloud
#

sounds cool

#

i also just worked out another way

neat ingot
#

do share?

sick cloud
#
    toJSON() {
        return JSON.parse(JSON.stringify(this));
    }

😎

#

it looks odd but works

neat ingot
#

not even gonna waste my time here tonight tbh

#

hf guys πŸ˜—

amber fractal
#

what the fuck?

#

I'm confused... if you're going to json, why would you be parsing

#

and why would you undo a stringify

#

it'll literally return this

#

they're inverse functions

quartz kindle
#

thats useful to properly deep-clone an object

amber fractal
#

then the function name should be clone shouldn't it?

quartz kindle
#

yup, probably

white anvil
#

this function will have issues if you have circular structures

sick cloud
#

i want to take the class and just get an object of properties

#

then i can store it in the db

white anvil
#

without instantiating?

#

this is annoying to do with raw js because nothing is typed

#

no property is guaranteed

quartz kindle
#

i prefer it that way tbh

#

forces you to have more control

white anvil
#

its not proper oop

#

i dont see how u can ever have more control without any sort of regulation on class objects

quartz kindle
#

with control i mean doing your own type checking and validation

sick cloud
#

^

white anvil
#

oh

#

lol

#

this is where typescript is most useful

quartz kindle
#

i have enough headache already trying to figure out how to configure webpack

#

i dont wanna have to configure ts building too, let alone learn it

white anvil
#

typescript is not even that much harder

#

but dynamic typing as a whole does suck ngl

quartz kindle
#

i like it

#

Β―_(ツ)_/Β―

amber fractal
#

I like non typed langs better than typed langs as well

white anvil
#

non typed langs arent even programming languages

#

they are scripting languages

quartz kindle
#

starting lang wars again? smh

white anvil
#

its not even a debatable idea

#

im not tryna start an argument but u dont get any compiled language that isnt typed

sick cloud
amber fractal
#

who fucking cares...?

sick cloud
#

that can also save missing values

quartz kindle
#

even html is considered a programming language by wikipedia and by many experts

amber fractal
#

you can do basically the same shit in every lang, programming, scripting, etc

white anvil
#

depends how far u wanna go with the term

#

id call it a markup language because its kinda in the name

#

but then again im not a frontend dev

#

name is just semantic

quartz kindle
#

they all do a certain degree of programming, so they are all programming languages in one way or another

#

some are declarative, others imperative

#

some are compiled, others interpreted

white anvil
#

i kinda wnna learn haskell

#

functional looks rlly cool but probably a pain to do well

sick cloud
#

that timing :(

amber fractal
#

lmao sorry

#

I care :>

rough walrus
#
const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {
    if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("You don't have enough permissions for this command!");
    let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
    if(!args[0] || args[0 === "help"]) return message.channel.send(`Usage: addrole user role`);
    if(!rMember) return message.reply("Couldn't find that user.");
    let role = args.join(" ").slice(22).toLowerCase();
    if(!role) return message.reply("Please specify a person.");
    let gRole = message.guild.roles.cache.find(r => r.name.toLowerCase() === role);
    if(!gRole) return message.reply("Couldn't find that role.");

    if(rMember.roles.cache.has(gRole.id)) return message.reply("That user has the role already.");
    await(rMember.addRole(gRole.id));

    try{
        await rMember.send(`βœ… You have were given the role ${gRole.name}!`)

    }catch(e){
        message.channel.send(`βœ… <@${rMember.id} was given the role ${gRole.name}!`)
  }
}
 module.exports.help = {
     name: "addrole"
}```


i don't get terminal errors, but the bot can't find the role that iam trying to add,what's wrong?
ping me if you would help, thanks
sudden geyser
#

if(!args[0] || args[0 === "help"]) return message.channel.send(Usage: addrole user role);
Why are you comparing a number to a string?

You should also avoid using .join(" ").slice(22). That's not a guaranteed length.

uncut sundial
#

Helo guys,i dont know how to use HTML is there anyone have ready like template or something or how can i do ? Thanks

earnest phoenix
#

you can use a framework to make your site

#

like Bootstrap or MaterializeCSS

pale vessel
earnest phoenix
#

that'll be also helpful

#

with frameworks you dont have to write a lot of CSS code, and can help your site look better with minimal effort

uncut sundial
earnest phoenix
#

ive tried making a special simplified version of my bot's site for the html description, because it was bugging out the site's css, but it was ugly and the site css made it worse so i just plopped an iframe and some as in a comment

#

I get the error server is not defined when I use ?play (song link)

function plya(connection, message) {
    var server = Object.create(Object);

    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();
    })
}

exports.run = (client, message, args) => {
    if (args[1]) {
        message.channel.send('Please provide a link');
        return;
    }
    if (!message.member.voice.channel) {
        message.channel.send('You must be in a voice channel')
        return;
    }
    if (!server[message.guild.id]) servers[message.guild.id] = {
        queue: []
    } 

    server.queue.push(args[1]);

    if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
        AnimationPlaybackEvent(connection, message);
    })
}
#

i can tell that's js, so i might not understand, but why are you trying to create an Object object?

#

Someone told me that might work, turns out it dosen't

#

who told you that would work??

#

someone earlier on the server forgot the name

#

btw you misspelled play as plya

#

lmao

uncut sundial
earnest phoenix
#

that's a table

fast trench
#

How would I get a list of caseNumbers into an embed in a list to show the case numbers per user in the db? here's what my code is: js } else { const user = await StateManager.connection.query(`SELECT * FROM warningamount WHERE guildId = ${message.guild.id} AND memberId = ${warned.id}`); const cases = await StateManager.connection.query(`SELECT caseNumber FROM warninglog WHERE guildId = ${message.guild.id} AND memberId = ${warned.id}`) console.log(cases); if (user[0][0] === undefined) { message.channel.send(`This member doesn't have any warnings`) } else { if (!args[1]) { const embed = new MessageEmbed() .setTitle(`${warned.username} warning cases`) .setDescription(cases[0][0].caseNumber) message.channel.send(embed) } else {
console says: https://prnt.sc/sghf8k
output in channel so far: https://prnt.sc/sghf1q

Lightshot

Captured with Lightshot

Lightshot

Captured with Lightshot

earnest phoenix
neat ingot
#

@earnest phoenix no. i told you that the code i showed was not copy/paste. you copy/pasted it.

#

also also incorrectly πŸ˜„

#

@earnest phoenix Object.create(Object) is just a long way of doing {}.

earnest phoenix
#

ah

#

sorry im not really experienced in js development that much

#

im more focused on python

#

Β―_(ツ)_/Β―

neat ingot
#

np, thats a thing that a lot of js devs arent sure about as well πŸ˜„

earnest phoenix
#

at least i dont have to be ashamed of that as much, i guess

neat ingot
#

no one should ever be ashamed of not knowing a thing; imo as long as your able to learn when someone explains things, thats reason enough to be proud πŸ˜„

earnest phoenix
#

yeah

#

i do know some JS but im not focused on learning d.js

#

thats why i was thrown off by Object.create(Object)

neat ingot
#

tbf, they arent exactly the same, but for most use cases they are interchangable πŸ™‚

#

Object.create(Object) and {} i mean

halcyon ember
#

i have this if (message.content.startsWith('$start')) { score = client.getScore.get(message.author.id); if (!score) { if (!score) { score = { id: `${message.author.id}`, user: message.author.id, btc: 0, eth: 0, usd: 0, i3: 0, i5: 0, i7: 0, i9:0, level: 1} } const embed = new Discord.MessageEmbed() .setColor('#ff9933') .setTitle('Use $profile to see your newly created profile!') .setAuthor('Account Created', 'https://cdn.discordapp.com/emojis/710590499991322714.png?v=1') message.channel.send(embed) client.setScore.run(score); } else { const embed = new Discord.MessageEmbed() .setColor('#ff9933') .setTitle('You already have an account! Use $profile to see your account.') .setAuthor('Error', 'https://cdn.discordapp.com/emojis/710585568660291584.png?v=1') message.channel.send(embed) } }

#

i want it to send the error message if the user wasnt found in the sqlite but its not workin

#

if i run the $start command multiple times it keeps saying success

halcyon ember
#

now this is working

#
    if (message.content.startsWith('$start')||('$register')) {
      score = client.getScore.get(message.author.id);
      if (!score) {
        if (!score) {
          score = { id: `${message.author.id}`, user: message.author.id, btc: 0, eth: 0, usd: 0, i3: 0, i5: 0, i7: 0, i9:0}
        }
              const embed = new Discord.MessageEmbed()
                  .setColor('#ff9933')
                  .setTitle('Use $profile to see your newly created profile!')
                  .setAuthor('Account Created', 'https://cdn.discordapp.com/emojis/710590499991322714.png?v=1')
                  message.channel.send(embed)
        client.setScore.run(score);
      } else if (score && message.content.startsWith('$start')||('$register')) {
        const embed2 = new Discord.MessageEmbed()
        .setColor('#ff9933')
        .setTitle('You already have an account! Use $profile to see your account.')
        .setAuthor('Error', 'https://cdn.discordapp.com/emojis/710585568660291584.png?v=1')
        message.channel.send(embed2)
      }
    }```
#

but it send the error whenever i type anything

wheat jolt
#

what's the error

fathom crow
wheat jolt
#

that isn't really needed

#

they're just some colors

halcyon ember
#

problem was my or statement wasnt proper fixed it

fast trench
#

that isn't really needed
@wheat jolt it helps if it helps someone πŸ˜‰ it helps me no what is going on most of the time

wheat jolt
#

What?

#

Excuse me, but I don't understand what you're trying to say

fast trench
#

it helps if it helps someone πŸ˜‰ it helps me no what is going on most of the time
that's what I'm trying to say

wide ridge
#

any bots go down just now?

fast trench
#

nope

wheat jolt
fast trench
#

so I'm getting this error: Error: Incorrect datetime value: '1589521526720' for column 'createdOn' at row 1 when trying to put a date into mySql with this code Date.now() anyone have any idea?

pale vessel
#

try new Date()

fast trench
#

even though it's in the middle of a line?

pale vessel
#

sure

fast trench
#

didn't work

pale vessel
#

any new error?

fast trench
#

same thing

pale vessel
#

what datatype did you specify for that column?

fast trench
#

I've tried datetime...timestamp...date

pale vessel
#

what do you want your dates to look like?

fast trench
#

I just need it to be entered into the database for a giveaway command

pale vessel
#

you can just put timestamp

#

and new Date() would work

fast trench
#

ok I'm getting an actual date and time but it's still giving me that error

pale vessel
#

did you change the datatype

fast trench
#

yes...I've tried them all again and nothing changed except it's logging the actual date instead of just that string of numbers

pale vessel
#

what's the datatype you're using now

#

try TIMESTAMP

fast trench
#

I did

#

and I still got the error

pale vessel
#

with new Date() ?

#

that's odd

fast trench
#

yep

pale vessel
#

well in that case, just make it a bigint and store Date.now()

#

make sure you enable big numbers in your MySQL connection options

#

otherwise they would round them

fast trench
#

I've tried that...nothing

pale vessel
#

yeah it's just you

#

so try to figure out what you did wrong

#

i can't help much

#

sorry

fast trench
#

so try to figure out what you did wrong
@pale vessel please tell me that wasn't supposed to be read sacastically like a dickhead lmao

pale vessel
#

idk

silent berry
#

Hello again, what could cause this.

    at Client.<anonymous> (/home/container/bot/bot.js:431:23)
    at Client.emit (events.js:323:22)
    at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
    at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
    at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
    at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:311:20)
    at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:311:20)```
#

Discord.ks version 11.5.1

pale vessel
#

not a library issue

#

go to bot.js

#

line 431

silent berry
#
let evaled = eval(text)
pale vessel
#

so the text has syntax error

#

what is the text

silent berry
#

airbus.guilds.get("639122730389864458").channels.get("701823878292439120").send("Hide all the keys, and seal our windows
'Cause I'm going to war")});

pale vessel
#

remove } at the end

silent berry
#

Ok

pale vessel
#

wait

#

remove )}

silent berry
#

HE!airbus.guilds.get("639122730389864458").channels.get("701823878292439120").send("Hide all the keys, and seal our windows
'Cause I'm going to war");

#

That

pale vessel
silent berry
#

SyntaxError: Invalid or unexpected token
at Client.<anonymous> (/home/container/bot/bot.js:431:23)
at Client.emit (events.js:323:22)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:311:20)

pale vessel
#

well never mind

#

why did you use eval?

#

you can just use that without it

silent berry
#

I'm doing it via another server

pale vessel
#

that's not how it works

#

try without eval

silent berry
#

Explain

pale vessel
#

you're evaling it on the same server

#

there's no point

silent berry
#

No. I'm in another server running eval

#

I think i know what it was

#

I'ma fix it

#

I fixed it

#

Thanks for helping

tight plinth
#

only happens w<ith this song tho

#

nope, also happens wih other songs (seems random)

earnest phoenix
#

check if there are any LL/LP updates

tight plinth
#

there is a new LP update, but no new LL

#

and idk how to apply a LP update to LL

tight ferry
#

anyone here familiar with twitch's api? I can't seem to get the new one to work properly. All I want to do is have my bot notify users when someone goes live

pale vessel
#

sounds like ifttt

tight ferry
#

that only lets you get notifications when your stream goes live. I need it to get pinged when a channel that is not my own goes live

mossy vine
#

i tried to implement something like that with the twitch api about a year ago

#

yeah its fucked

#

sometimes if a channel is live it says it isnt

#

and when its not live it says it is

#

its just cursed

pale vessel
#

well you can try with their new api

tight plinth
pale vessel
#

catch

tight ferry
#

yeah its fucked
@mossy vine literally the WORST api I have ever seen. And their docs are not very helpful.

Anyway, I will try IFTTT again and see if anything changed since last time I used it

tight plinth
#

wait

#

it happens for every message

#

ho

#

I use thee excact same code for my bot, and it works

#

wtffffff

white gyro
#

find is a method for arrays, not maps

#

@tight ferry You need to poll their streams endpoint every ~2 minutes for reliable results. Don't use the webhooks

tight plinth
#

it still works with my other bot using the exact same lines of code tho

white gyro
#

That's not possible, if you want to use find use a discord.js Collection instead

#

Which is basically Map with array methods

true ravine
#

When bots get a message containing emojis, are the emojis actual unicode emojis or what are they?

pale vessel
#

they're unicode or custom (<:nameπŸ†”>)

#

smh

#

discord

tight plinth
#

like

#

-->

true ravine
#

I run a delivery bot and people can order with emojis but when I check the order info of an order containing emojis they just show up as ????. The orders are stored in a mysql database using default unicode (utf8 something I assume) and I don't really want the emojis to appear as ???? lol

pale vessel
#

yeah my mysql db does that too

true ravine
#

I kinda wanna fix it now my bot is gaining traction

#

Do you think it is a mysql issue or something else?

neat ingot
#

just store the name and id of the emoji, not the emoji object?

true ravine
#

But then I'd have to store each emoji from an order separately

#

Storing the ids for all emojis in a message would be clunky af

neat ingot
#

im curious, what do people have delivered?

#

lol 'mr delivery man' πŸ˜„

true ravine
#

It's food only atm because people abused it when they could order anything lol

#

Indeed

neat ingot
#

ooohhh, so you hook into an api to order from local takeaway places?

true ravine
#

Nah, they get sent images lul

neat ingot
#

just eat or deliverooo or uber eats or such?

#

:/

true ravine
#

You never heard of DFF?

neat ingot
#

so they dont actually order real life produce?

#

nah 😦

true ravine
#

Nah unfortunately not

#

If deliveroo wanna partner I'd be happy to tho

#

Anyway

neat ingot
#

i feel its not that πŸ˜„

true ravine
#

Discord Fast Food

neat ingot
#

ahhh lmao

true ravine
#

I'm like the hip younger brother where you don't have to wait like 10 hours to get your stuff

#

I digress

#

Any ideas how I could fix the emoji issue?

neat ingot
#

other than storing the id/name not really. i guess you could maybe json stringify the object before storing it in sql database then json parse it when its coming back out? but it'd likely lose some data

pale vessel
#

is there even a way to store a Unicode id and name

neat ingot
#

string?

true ravine
#

Err I dunno

neat ingot
#

like, i'd try to store it in the format discord uses <name: id> w.e it is (think thats backwords)

pale vessel
#

could probably do that with custom emojis

#

but not something like πŸ€”

neat ingot
#

: thinking :

#

not hard

#

lol

pale vessel
#

no

true ravine
#

Aren't "normal" emojis able to be stored in the name:id format too?

pale vessel
#

it gets converted to unicode

#

no

true ravine
#

Oof

restive furnace
#

its <:name:id> btw

true ravine
#

It's janky, but I might filter out custom emojis and store standard ones as discords :emoji: format

pale vessel
#

it's the opposite

#

you should store custom emojis

#

because they're easy to manage

neat ingot
#

think about this: people use emoji in their discord username a lot

#

does your db have issue storing their names?

true ravine
#

It only stores ids

#

So idk

pale vessel
#

it should store their IDs

#

and resolve it to a user using the bot itself

true ravine
#

That's what it does

pale vessel
#

that's better than storing names individually which is not permanent

true ravine
#

Yeah

#

Back to the emoji thing

#

You were saying I should store custom ones

#

Surely regular ones would be more useful as theyre more commonly used?

#

Just thinking aloud

pale vessel
#

ah i thought the users get to choose the emoji lol

neat ingot
#

i mean, idk about yall, but i also store usernames for my bot (its rpg and has leaderboard, leaderboard uses usernames) and i have no issue at all with people with strange usernames and emojis etc

true ravine
#

What db you using?

neat ingot
#

mongodb

pale vessel
#

oof

true ravine
#

Ah I use mysql

earnest phoenix
true ravine
#

(I'm gonna go and tinker so you can help this person now)

pale vessel
#

use hastebin

neat ingot
#

+1 for using pastebin over hastebin ❀️

#

lmao

earnest phoenix
#

i don't know what's the diffrence

#

but i want help, please

pale vessel
#

the difference is that people would actually help you if you use hastebin

#

legit

earnest phoenix
#

better ?

pale vessel
#

yes

#

no errors?

earnest phoenix
#

No errors

pale vessel
#

because pastebin is hard to use and it's ugly

#

@earnest phoenix you should upgrade to v12 asap

#

v11 isn't going to last any longer

earnest phoenix
#

i want my bot to be accepted first, an then upgrade, because i have a risk that if i update to v12 now the bot will have errors and won't work normaly when testing πŸ˜›

tulip violet
#

can someone help me ? im searching for bot which, when u react, the bot will dm u

pale vessel
#

make your own

tulip violet
#

how

pale vessel
earnest phoenix
#

@pale vessel so do you have any idea?

pale vessel
#

could be the role

#

it's weird

#

maybe permissions

#

did your bot have the correct permissions and respect the role hierarchy

earnest phoenix
#

yes

sick cloud
#

just found a bug that lets you see any server's settings lol

pale vessel
#

maybe report it and get a bug hunter badge

sick cloud
#

nah

#

not really development but its close

true ravine
#

It kicks you off if you try to view members tho

#

Big rip

earnest phoenix
#

           let getLevelBoost;
            let getBoost = message.guild.premiumSubscriptionCount;
            if(getBoost < 2) getLevelBoost = "0"
            if(getBoost = 2 || getBoost > 2 && getBoost < 15) getLevelBoost = "1";
            if(getBoost = 15 || getBoost > 15 && getBoost < 30) getLevelBoost = "2";
            if(getBoost  = 30 || getBoost > 30) getLevelBoost = "3";```

I have do this but the bot send me level 3 but my server does not any boost imao
#

how can i do?

pale vessel
#

you used =

#

what do you think that does

earnest phoenix
#

=== ?

pale vessel
#

yes

earnest phoenix
#

Ok thx u

#

@pale vessel

#

my bot send me undefined :/

pale vessel
#

what's your code

earnest phoenix
#
            let getBoost = message.guild.premiumSubscriptionCount;
            if(getBoost < 2) getLevelBoost === 0
            if(getBoost === 2 || getBoost > 2 && getBoost < 15) getLevelBoost === 1;
            if(getBoost = 15 || getBoost > 15 && getBoost < 30) getLevelBoost === 2;
            if(getBoost === 30 || getBoost > 30) getLevelBoost === 3;```
pale vessel
#

ok

sick cloud
#

still using =

pale vessel
#

you need = on some parts

sick cloud
#

and you're using === when setting ...

earnest phoenix
#

uh ok

pale vessel
#

yeah

earnest phoenix
#

so this :

sick cloud
#

learn js before making a bot

earnest phoenix
#
            let getBoost = message.guild.premiumSubscriptionCount;
            if(getBoost < 2) getLevelBoost = 0
            if(getBoost === 2 || getBoost > 2 && getBoost < 15) getLevelBoost = 1;
            if(getBoost === 15 || getBoost > 15 && getBoost < 30) getLevelBoost = 2;
            if(getBoost === 30 || getBoost > 30) getLevelBoost = 3;```
pale vessel
#

yes

#

perfect

earnest phoenix
#

i learn doc, u want to see my history!? @sick cloud

pale vessel
#

do you know what that code does

earnest phoenix
#

ok ty

sick cloud
#

you clearly don't know some basics

#

so learn js basics before making a bot

modest maple
#

I dont even do JS and ik how todo comparisons lol

languid dragon
#

Is anyone aware of why 'AbortError' would be spamming my logs or if there are any issues currently with DAPI?

modest maple
#

probably

languid dragon
#

very helpful response

#

thanks

modest maple
#

i mean looking at my logs i havent had anything

#

other than alot of fucking 401's holy fuck

indigo geyser
#

how do you put links on footer (webhooks) like the github one

#

I now realize that is the description

#

sorry

pale vessel
#

footer would have grey text

winter basalt
#

lmao

mellow violet
#

you can achieve that by using markdown, it works even in embeds

pale vessel
#

he meant links in footer

opaque seal
#

Can I include a gif in my bot description on top.gg if my bot isn't verified?

pale vessel
#

sure, why not

#

unless it causes seizures

lofty lagoon
pale vessel
#

virus

lofty lagoon
#

why I have this error (too many carracter)

pale vessel
#

because the content reached over x characters

lofty lagoon
#

no virus XDDD

#

virus
@pale vessel .txt file cant be a virus

#

it's not a .bat x)

grizzled raven
#

hm

grizzled raven
#

a mod removed the embed but left you on read

quartz kindle
#

econnreset means your connection was reset and the shard disconnected

#

usually happens due to network issues

#

you can usually catch those by doing ```js
client.on("error", error => {
console.log(error) // or do other things with error
})

earnest phoenix
#

how i get the level of security of the guild?

quartz kindle
opaque seal
#

sure, why not
@pale vessel so you know how I can do that in the actual code?

quartz kindle
#

with html?

opaque seal
#

But if the gif is on my PC and not online anywhere I will have to upload it somewhere right?

pale vessel
#

yes

opaque seal
#

What's the best place for that?

pale vessel
#

depends

#

definitely not a sharex server

#

you can right click the image and get the link

#

after you upload the image

opaque seal
#

Cool, hopefully they have good servers because my gif is a bit heavy and I need it to load quick

plucky atlas
#

Do I have to use discord.js to actually code a bot

pale vessel
#

no

opaque seal
#

Flazepe do you know about this?

Cool, hopefully they have good servers because my gif is a bit heavy and I need it to load quick

pale vessel
#

just use html lol

#

oh, their server is fine

#

you can just use github if it's slow

opaque seal
#

Ok thx for everything

#

Can I use markdown for that too?

quartz kindle
#

you can also convert your gif to base64

#

that way you dont need to host it lol

opaque seal
#

What's basic64?

quartz kindle
#

base64

neat ingot
#

lol

quartz kindle
#

its an encoding method

opaque seal
#

Uh ok

quartz kindle
#

basically instead of the image being a separate file

#

you put the entire image code in the website

#

encoded in base64

opaque seal
#

Ok got it

neat ingot
opaque seal
#

Then it's the viewer PC that has to elaborate the gif

quartz kindle
#

yes

#

it will read the image from the code, instead of from a file

#

the only problem is that base64 encoding makes the file size about 1.5x bigger

#

since its not as efficient as binary

neat ingot
#

sometimes convenience is better than performance as long as its not overly detrimental imo πŸ™‚

#

note: sometimes

lofty lagoon
#

you can usually catch those by doing ```js
client.on("error", error => {
console.log(error) // or do other things with error
})

@quartz kindle I use eris not discord.js

quartz kindle
#

should be the same on eris

lofty lagoon
#

ok I gonna try

quartz kindle
lofty lagoon
#

I think it's worked

#

cuz my bot is online

tight plinth
#

my lavalink node crashes if I try to play a yt livestream

#

why

#

(giving logs...)

#

Thank you for listening, I hope you will have a good time here :)

🎼 Listen to the playlist on Spotify, Apple music and more
β†’ https://bit.ly/chilledcow-playlists

🧑 The Lofi Girl figure (limited edition)
β†’ https://youtooz.com/products/lofi-girl

πŸ‘• Check out the ChilledCow me...

β–Ά Play video
#

*lavalink node restarts automatically

lyric mountain
#

this happened a lot with me earlier

#

update your lavalink lib

quartz kindle
#

i see you are a man/woman of culture as well

tight plinth
#

k

#

yes im a man of culture

#

I spent my first 14 years of life discovering things

#

(the 15th here)

#

update your lavalink lib
@lyric mountain which one? shoukaku? the lavalink.jar?

lyric mountain
#

are you using maven/gradle?

tight plinth
#

erm no

lyric mountain
#

you're crazy

#

lol

#

get the one from the official github repo

tight plinth
#

well gonna lock live streams for now

#

and gonna wait for a update

earnest phoenix
#
client.on('shardDisconnect', ()=>{})```
 events are working on discord.js v11? I don't want to update v12 ..
pale vessel
#

you will need to

#

#soon

earnest phoenix
#

@pale vessel so, this mean isnt working?

#

?

pale vessel
#

it works

earnest phoenix
#

oh thanks so much >3

lyric mountain
#

@earnest phoenix but won't soon

earnest phoenix
#

Hi can someone help me with a music order

#

:)

wheat jolt
#

What do you mean

earnest phoenix
#

@wheat jolt
I had developed a music command and it didn't work

wheat jolt
#

well, share your code

#

also the error if you get one

earnest phoenix
#

i
I delete the command because visual code studio does not work with errore

wheat jolt
#

then what's your point?

#

You want us to write the command for you?

earnest phoenix
#

well i can't

wheat jolt
#

You can't what

earnest phoenix
#

order music

wheat jolt
#

stop using google translate pls

earnest phoenix
#

i no english

modest maple
#

you're english?

wheat jolt
#

I already knew this

earnest phoenix
#

i french

wheat jolt
#

ok

pale vessel
#

this is lumap's job

modest maple
#

@tight plinth Je Suis ne le pas fancias, baguette #development le fromage

earnest phoenix
#

hainn

pale vessel
#

oui oui

earnest phoenix
#

no comprendo

tight plinth
lyric mountain
#

I wonder what baguette means besides being a bread type

pale vessel
#

uhh nothing probably

wheat jolt
#

non non

earnest phoenix
#

plase help order music

wheat jolt
#

no spoon feeding

tight plinth
#

@earnest phoenix allons dans #memes-and-media (le channel ou on peut parler fr), j't'aide

earnest phoenix
#

oke

lusty quest
#

does anyone got an idea why this wont work? I have a Command that creates an Embed that i want to delete after a certain time. For this i send the message id and channel id into a mysql database. In a event i check in an interval if a Dataset in the Mysql database is older than x hours. If yes it retrives the data. Now i want to get the data sorted out but for some reason is my json invalid in the bot but valid in a json path finder

{"id":1,"lfg_message_id":"710517636752081007","timestamp":"2020-05-14T15:43:25.000Z","channelid":"660506975796461720"}
 for (var i = 0; i < messages.length; i++) {
            var p = messages[i];
            let val = JSON.stringify(p)
           console.log("Package: "+val.lfg_message_id)
        }

This gives me this Console print
Package: undefined

#

the mysql query returns a json with 3 nested arrays this is why the loop

lyric mountain
#

why don't you simply use setTimeout()?

lusty quest
#

still need to make something to restart the timeout if the bot restarts during an active timer

lyric mountain
#

then instead of storing the timestamp in the db, get the message's own creation date

#

and store only the ids on the db

lusty quest
#

the timestamp is created while its inserted into the Database and is only used by Mysql for selecting the rows that are older than x hours

lyric mountain
#

btw, the issue is that you used JSON.stringify

#

you can't val.lfg_message_id as string

lusty quest
#

when i run the console.log without .lfg_message_id i get this Package: {"id":1,"lfg_message_id":"710517636752081007","timestamp":"2020-05-14T15:43:25.000Z","channelid":"660506975796461720"}

lyric mountain
#

read what I said

honest perch
#

idk why but the serverinfo command doesnt work in this server, its something to do with the server owner line

lyric mountain
#

you gotta pick the attribute BEFORE stringifying it

#

JSON.stringify(p.lfg_message_id)

lusty quest
#

ok thanks

pale vessel
#

you can actually do that

lyric mountain
#

you can't get a json parameter from a string

#

since the string is a text

pale vessel
#

oh, i thought he was trying to stringify the whole object

#

why would he stringify it in the first place if he's going to pick a parameter

lyric mountain
#

idk, buuuuut

pale vessel
#

bruh

balmy knoll
#
let path = [__dirname + '../../../assets/Stats.png'];
                  
                  let mage = new Canvas(1408, 1058)
                    .addImage(path, 0, 0, 1408, 1058)
                    .toBufferAsync();
                  
                  let stats1Embed = new Discord.MessageEmbed()
                      .attachFiles([mage])
                      .setColor("BLUE")
                      .setImage('attachment://mage')
                      .setTimestamp()
                      .setFooter("Pagina 1");
                  embeds.push(stats1Embed);```
How can i set the mage files in the embed?
lyric mountain
#

you forgot the extension

balmy knoll
#

@lyric mountain Mage is a canvas object, so which is the extension?

lyric mountain
#

afaik you need to make it become an image

#

I never used canvas, so idk

quartz kindle
#

is that canvas-consctrutor?

balmy knoll
#

@quartz kindle Yes

quartz kindle
#

path is supposed to be a string, not an array

#

also, from what i can see in their readme, you have to load the image yourself

#

addImage doesnt load it for you

balmy knoll
#

Wait the addimage works, i asked to setImage in the embed

#

If i use message.channel.send({files: [mage]});, all work well

quartz kindle
#

if it works then do this

#

.attachFiles([{attachment:mage,name:"mage.png"}])

#

.setImage("attachment://mage.png")

earnest phoenix
#

how i can put a video in embed?

lyric mountain
#

you can't

earnest phoenix
#

oh ok

balmy knoll
#

@quartz kindle Thanks, i'll try

#

@quartz kindle I'll get this error TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.

quartz kindle
#

use toBuffer

#

instead of toBufferAsync

dusky hill
#

hey

#

is there any way to get the on or off status in php of my bot?

earnest phoenix
#

On/off? Like if your bot is running?

dusky hill
#

yes

#

i don't know how i can pass this on to my php

quartz kindle
#

@balmy knoll try the path as a string

#

without []

rough walrus
#
const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {
    if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("You don't have enough permissions for this command!");
    let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
    if(!args[0] || args[0 === "help"]) return message.channel.send(`Usage: addrole user role`);
    if(!rMember) return message.reply("Couldn't find that user.");
    let role = args.join(" ").slice(22).toLowerCase();
    if(!role) return message.reply("Please specify a person.");
    let gRole = message.guild.roles.cache.find(r => r.name.toLowerCase() === role);
    if(!gRole) return message.reply("Couldn't find that role.");

    if(rMember.roles.cache.has(gRole.id)) return message.reply("That user has the role already.");
    await(rMember.addRole(gRole.id));

    try{
        await rMember.send(`βœ… You have were given the role ${gRole.name}!`)

    }catch(e){
        message.channel.send(`βœ… <@${rMember.id} was given the role ${gRole.name}!`)
  }
}
 module.exports.help = {
     name: "addrole"
}```



i don't get terminal errors, but the bot can't find the role that iam trying to add,what's wrong?
ping me if you would help, thanks
quartz kindle
#

@dusky hill many ways you can do that, use a shared database and have your bot push its status there, have an api endpoint in your bot program to retrieve its status, get its status from top.gg after your bot is listed there

balmy knoll
#

@quartz kindle No, i can't understand

quartz kindle
#

@rough walrus dont use .slice(22), its bad practice

#

use message.mentions.roles.first()

rough walrus
#

i replace that right?

quartz kindle
#

you can also remove the entire roles.cache.find() line

#

because mentions.roles will give you the role alredy, no need to find it

#

if you want to use roles by ID, then you do the same thing as you did for member

#

use args[1] and use roles.cache.get() using args[1]

balmy knoll
#

@quartz kindle Nothing work

quartz kindle
#

then you need to do what the docs say

#

and load the image first

#

you dont need to use fs-extra, you can use normal fs

#

you can do for example let image = fs.readFileSync(path) then .addImage(image)

plucky atlas
#

Do you guys now how to open up the coding window

#

Sry I'm new to this