#development

1 messages · Page 594 of 1

earnest phoenix
#

when i return error

west spoke
#

0x40

earnest phoenix
#

i can return any other, e.g. ("KICK_MEMBERS")

west spoke
#

Use that

#

Or 0x800

#

If that top one doesn't work

earnest phoenix
#

instead of SEND_MESSAGES?

west spoke
#

Ye

#

0x00000800
May actually be that

#

Through a bit more research..

#

And the SEND_MESSAGES should have worked tho

earnest phoenix
#

it doesn't for some reason

west spoke
#

Weird

earnest phoenix
#

it logs Missing permissions to console

#

as error

#

but i cant return error as message

west spoke
#

What lang

earnest phoenix
#

js

west spoke
#

Ah

#

Well

#

If there is a way to "except" a error message

earnest phoenix
#

idk, theres catch

west spoke
#

Like when that error comes up

earnest phoenix
#

which works

west spoke
#

Make it say the error messagd

earnest phoenix
#

yes

#

i already have that

west spoke
#

I don't know js

earnest phoenix
#

its called .catch

west spoke
#

Odd

#

Meh

earnest phoenix
#

but its so long and ugly

#

waste of time

west spoke
#

Whatever will make it work tho

grim aspen
#

show us the error message

earnest phoenix
#

it just says Missing permissions

#

basic discord api error

west spoke
#

Wait

grim aspen
#

wait

west spoke
#

What are the bot's permission

#

Does it have administrator

grim aspen
#

you're trying to have the website server count?

earnest phoenix
#

look, im trying to make bot reply to user if cant send message to channel

#

and i made it

#

but code is so long

#

with .catch

#

if i could check for permissions

#

in message event. instead of .catching every error

gleaming tulip
#

just screenshot the code

earnest phoenix
#

sec

#

this is the code im trying

#

its werid cuz i have this code

#

and it works perfectly fine

gleaming tulip
#

whats the error

harsh nova
#

Maybe the user has blocked DM’s

west spoke
#

Oh

#

My

#

God

#

If it can't send messages it can't send the message

gleaming tulip
#

pls

earnest phoenix
#

i still want to handle all errors

gleaming tulip
#

put a catch after the author.send

earnest phoenix
gleaming tulip
#

no

#

console.log

earnest phoenix
#

it works, i already use it, just

#

its not what im looking for

gleaming tulip
#

you put the catch on the author.send?

#

I mean, did you put that catch you screenshotted on the author.send?

earnest phoenix
#

i probs didnt explain well

#

i can send error message to author

#

with .catch

gleaming tulip
#

so what do you want

earnest phoenix
#

its not what im looking for because its long

#

i want

#

to check if bot can send messages

#

before it continues

#

so i dont have to .catch 345345 times

gleaming tulip
#

are you sure that's the permission it's missing

earnest phoenix
#

i muted bot on purpose

#

so it cant send messages

gleaming tulip
#

muted?

earnest phoenix
#

im looking for a way to handle that error

gleaming tulip
#

or removed the permission from it's role

earnest phoenix
#

removed permission

gleaming tulip
#

hm

#

from the role or the channel?

earnest phoenix
#

role

#

i mute bot so i can cause an error

#

i want to check for that error

#

just not with .catch

#

idk why checking for "send_messages" wont work

#

its only thing i need right now

gleaming tulip
earnest phoenix
#

this works

gleaming tulip
#

but actually give it SEND_MESSAGES before testing it

earnest phoenix
#

buuuuut

#

i would like to check for permissions

#

when message event is called

#

not specific command

deep pond
#

Hi

#

Can I have some help

grim aspen
#

on what

deep pond
#

member.top_role

gleaming tulip
#

dbl ask2ask

earnest phoenix
#

okay i think im actually retarded

echo pasture
#

@deep pond what you need with help?

#

if you have an error just send code and your error

#

and we will may help you :^)

deep pond
#

kk 1 sec

gleaming tulip
#

so what was wrong "uwu"?

echo pasture
#

welp i dont even know python languages so yeah

deep pond
#

oh

earnest phoenix
#

i didnt declare check for permission in message event xd

echo pasture
#

i know javascript very well

#

wait until someone gives you a help

earnest phoenix
#

dk how tf i missed that

obsidian shoal
#

i need help making a roblox verification bot

earnest phoenix
#

How can I put a timestamp in a message

#
client.channels.find(x => x.name === 'bot-information').send(`Bot succesfully logged in at ${Date.now()}`);
${Date.now()}

ain't working, it sends it in ms (I think) but I want it like Today at 23:12

#

Any1 knows how to put it so it would do that?

amber fractal
#

new Date()

#

Wait

#

Timestamps?

earnest phoenix
#

ye

#

like today at 23:27

amber fractal
#

Idk how to make timestamps on a regular message that change like the ones in embeds do

earnest phoenix
#

same ::P

quartz kindle
#

just format it

earnest phoenix
#

I tried

amber fractal
#

I dont think that changes with the time like embed times stamps do though

earnest phoenix
#

but Im new to coding

quartz kindle
#

you cant put a discord timestamp on a normal message, it will show next to your username, but not in the message itself, you cant connect the two

grim aspen
#

message deleted: not helpful and sounded rude

amber fractal
#

Send an embed with just a timestamp with the message mmLol

quartz kindle
#

well, embeds yeah, hes trying on a normal message

earnest phoenix
#

xd

#

Im trying to get the times my bot restarted in a channel

#

any idea how to do that with embed?

quartz kindle
#

if you're posting to discord, you dont need to control that yourself

#

just use discord's own timestamps that appear after the username

earnest phoenix
#

but that takes more time for my eyes to find and im lazy

lusty dew
#

@deep pond Wut you trying to do?

honest kernel
#

how does on development

#

I cant soak right

#

*speak

heady zinc
#

discord.js itself is the leak

unborn nebula
#

bug fixed put bot back in for verification

earnest phoenix
#

How do you edit your bot page? like

grim aspen
#

if i'm not mistakened, it's a webhook and html

earnest phoenix
#
client.on('guildMemberAdd',member=>{
    let color = ['Red','Pink','Green','Blue','Yellow','Snow','Black','HotPink','DeepPink','Chocolate','Cyan','Purple','DodgerBlue']
    var role = member.guild.roles.find('name'+color[Math.floor(Math.random()*color.length)])
    member.guild.channels.get('281113673282486273').send(`${member} хай кст`) 
    member.addRole(role)
})

what am I doing wrong? a fall due to the line:

+color[Math.floor(Math.random()*color.length)]
idle basalt
#

.find() either takes 2 params or a function, and you passed 1 string param

#

you probably want .find('name', color[Math.floor(Math.random() * color.length)])

earnest phoenix
#

@idle basalt thank you very much, I did not notice this)

idle basalt
#

i read the russian anyway, youre welcome

amber fractal
#

Well using the 2 params is deprecated. It will only work with functions in the future

idle basalt
#

ye but theres not even a tentative date for v12 release

#

it wont be a problem for a long time

amber fractal
#

But why use deprecated methods in the first place

idle basalt
#

no reason. i use functions /shrug

#

with support i prefer to just fix the problem theyre having instead of telling them to refactor code that works (and will work for some time)

amber fractal
#

(r => r.name == "role") isn't that difficult lol

idle basalt
#

i dont know what youre arguing

amber fractal
#

I'm arguing that you gave him a deprecated solution either way

idle basalt
#

reread this message: with support i prefer to just fix the problem theyre having instead of telling them to refactor code that works (and will work for some time)

#

passing a function is better, i agree. its just not necessary to refactor his code

amber fractal
#

He would need to add 6 extra characters not including spaces

#

you told him .find('name', color[Math.floor(Math.random() * color.length)])
Which is lliterally
.find(r => r.name == color[Math.floor(Math.random() * color.length)])

idle basalt
#

argues over using deprecated code that will work for months
uses double equals

amber fractal
#

Sorry I dont want to use strict equals for something that it wouldnt make a difference for

#

I'm not checking strictly that a number is a number or a string is a string it would make no difference in this case

#

But if you want 1 extra character? Then fucking go for it

idle basalt
#

ironic

#

if we're golfing, why are you suggesting he pass a function which takes 6 extra characters

amber fractal
#

Because it isnt deprecated

#

That's like knowing a company is going to collapse and investing in it anyways.

idle basalt
#

🤦

#

if you want to use 6 more characters, go for it

amber fractal
#

If you want to make your code work in the future, go for it

idle basalt
#

like i said twice now, i agree that passing a function is more correct. i use master so i have to pass a function anyway, but its silly to refactor someones code when he just wanted to know what he did wrong

#

his code will work in the future

#

you act like this is the only change that will exist in v12 😂 if he chooses to update when master comes out (in an unknown but large amount of time), he will have to refactor a lot more code than his .find()

lavish shuttle
amber fractal
#

It's literally not a refactor he would've hit backspace 6 times and type 11 characters

idle basalt
#

youre making a silly semantic argument. whats the point?

lavish shuttle
#

The reason why I ask is because I'd like to make a Discord bot that interacts with my website written in PHP

idle basalt
lavish shuttle
#

I know, but has someone made a rewrite or such?

#

I read that too you know

idle basalt
#

i wouldnt know, but its likely theyre all substandard

#

pretty sure you can have your discord bot interact with your backend even if theyre in different languages

lavish shuttle
#

Hm, I'll try to look it up. Thank you

idle basalt
#

you can use http requests and web sockets to transfer data from one language to the other

#

theres no need to torture yourself with a discord php lib if you know another language that can get the job done (py, js, java, cpp, go, etc.)

lavish shuttle
#

I'm more fluent in PHP than I am in JS, Python or CPP

#

Although, I'll try to take a look into doing the above

#

Thank you

hasty ginkgo
#

anyone use postgres with node.js?

robust breach
#

How do you close a message/reactioncollector?

#

nvm found it

bitter sundial
#

@amber fractal @idle basalt to settle this dumb argument:
DO NOT instruct newbies to use deprecated functions, it'll be a setback on them later and they'll be super confused. It doesn't help them learn. Instead, if you see someone asking for help with code that has a deprecated function, as a side note recommend them to switch away from the deprecated function.

brazen quartz
#

I am trying to manipulate json data from my postgres database using knexjs, if anyone understand what I just said and thinks they could help @ or dm me

near zinc
#

help

#

how do i see invites

#

when people invite

#

??

#

how do i trach invites

#

@bitter sundial

bitter sundial
rustic obsidian
near zinc
#

how do i make it track invites??

#

anyone help

lament meteor
#
  1. provide more information. you are asking how do you make a bot to track invites but you do not give any useful information as what library or coding language you use
lean swan
#

How to make bot owner can use all commands in other server?

#

.js

marble needle
#

giving yourself pseudo admin on any server your bot is on sounds like a pretty bad idea

lean swan
#

yes it so anoying to server owner

obtuse hearth
#

This may be a stupid question, but could my bot use any language I want?

marble needle
#

sure, as long as you're able to make api requests you can use whatever you want

#

if there's no library for the language you wanna use you might have to write your own though :>

uneven pond
#

bot auto role is code if (member.user) return false; ?

scenic kelp
#

Wut

#

@uneven pond what are you trying to do?

#

Guess not then

mossy vine
#

can someone please explain in a tl;dr or link me an article about what docker is and why and when i would use it?

jade rapids
unique nimbus
#

They can

#

idk how

jade rapids
#

Thats better than nothing

#

(If anybody has anything relating to this please PM me)

mossy vine
#

what lib are you using?

#

@jade rapids

marble needle
#

wild guess but if he's searching for the specific discord api reference he might not be using any conventional lib

jade rapids
#

one of the Java ones, I haven't gotten that deep yet but I wanted to know if my idea was possible

reef jacinth
#

Look at their docs

#

Should be something like guild the message was sent in .createChannel

#

I don't use java so cant tell ya

marble needle
#

there's your reference

jade rapids
#

Ahh thank you

#

Alternate subsection thats why it was lost

marble needle
#

found it via detour aswell, looked through a lib's code to find what endpoint they use for channel creation hmm

jade rapids
#

ahh very nice

obtuse hearth
#

Apparently my computer is running node version 7.0.0
Will that be a problem? It seems like a problem so far, but is here a work around?

hushed berry
#

its not too hard to just install a newer version lol

obtuse hearth
#

This isn't my computer, so I don't have permission to do that

hushed berry
#

then i dont think itll be too much of an issue

#

its only about 2 years old

obtuse hearth
#

I keep getting unmet peer dependency problems when I try to install discord.js

#

bufferutil, for instance, and when I try to install bufferutil, I get 'node_api.h' file not found

marble needle
#

you could simply ask for permission to update node thinkfused

obtuse hearth
#

Mmmmm... I could. I think I'd rather just do this on my laptop instead.

earnest phoenix
#

whats a good site to start learning nodejs for free?

lusty dew
#
let channel = message.guild.channels.get('540406836311097374')
#

This should work right?

slender thistle
#

Yep

lusty dew
#

Odd

#

I am getting errors

#

saying

#

channels of null

slender thistle
#

The message is in DMs

lusty dew
#

Hm?

#

Oh, wait

#

So if I dm the bot a command

slender thistle
#

If a message was sent in a DM, guild attribute will be null

lusty dew
#

Ah shit

#

true

#

didn't think about that

#

Hmmm

#

How could I solve that?

amber fractal
#

(return on dm messages)

slender thistle
#

an if checking for falsey value

lusty dew
#

Ah ok

#

Thanks

slender thistle
lusty dew
#

so wait

#

could I do something like

#
if(message.guild){
//do something
}else if (message.dmchannel){
//do something else
}
#

Would that work?

marble needle
#

just switch through message.channel.type

#

if it's 'text' do your thing if it's 'dm' or 'group' return

lusty dew
#

ah okie

#

so like

#
if(message.channel.type === "text"){
//do something
}else {
return
}
#

?

marble needle
#

if you're only interested in text messages then yes you could do it like that

lusty dew
#

Wait

#

but what if I want it to also get the channel id and send something to that channel if they use a command in dms

#

This is for an error system I have

marble needle
#

if you want to have messages sent to a channel via dm command the channel id you want the message to be sent into needs to be one of the command arguments

lusty dew
#

Wdym?

marble needle
#

what exactly do you wanna do

lusty dew
#

I was trying to use the help cmd

#

in my bots dms

#

and it sent me an error

#

But I couldn't view the error until I did console.log

#

so my error system isn't working in dms

#

and I also don't know why my help cmd won't send in dms

#

bc the error system broke so I couldn't view the error it gave me to fix the reason it won't send in dms

#

As for the error system, I want it so if they send a cmd in dms and it errors I want that error to be sent to a channel in my discord server

marble needle
#

what does your error system do for errors that happen in regular text channels

#

also send a message to your specific channel?

lusty dew
#

Yea

#

It saves it to a txt file

#

and sends it to the channel

marble needle
lusty dew
#

It is specific to my server yes

marble needle
#

could just hardcode the id and call it a day, get the channel through <client>.channels and you're fine

earnest phoenix
#

client.guild.channels.get()

lusty dew
#

Well fuck

#

I forgot you could even do that :/

earnest phoenix
#

sorry its: client.channels.get

lusty dew
#

Yea

#

I seriously need to think more about things before asking for help

earnest phoenix
#

happens

lusty dew
#

the whole problem with it not sending in dms was because of a permissions check

#

Rip

marble needle
#

don't fail silently

#

if the bot is specific to your server anyway keep logs of whats happening, will help you troubleshoot simple issues

lusty dew
#

Wdym keep logs?

earnest phoenix
#

track errors and stuff

lusty dew
#

Ah

#

I do lol

#

Unless you mean

#

try everything before asking for help?

marble needle
#

return console.logs or whatnot unless you're 100% sure your code will run without failing in any given scenario

lusty dew
#

Ah okie

amber fractal
#

Wait what are you trying to do?

lusty dew
#

I already got part of it solved

#

now I need to get it to check the users permission from the server they are in

earnest phoenix
#

(node:14217) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tag' of undefined

#

${nesne.user.tag}

lusty dew
#

whatever is before tag

#

is null

#

what is

#

nesne?

earnest phoenix
#

Turkish word.

amber fractal
#

nesne.user is not defined

lusty dew
#

I know that

earnest phoenix
#

blacklist command

lusty dew
#

Mk

#

But what do you have

#

nesne set as?

#

Also whatever his name above

#

is correct

amber fractal
#

You know who I am tho

lusty dew
#

didn't mean to say null

amber fractal
#

Im steven 😢

earnest phoenix
#

let nesne = args[0]

lusty dew
#

Ok

earnest phoenix
#

is nesne mention

lusty dew
#

Yea

amber fractal
#

That wouldnt give it a user property

lusty dew
#

Yea

#

so you wouldn't need

#

the .user

queen sentinel
lusty dew
#

right?

queen sentinel
#

ashamed of the name I gave you

#

I see

amber fractal
#

No

earnest phoenix
#

:\

amber fractal
#

He just knows who I am :(

lusty dew
#

Hello Steven

#

I forgot your name for a sec jeez

amber fractal
#

It ruins our friendship

earnest phoenix
#

but when i remove .user undefined :/

amber fractal
#

you want it to be a mention right?

earnest phoenix
steep hatch
#

hello

earnest phoenix
#

Rikkaevet- undefined karalisteye alındı.

steep hatch
#

özgür bey

earnest phoenix
#

He cnm

steep hatch
#

bot bağlanmıyor apiye

#

açılmıyo

earnest phoenix
#

Hm

#

Ne yapam

steep hatch
#

mantıklı

marble needle
lusty dew
#

How could I restrict certain commands from being used in dms?

marble needle
#

simply return if the respective command is used in dms rather than processing it

late hill
#

Or return an error

#

If you're gonna allow some commands in DM

#

It be better to let the user know when using one that isn't allowed

earnest phoenix
#

guys i need help

idle scaffold
#

so

#

i need a little help

grim aspen
#

with what

idle scaffold
#

this

idle basalt
#

prob have a zero width space or something

idle scaffold
#

what?

#

im just getting into discord bots

mossy vine
#

can you show your entire json

idle basalt
#

did you copy paste that code from the internet?

mossy vine
#

copypaste it here

idle scaffold
#

{
“token”: “Your Bot Token”
}

#

can i get into a call with you guys

idle basalt
#

looks valid

#

why are the quotes sideways though

#

"token": "bot token"

idle scaffold
#

what?

#

can i get into a call with you @idle basalt

idle basalt
#

why 🤔

idle scaffold
#

because i was gonna ask if you can help me

idle basalt
#
{
  "token": "put your token here"
}```try copy pasting this
idle scaffold
#

my i get your help

#

in a call

idle basalt
#

im not available to call, and whatever problem you have can surely be fixed by text

idle scaffold
#

ok

#

thanks

#

so i have some code set up to say a message at a interval but i dont think its working

idle basalt
#

show the code

idle scaffold
#

k

idle basalt
#

and the error

#

or the unexpected behavior

idle scaffold
#

var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with !
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];

    args = args.splice(1);
    switch(cmd) {
        // !ping
        case 'ping':
            bot.sendMessage({
                to: channelID,
                message: 'Pong!'
            });
        break;
        // Just add any case commands if you want to..
     }
 }

});

#

there really is no error but it wont send the message i want it to its just a test Right now

mossy vine
#

do you even understand that code

idle scaffold
#

i dont really code but i am working on it

grim aspen
#

next time put it in a code block

idle scaffold
#

what?

grim aspen
#
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
    colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
   token: auth.token,
   autorun: true
});
bot.on('ready', function (evt) {
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
    // Our bot needs to know if it will execute a command
    // It will listen for messages that will start with !
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0];

        args = args.splice(1);
        switch(cmd) {
            // !ping
            case 'ping':
                bot.sendMessage({
                    to: channelID,
                    message: 'Pong!'
                });
            break;
            // Just add any case commands if you want to..
         }
     }
});```
idle scaffold
#

how

idle basalt
#

```js
code
```

idle scaffold
#

im just trying to make a simple bot that sends a message at a interval

#

i dont really code

idle basalt
#

are you looking to learn or just do this

idle scaffold
#

just make the interval bot and im done i might get back into it

#

im willing to do a commision thing for the code

idle basalt
#

commission 🤔 im in

idle scaffold
#

how much is your commision

marble needle
#

this is probably not the right place to hire freelancers

idle scaffold
#

but i right am just doing this for a friend

#

@marble needle how so?

idle basalt
#

free lmao i wouldnt charge for something as simple as a message interval bot

idle scaffold
#

oh

#

would you be able to do it?

idle basalt
#

sure

idle scaffold
#

would you be able to make it send mulitiple at intervals of my choosing?

idle basalt
#

slightly more work, but sure

earnest phoenix
modern sable
#

so I've been trying to start a PHP project which requires me to get data from a MySQL database

I've worked with code like this in school and it successfully worked there, however it doesn't work at home and I have no idea why

<?php
$db = new PDO("mysql:host=localhost;dbname=competitive;charset:utf8", 'competitive', '123456');

$id = $_GET["id"];

$sql = 'SELECT * FROM matches WHERE tournamentid = "$id"';

$result = $db -> query($sql);

$row = $result -> fetch(PDO::FETCH_ASSOC);

while($row)
{
  echo("test");

  $row = $result -> fetch (PDO::FETCH_ASSOC);
}
?>```

This code should work but it refuses to do anything

@scarlet bane
scarlet bane
#

test doesn't echo?

modern sable
#

nope

scarlet bane
#

only thing i can think of is that you have no rows

#

that's the only case your code would fail on

#

make sure you spelt your column names / table name right

modern sable
#

actually

#

i think i figured out the main issue

#

but that still doesn't explain anything

scarlet bane
#

💵

modern sable
#

i added a echo to print $sql

#

aaaaand it turned into SELECT * FROM matches WHERE tournamentid = "$id"

scarlet bane
#

inb4 $id isnt valid

#

uh

#

try with double quotes

#

also, you should be escaping your params

#
$sql = "SELECT * FROM matches WHERE tournamentid = '$id'";
modern sable
#

double quotes worked

scarlet bane
#

code works now?

modern sable
#

yup

unique nimbus
#

Epic

scarlet bane
#

nice

unique nimbus
#

I am proud of both of you

scarlet bane
#

you should really escape your params tho, you're begging for an sqlinjection like that

modern sable
#

yeah

I wanted to get basic functionality working just to test and then secure it

scarlet bane
#

i dont really use pdo often (i prefer mysqli cus i use that more)

#

but uh

#
$id = $db->quote($_GET["id"]);
$sql = "SELECT * FROM matches WHERE tournamentid = $id";
#

that should do it

#

notice that on the $sql, i removed the 's, since quote does that for you

modern sable
#

yup

#

thank you blobheart

scarlet bane
#

any time ❤

earnest phoenix
#

php and mysql the two frenemies of leaking data

scarlet bane
#

i have a 500 page book on php&mysql

#

that i got when i was like, 11

#

shit's 🍞

wooden prawn
#

Use PDO prepared statements wherever possible

scarlet bane
#

effort

wooden prawn
#

Not really

scarlet bane
#

using a wrapper for a single file project

#

yikes

wooden prawn
#

Single file project? You know that's what *not my bot is 😛

scarlet bane
wooden prawn
#

not what*

scarlet bane
#

no i mean for marco

wooden prawn
#

I cant english

#

Oh yh

scarlet bane
#

marco's just makin single file api endpoints

#

not worth it to get a wrapper

wooden prawn
#

Ah okay, still worth using PDO tho

unique nimbus
#

I feel sad

wooden prawn
#

Why peter

unique nimbus
idle scaffold
#

any one down to get into a discord call for a quick seconds

earnest phoenix
#

no

#

recheck your syntax

idle scaffold
#

syntax?

earnest phoenix
#

look very carefully

idle scaffold
#

oh

#

shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

i knew that

hushed berry
#

😑

idle scaffold
#

yup

#

im fucked

#

i cant find it

hushed berry
#

srsly?

scarlet bane
#

hint: .

idle scaffold
#

oh

#

i didnt know that im new to coding

mossy vine
#

I suggest you learn javascript properly before trying to make a bot with it

idle scaffold
#

i just need a little help

#

this bot works it just need to be started up

scarlet bane
#

yikes

hushed berry
#

that doesnt look like it "works" to me

mossy vine
#

How did this even happen

west spoke
#

Learn the lang first before making a bot

scarlet bane
#

considering it's doing a .react("?"), i really think you just copied a bot and are trying to run it

#

We don't help with that here

west spoke
#

^

#

^^

idle scaffold
#

i got help out by a guy named @earnest phoenix he just went some where and i need a little help

west spoke
#

...

idle scaffold
#

he is in my testing server so he help out

west spoke
#

Then wait for them to come back...?

idle scaffold
#

i really need this bot up and running

willow marlin
#

Why don't you just learn the JS basics until u start working with a library or something like this?

west spoke
#

^

idle scaffold
#

@scarlet bane what do you mean its doing .React("?")

willow marlin
#

Dude

idle scaffold
#

should i just get rid that line

scarlet bane
#

? is not an emote, you dont know what your code is doing

west spoke
#

xd

idle scaffold
#

i do

scarlet bane
#

You clearly copied this

idle scaffold
#

i didnt

scarlet bane
#

Please stop

idle scaffold
#

there is the og code

west spoke
#

Delete

#

It

idle scaffold
#

all i did was modify it alittle bit

west spoke
#

It has token

#

DELETE THAT IMAGE NOW

unique nimbus
#

delete it

west spoke
#

IM TRYING TO HELP

idle scaffold
#

dude

scarlet bane
#

im so done

unique nimbus
#

Frigid token bad

scarlet bane
#

@modern sable token leak up there

unique nimbus
#

I could use your bot

scarlet bane
#

oh, someone already got it

unique nimbus
#

and yeet

idle basalt
#

its already deleted

scarlet bane
#

my bad marco

west spoke
#

xd

modern sable
#

where Thonk

idle basalt
#

its gone

idle scaffold
#

changed the token

scarlet bane
#

someone already got it

#

my bad

idle basalt
#

regen your token

west spoke
#

:grey_question:

#

@idle scaffold put that in

idle scaffold
#

didnt realise god dammit

west spoke
#

Instead of the '?'

earnest phoenix
#

bruh i gave u working code

west spoke
#

:grey_question:

earnest phoenix
#

u just don't have emoji encoding

west spoke
#

Or

earnest phoenix
#

so it becomes ?

idle scaffold
#

im am exceptionally retarded

west spoke
#

:question:

earnest phoenix
#

isntead of emoji

#

and gives error

west spoke
#

xdd

scarlet bane
#

@earnest phoenix tip 1: don't give code to people

west spoke
#

Try it with unicode symbols

scarlet bane
#

it causes help vampires

#

who dont know anything and just ask for more code

west spoke
#

Ye

#

At least research it

#

Before trying it

earnest phoenix
west spoke
#

YeS

#

@idle scaffold

#

That link

#

And the only reason I use async is because I'm too lazy to translate my code xddddd

earnest phoenix
#

the async in the website is referring to async code

west spoke
#

Ik

earnest phoenix
#

not the lib

west spoke
#

Ooooh ok

scarlet bane
#

we can stop brigading now 👏

earnest phoenix
#

discord is delaying my messages wee

idle scaffold
#

alright im sorry for not knowing the code

west spoke
#

Same cry

idle scaffold
#

i just wanted to make a bot its my first time trying

west spoke
#

Learn the lang first tho

idle scaffold
#

i didnt know that i needed to know Js

west spoke
#

Make a text based game first or sth

idle scaffold
#

sorry

west spoke
#

Nah it's k

idle scaffold
#

i changed the Token

west spoke
#

You just need to leaRn

idle scaffold
#

i know

#

would you like to see the code

#

i removed the token so dont worry

west spoke
#

Don't send token.

#

Edit it

idle scaffold
earnest phoenix
#

thats equivalent of saying "i didnt know i had to learn spanish in order to work in spain"

west spoke
#

Yeah

#

That's copied

earnest phoenix
#

also use hastebin for sharing code

west spoke
#

^

scarlet bane
#

endless loop by for(;;)

west spoke
earnest phoenix
west spoke
#

7th line

#

Copied. Very obviously even

idle basalt
#

i use hasteb.in.. doesnt matter

#

if you dont know what youre doing, then just dont bother

#

either pay someone to make the bot for you, learn the language yourself (this doesnt mean you have to do it alone. you can ask for support, just dont ask to be given free code when you dont have the faintest idea of how it works), or use one of the thousands of public bots

idle scaffold
#

i wanted to make it for a friend im sorry

earnest phoenix
#

.

#

bruh i gave u links just learn it

idle scaffold
#

i know

#

i am right now

scarlet bane
#

nah u gave him code and let him copy

earnest phoenix
#

u can't code without knowing syntax

scarlet bane
#

you're hurting him more than helping him

mossy vine
#

heRES A GREAT GUIDE ABOUT HOW TO CODE ON MO

earnest phoenix
#

its a simple code

#

just an for loop

scarlet bane
#

to you

#

not to someone who has no idea how to program

#

i doubt he even knows what a for loop is

idle basalt
#

why would you use an infinite loop and a promise timeout when you can just use setInterval() lmao

scarlet bane
#

shush

earnest phoenix
#

was testing different ways

idle basalt
#

also why declare ms, min, and sec when you never use any of them

earnest phoenix
#

wAs TeStInG dIfFeReNt WaYs

#

its a 2 minute code

#

not even

idle basalt
#

im just saying its overcomplicated for no reason

#

its whatever

versed pawn
#

?

scarlet bane
#

!!

earnest phoenix
#

wtf

#

use a proper vps

#

problem solved

#

anything is better than glitch

grim aspen
#

use a vps, not glitch, like cry said

scarlet bane
#

you guys assume they know how to use a vps

tawdry pelican
#

I recommend a vps from ionos if you want something simple to use

scenic kelp
#

Yeah right, Ionos. Stay very far away from them, they're pretty shady

quartz kindle
#

Google or amazon are free for 12 months

robust breach
#

in mongoose/mongodb is there a way to check two fields in one query?

#

for ex

#

.find(name) will check the {name:} field of a document and {nickname:}

scenic kelp
#

{field1: condition..., field2: condition...}?

#

.find({field1: condition..., field2: condition...})

robust breach
#

so if field1 doesnt match any itll go to field2?

amber fractal
#

no

#

it'd have to match all of them

#

iirc

scenic kelp
#

I'm assuming it's an AND

#

yeah

robust breach
#

oh is there anyway to check field2 if field1 is false?

#

like

#

how i want it to work is

amber fractal
#

find it, if it doesnt exist find the other field

scenic kelp
#

$or: {..., ...}

robust breach
#

so i have to do two queries?

#

oh wait thats a thing

robust breach
#

tysm

scenic kelp
#

it's called documentation man

amber fractal
#

I dont even use mongodb that much frostpDab

lusty dew
#
    for (let { conf } of Object.values(client.commands)) {
        console.log(conf.guildOnly)
        if (conf.guildOnly && message.channel.type !== "text") {
            return message.reply("That command is a Guild Only command!")
        }
    }
#

Alright

#

ignore the console log with the conf.guildOnly

#

But conf is for some reason undefined.

#

I don't see how or why it would be.

#

Can someone please help me?

scarlet bane
#

perhaps client.commands values do not have a conf attribute

#

or perhaps your for loop format is wrong, i can't tell, im not that good with JS

lusty dew
#

I know it does GWqlabsThonkery

#

I wouldn't be using it if it didn't.

scarlet bane
#

then your loop is weird

lusty dew
#

Don't see how

scarlet bane
#

try with let cmd and cmd.conf

#

and see if that fixes it

#

maybe its not unwrapping properly

lusty dew
#

What?

potent frost
#

oh?

lusty dew
#

Makes no sense to me, how could that fix it?

potent frost
#

@lusty dew do you have an example command?

lusty dew
#

I have a command

potent frost
#

mind posting it?

lusty dew
#

Yea

scarlet bane
#

man what is this newfangled formatting

#

you have function declarations inside of objects without defining keys, you're unpacking inside of a for initializer, what the fuck

lusty dew
#

Hm?

scarlet bane
#
    for (let cmd of Object.values(client.commands)) { 
    let conf=cmd.conf;
        console.log(conf.guildOnly)
        if (conf.guildOnly && message.channel.type !== "text") {
            return message.reply("That command is a Guild Only command!")
        }
    }
potent frost
#

raid

scarlet bane
#

just

potent frost
#

no

scarlet bane
#

thats the only thing i can think of

#

lmao

lusty dew
#

You said you weren't any good at Js

scarlet bane
#

no other part seems wrong

grim aspen
#

you're missing }); on the last line

lusty dew
#

What?

scarlet bane
#

no?

grim aspen
#

shit i missed

scarlet bane
#

xd

grim aspen
#

i need to go die

lusty dew
#

Actually

#

you are missing a );

potent frost
#

client.commands = new Discord.Collection();

lusty dew
#

No

grim aspen
#

🤦

scarlet bane
#

you guys are wacky lmfao

grim aspen
#

that's what i said

#

EXACTLY WHAT I MEANT

lusty dew
#

@potent frost No

scarlet bane
#

@lusty dew try what i did

potent frost
#

OH wait lmao

lusty dew
#

@scarlet bane No

scarlet bane
#

Ok then stop asking for help

lusty dew
#

I don't trust it

scarlet bane
#

¯_(ツ)_/¯

lusty dew
#

You said you was not good at js

scarlet bane
#

I thought you knew how to code JS

#

Why not trust it?

#

Can you not read it?

lusty dew
#

I can.

scarlet bane
#

So use it

#

It seems safe, right?

#

It's not modifying anything, it's not printing your token

#

What's the worst that could happen, it doesnt solve your problem

#

But at least you tried

amber fractal
#

What are you trying to do Thonk

scarlet bane
#

He's trying to unpack a custom object inline inside of a for loop constructor

#

because apparently let cmd of is too low iq

lusty dew
#

This guy is taking what I am saying seriously

#

Lmao

scarlet bane
#

Mate do you want help or not?

#

You're giving everyone here attitude

lusty dew
#

You are the one choosing to have the attitude I am not forcing you too.

amber fractal
#

of is a collection iterator right?

scarlet bane
#

ig

#

Object.values is tripping me out too

#

pretty sure you can do of on the dict

#

but that shouldnt affect anything

amber fractal
#

Then if you wanna loop over commands in a Discord.Collection you can just use of like he said

lusty dew
#
    client.loadCommands = (callback) => {
        client.commands = {}
        fs.readdir('./commands/', (err, files) => {
            if (err) {
                client.log(`Error loading commands : ${err}`)
                return
            }
            files.forEach(file => {
                require(`../commands/${file}`).load(client)
            })
            callback()
        })
    }
scarlet bane
#

So it's an absolutely regular dict

#

not even a Discord.Collection

lusty dew
#

That is how I have client.commands set up

#

Yea

#

I was trying to say that

scarlet bane
#
    for (let cmd of client.commands) { 
    let conf=cmd.conf;
        console.log(conf.guildOnly)
        if (conf.guildOnly && message.channel.type !== "text") {
            return message.reply("That command is a Guild Only command!")
        }
    }
lusty dew
#

but you flipped out

scarlet bane
#

Try that

#

No, you flipped out

lusty dew
#

How did I flip out

scarlet bane
#

"But you dont know JS! I dont trust your code!"

#

lmao

lusty dew
#

I was joking...

scarlet bane
#

Lmfao

lusty dew
#

You guys have no humor

scarlet bane
#

Alright

#

It was just a prank bro

lusty dew
#

Not a prank

#

a joke

scarlet bane
#

Just use the damn code

#

And fix your problem

lusty dew
#

Don't cuss at me

scarlet bane
#

ok gamer

#

good luck with your bot

lusty dew
#

Sorry that I don't like being cussed at.

scarlet bane
#

No i just dont like your attitude, it's very entitled and frankly it's too "jokey" for me

#

Nothing either of us can do about it. Good luck with your bot

potent frost
#

@lusty dew try this

#

and tell me what it returns

#
console.log(Object.values(client.commands))
lusty dew
#

@scarlet bane Doesn't work anyways

#

Thanks for trying though

amber fractal
#

ok ok ok. you're trying to load commands right?

lusty dew
#

No

scarlet bane
#

also, real question

#

why are you iterating through every command

#

when you are responding about "this command"

lusty dew
#

It isn't the only command like that

#

...

#

You guys asked for a example command

#

So I sent one

scarlet bane
#

How do you know your code isn't working?

lusty dew
#

Want me to send every cmd with the GuildOnly thing?

#

When it sends an error

potent frost
#

@lusty dew this is my command layout,

lusty dew
#

and doesn't send the message it is supposed too.

scarlet bane
#

And it sends undefined does not have property guildOnly right

#

as the error

lusty dew
#

Mhm

potent frost
#
module.exports = commandManager.addCommand({
    commandsAlias: ["ping", "clientPing", "pong"],
    configuration: { guild: false, loud: false, nsfw: false},

    description: `gets the bot's ping`,
    commandArguments: ``,
    example: ``,

    runFunction: (args, params, msgObj, speaker, channel, guild, isStaff) => {
        Util.sendEmbed(channel, 'Ping', `PONG! \n ${client.ping}`, Util.makeEmbedFooter(speaker), null, Colors.Orange, null);
    },
});```
lusty dew
#

I even console logged conf

#

and it was undefined

amber fractal
#

if(!conf) return

scarlet bane
#

What does m9's snippet say

lusty dew
#

I had

scarlet bane
#
console.log(Object.values(client.commands))
#

put that in front of your loop, what's it respond with

lusty dew
#

if(!conf) {continue}

#

The values

#

client.commands has

scarlet bane
#

with conf and everything?

lusty dew
#

conf and everything inside of conf

scarlet bane
#

hm

#

in my snippet, what if you did console.log(cmd)

lusty dew
#

undefined

scarlet bane
#
    for (let cmd of client.commands) { 
        let conf=cmd.conf;
    console.log(cmd)
        console.log(conf.guildOnly)
        if (conf.guildOnly && message.channel.type !== "text") {
            return message.reply("That command is a Guild Only command!")
        }
    }
#

like that

#

Cmd is undefined?

lusty dew
#

Oh no

#

(node:7248) UnhandledPromiseRejectionWarning: TypeError: client.commands is not iterable

#

This was the erorr

scarlet bane
#

uHH

lusty dew
#

with your code

#

error*

scarlet bane
#

But i thought client.commands was a regular dict??

lusty dew
#

You can't itterate over an object iirc

#

or can you?

scarlet bane
#

you can

amber fractal
#

you can

scarlet bane
#

afaik

inner jewel
#

nope

#

you can use for ... in ...

lusty dew
#

but not of?

inner jewel
#

but not for ... of ...

lusty dew
#

Yea

#

What I though.

#

thought*

#

but wouldn't in just return the number of values?

#

and not hte value itself?

#

or am I wrong?

scarlet bane
amber fractal
#

use in for that then

scarlet bane
#

steven pls

amber fractal
#

?

scarlet bane
#
    for (let cmd of Object.values(client.commands)) { 
        let conf=cmd.conf;
    console.log(cmd)
        console.log(conf.guildOnly)
        if (conf.guildOnly && message.channel.type !== "text") {
            return message.reply("That command is a Guild Only command!")
        }
    }
#

try that then, my bad

#

could've sworn of lets you iterate dicts

amber fractal
#

I'm confused at why you said steven pls tho

lusty dew
#

I thoguth so at first as well.

scarlet bane
#

thats not even using an of at all xd @amber fractal

amber fractal
#

Yes

#

because of doesnt do that

#
scarlet bane
#

@lusty dew any luck with that one

lusty dew
#

That is what got console logged with

#

conf.guildOnly

#

or cmd

scarlet bane
#

yikes

lusty dew
#

Actually

scarlet bane
#

how come your confs dont have guildOnly in here

lusty dew
#

I think it is both

#

Oh shit

scarlet bane
#

this doesnt even

lusty dew
#

I forgot to do it in the beta bot

#

xD

scarlet bane
lusty dew
#

Let me actually go do that

scarlet bane
#

yikes

amber fractal
#

but why do that Thonk

scarlet bane
#

idk

#

to save that one line of code ig

lusty dew
#

Ok

#

It works in dms

#

but in server

#

it errors

#

It tells them they must use cmd in server and I tried to use cmd in server and I got errors

scarlet bane
#

what errors

amber fractal
#

so I'm assuming that you only want some commands to work in a dm channel then?

lusty dew
#

Oh wait

amber fractal
#

I'm a little behind

lusty dew
#

Yea

amber fractal
lusty dew
#

I do

#

and I think I know the problem

#

oof

#

I forgot to add if(!conf) {continue}

#

so it is checking all cmd files

#

and there is one file that has admin instead of conf

#

so it doesnt have guildOnly in it

#

Hopefully it works now :p

#

Ayyy it worked.

#

Thaks @amber fractal and @scarlet bane

#

thanks*

#

god my grammar

scarlet bane
#

👏 np

lusty dew
#

Question though.

#

I have this idea for a command but idk how to go about doing it.

#

You know the bot Yggisdral or however you say it

#

It has the userphone cmd

#

I wanted to do that

#

but people could mention the person they wanted to talk too.

#

and their names would be anon and it would happen in dms.

#

The bot would dm each other their messages to the other person.

#

Any tips on how to do that?

#

What I would use and such?

scarlet bane
#

a dict mapping userids together and a message event handler that pushes one dm to another person and vice-versa if they're in the dict

lusty dew
#

Hm

#

Ok

amber fractal
#

wow I spent like 10 mins trying to make it work in dms just for him to say it worked lmfao

#

I didnt realize he fixed it

#

oh well

#

time to revert

lusty dew
#

xD

#

Tarpergon

#

It's fine

#

you would have helped alot anyway

#

:3

amber fractal
#

but it worked

#

with 1 line

scarlet bane
#

did you make an entire new application just to test his theory

amber fractal
#

no

scarlet bane
#

Guild Lock

amber fractal
#

That's why it took so long, I had to modify my original one to work outside guilds

#

It's something I'm working on

scarlet bane
#

oh ok

amber fractal
#

COnvient name Lmao

#

I was bored so I started working on a mod bot lmao

#

I need to stop saying lmao and leave the developer channel

#

👋

lusty dew
#

Lol

#

Hm

#

Wrong thing

#

Yeet

#

I am not working on that yet

#

UwU

idle scaffold
#

so any hints on how to start learning java

coral trellis
#

Search on google

#

"How to learn Java"

lusty dew
#

^

golden vector
#

anyone know why my start script isnt working?

#
{
  "name": "RB",
  "author": "Miko E.",
  "main": "bot.js",
  "version": "1.3.0-beta.5",
  "scripts": {
    "start": "node bot.js"
  },
  "dependencies": {
    "discord.js": "^11.3.0",
    "fstorm": "^0.1.3",
    "jimp": "^0.2.28",
    "valid-url": "^1.0.9"
  }
}
#

it works at start

#

but fails when it tries to reboot

#

what im saying is any know the best way to reboot WITHOUT crashing?

earnest phoenix
#

how to fix it?

    let uptime_embed=new Discord.RichEmbed()
        .setColor('RANDOM')
        .addField('Uptime: `'+days+dayText+hrs+':'+min+':'+sec+'`')
        .setTimestamp(new Date())
    return uptime_embed
#

undefined

bright spear
#

@earnest phoenix you gave a field title but not the content

#

so the content is undefined

golden vector
#

can someone help me tho

#
{
  "name": "RB",
  "author": "Miko E.",
  "main": "bot.js",
  "version": "1.3.0-beta.5",
  "scripts": {
    "start": "node bot.js"
  },
  "dependencies": {
    "discord.js": "^11.3.0",
    "fstorm": "^0.1.3",
    "jimp": "^0.2.28",
    "valid-url": "^1.0.9"
  }
}

my reboot doesn't work

bright spear
#

yes you already sent that

idle basalt
#

depends how youre rebooting

#

if youre killing the process, you need to be running the bot with something like pm2 that will auto-restart

golden vector
#

no it just dies

bright spear
#

nobody responded because nobody really knew how to help

sinful lotus
#

pm2 + process.exit()

brazen quartz
#

I am trying to manipulate json data from my postgres database using knexjs, if anyone understand what I just said and thinks they could help @ or dm me

earnest phoenix
#

ask

#

i've used postres alongside knex

#

@brazen quartz

brazen quartz
#

I just am having trouble trying to store an array in postgres

#

I've figured out I probably use json/jsonb and that arrays are native to json so they sorta just work together, but anytime I try manipulate the array and post it back to postgres through knex it doesnt do what I'd expect

earnest phoenix
#

are you storing an actual json string to the db?

brazen quartz
#

for example, im trying to store an array of a bunch of user ids, so to begin with its just []
I then try .push the id to a variable I made = the json value from db, but checking my db it just return [1]

#

I've tried JSON.stringify and all that, idk im probably just a little confused on how to properly format it

earnest phoenix
#

i was about to ask

#

you need to stringify it first