#development

1 messages · Page 712 of 1

jaunty stump
#

I'll try that out

#

so far still access denied

jaunty stump
#

If anyone has a better way to do discord marriages please let me know as anything is helpful.

quartz kindle
#

just use an embedded database like sqlite

jaunty stump
#

how would I do that and implement it into my code
Like I said. I never have messed with database stuff and SQL stuff

true basin
#

Any idea regarding making a bot auto-detect selfbots?

west spoke
#

just use altdefender

true basin
#

Altdefender?

warm marsh
#

Using the Discord API is there a way to change the expires_in of a access_token?

true basin
#

I’m trying to make my own auto-moderator bot, lol.

warm marsh
#

Check user response time with message length?

west spoke
#

^ and/or check status changes, nickname changes, time between messages, etc

jaunty stump
#

I am just gonna not do anything with SQL anymore as it is just way to out of my range and I don't have time for it.

#

nothing is working

cobalt umbra
#

Big oof

jaunty stump
#

Like I want to pull my hair out

warm marsh
#

Just do it?

cobalt umbra
#

What's so hard?

near ether
#

Hey guys, I’m having an issue where my bot ends up DM’ing the wrong people even though my code explicitly does not allow for this to happen

jaunty stump
#

discord marriages and setting up a SQL database for it and having it work without giving me an access denied error

near ether
#

Like, the command takes two users and immediately DM’s them yet somehow some random user who uses the same command around the same time may receive a DM meant for someone else

cobalt umbra
#

Because you coded it that way review the code

#

What is discord marriage

jaunty stump
#

someone does a command like +marry @granite pagoda and then it "gets them married" or something like that

cobalt umbra
#

Only one mariage or multiple allowed

west spoke
jaunty stump
#

should just be one allowed per person

cobalt umbra
#

Idk seems easy, just have column man and column wife and store user ids

jaunty stump
#

I have never done anything with SQL before

#

is the twist

cobalt umbra
#

I could help but on mobile so rip

near ether
#

I have extensively, basically it works like

‘;fight @earnest phoenix’

And the bot will DM the person who wrote the command, and the person who was mentioned.

The code just immediately DM’s them using ‘user.createDM()’ and ends the command. How could it be sending messages to the wrong people if everything is taken care of in a single call?

late hill
#

show code

near ether
#

Ok, hold on a second

quartz kindle
#

@near ether you are probably using global variables accidentally

earnest phoenix
#

Hello

#

I was wondering if I could make it so doing ;addtochannel <member> would give that member access to read the channel

#

how would I go about doing this?

harsh nova
#

permission overwrite

earnest phoenix
#

I searched (ChannelUpdate) and ChannelEdit in d js docs and I couldn't find i

near ether
#

`currentTurnPlayerDM = await challenger.createDM();
opponentDM = await opponent.createDM();

let responseEmbed = new DiscordJS.RichEmbed();
responseEmbed
.setAuthor(opponent.tag, opponent.avatarURL)
.setTitle(Choose your move!)
.setColor("#fff000")

currentTurnPlayerDM.send(responseEmbed)`

earnest phoenix
#

because you don't know how to use docs

near ether
#

indent is messed up in discord but in the code its fine

#

js btw

earnest phoenix
#

ok...?

near ether
#

meant for @quartz kindle and @cobalt umbra (sorry for ping)

earnest phoenix
#

is there anyway to avoid checking a == 0 || b == 0 twice ?

#

store the boolean returned in a variable

#

ah i see

quartz kindle
#

are you defining those anywhere else? using var/const/let

#

if not, then those are global variables

#

and will be affected by multple users using it at the same time

earnest phoenix
#

hmm maybe if i drop the ``` printf("invalid input received");````

near ether
#

oops

#

one sec

#

ok i do not have var/const/let

#

written before their declaration

quartz kindle
#

so thats probably your problem

#

try using let

near ether
#

okay, thank you my dude!

quartz kindle
#

let ensures they are locked to the current scope

near ether
#

would you mind explaining/sending a link to why not having one of those prefixes leads to the creation of a global variable?

earnest phoenix
#

@earnest phoenix do you think it's possible ?

near ether
#

If not that’s totally fine

#

Just wondering so I could learn from this

quartz kindle
#

when you declare a variable using var/let/const, it will be created in the current scope
if you omit that prefix, it will attempt to find and modify an existing variable with the same name

#

falling back to the global scope if no variable exists

near ether
#

I see

#

Thank you for the explanation!

earnest phoenix
#

how do i prevent scanf from overflowing

valid frigate
#

it's not preventing my app from running or anything

#

it's just really odd since i'm catching errors and it's not an unhandled one

valid frigate
#

ok if this were github id probably comment something like "i'm retarded" but the issue was my logger logging every single error LUL

earnest phoenix
shy rose
#

@valid frigate your just printing error.stack and not error.message

haughty mica
#

alright so

#

i’ve been trying to make a balance command using discord.js

#

but can’t get one that works

#

does anyone know one that i could use?

sick cloud
#

fetch the user's amount from your db and show it

#

not that hard

valid frigate
#

lol chewey

#

i was using a custom error that didn't pass message pogey

#

dw it's all good now

dark oak
#

I am trying to pull the users the bot is working for, but I am getting errors. How to do it?

#

I tried with client.users.size which is not correct.

cobalt umbra
#

wym not correct @dark oak

dark oak
#

It’s inaccurate

grim aspen
#

client.users.size has a system called cache

cobalt umbra
#

"Without the client option fetchAllMembers you will not automatically cache all users in all guilds. Your cache will gradually fill up over time."

dark oak
#

Ok. I’ll try like that now

cobalt umbra
balmy lantern
#

How do i make a good support server?

cobalt umbra
#

Channel for help, channel for suggestions, channel for logging updates, general channel. I don't see what more is needed

balmy lantern
#

Solid
I was gonna do a faq

cobalt umbra
#

yea that too. I have that as a bot command but can come in handy to have too. Good idea I'll add it to my guild zoomeyes

dusky marsh
#

Is there a point to using a sharding manager as opposed to internal sharding?

oak tide
#

module.exports = {
  "help":{
    "name":"rebus"
  },
  run: async (bot, message, args) => {
   const qa = [
    ["https://www2.stetson.edu/~efriedma/puzzle/rebus/1.gif", "Tester"]
];
    var rand = (Math.random() * answers.length);
    var question = qa[rand][0];
    var answer = qa[rand][1];
    var embed = new discord.RichEmbed();
    embed = embed.setTitle("Rebus Puzzle").setImage(question).setDescription(answer).setColor("#02fa4d").setFooter("Ice Cream - Made by BiggestPotato");
    message.channel.send(embed);
  }
};```

```ReferenceError: answers is not defined
    at Object.run (C:\Users\BiggestPotato\Desktop\Corebot (5) - Copy\commands\rebus-wip.js:11:33)
    at C:\Users\BiggestPotato\Desktop\Corebot (5) - Copy\index.js:388:33
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)```How do I fix this?
sudden geyser
#

have you considered defining it

twilit rapids
#

You define answer after you use it

#
var rand = (Math.random() * answers.length);
    var question = qa[rand][0];
    var answer = qa[rand][1];
sudden geyser
#

answer is not the same as answers too btw

earnest phoenix
#

is there a way to announce all the servers that the bot will go onder maintenance for 2-3 days starting the day etc?

warm marsh
#

Yea but it's not a good idea, Just set the bots status.

#

Presence*

earnest phoenix
#

well I can't do that to take out the helper command

green kestrel
#

so, ive seen a mention thats like <@nnnn> where nnnn is a user id

#

what's a mention like this for? <:aNgErY:514287724031639582>

#

saw it in my debug screen

#

ive also seen a mention that starts like: <!@nnnn>

#

is it a server specific avatar?

slender thistle
#

That's custom emotes

green kestrel
#

ah ok, thought so after looking at it some more

late hill
#

and <!@userid> is a nicknamed user

heavy void
#

Can anyone help me? I'm having a problem with translate command, the error says 403 Forbidden. Here's my code

knotty steeple
#

can u just upload to hastebin pls

heavy void
#

Bruh

#

U can just install and review it

knotty steeple
#

yea but im not doing that

#

so

heavy void
#

k

knotty steeple
#

good luck with help tho

west raptor
#

@heavy void the variable text holds one string so if you were to run translate hello I want to translate this text en jp text = hello

#

kinda hard to explain but it's how you parse args

heavy void
#

Yeah, I'll just do const text = args.slice(2).join(' ');

#

So do u have any idea why the error says 403 Forbidden?

west raptor
#

incorrect key?

#

not sure

heavy void
#

I already put my api key there

bronze salmon
#

Forbidden means it cannot authenticate, an invalid key would be 400 i believe

mossy vine
#

401 iirc

bronze salmon
#

just checked, invalid key is 400

mossy vine
#

oh

#

i thuoght its bad request

bronze salmon
#

it is``` "code" : 400,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Bad Request",
"reason" : "keyInvalid"
} ],
"message" : "Bad Request"

mossy vine
bronze salmon
#

"Invalid key" is a part of "Bad Request"

heavy void
#

What key do I need to put

#

Still the google api key?

bronze salmon
#

for what are you trying to use it?

heavy void
#

Translate ^

bronze salmon
#

lemme check

heavy void
#

I put my google api key but still says 403 Forbidden

bronze salmon
#

interesting

#

did you enable the translate API in the google developer console?

heavy void
#

Yes

bronze salmon
#

then I dont know

#

can you send the whole log output?

heavy void
#

DMs cause I need to sleep in 5 minutes

opaque spear
#

wag1

earnest phoenix
#

my bot doesn't work if the prefix is larger than 1 character

sudden geyser
#

check if the command exists first

earnest phoenix
#

it exists

sudden geyser
#

not what I mean

#

but you could slice by the length of prefix

earnest phoenix
#

🤔

#

yhx u

#

*thx u

prime shell
#

HOLA

sudden geyser
#

hello

grim aspen
#

?

#

@twilit rapids possible shitposting?

twilit rapids
#

yeah

marsh frost
#

Y'all should make a Development category, and separate the languages into channels.
JS, Java, Python, Other.

mossy vine
#

unnecessary imo

marsh frost
#

Unnecessary for JS devs, sure.

mossy vine
#

yikes here we go with the language wars

#

channels would often be unused

#

what channel would you put something like 'hi can anyone help me with api design'

marsh frost
#

How is it a war? I'm just saying most use JS, I enjoy giving a hand with Java. The posts get swallowed up though.

mossy vine
#

then you can either directly contact someone who knows java or ask in java related servers

slender thistle
#

DBL is full of people who don't care what channel they're in

mossy vine
#

yeah, look at the people who advertise in #topgg-api

marsh frost
#

So there's my point Cyber, Why do Java devs have to ask in a different server but JS devs get plenty of assitance here.

mossy vine
#

because js is more widely used

#

there are no rules against asking java questions in this channel

slender thistle
#

Most people here use JS but you are always welcome to help anyone who codes in Java (even though there aren't many Java questions here overall)

mossy vine
#

in fact there are quite a few people who could help with it

marsh frost
#

I'm not asking for help. I'm saying I'd like to help in this server, as I do in others.

#

But the Java questions I see in here go unanswered and by the time I see them, they are too far up.

#

Generally speaking of course.

mossy vine
#

then you can ping the person who asked and provide an answer

slender thistle
#

While that might look convenient, the way of moderating those channels will be far worse than it already is

sudden geyser
#

or you could just go in discord-api

marsh frost
#

Lol moderating a discord is hard work 🙄

#

It's a couple extra channels.

slender thistle
#

Depends on how many exactly we're talking

marsh frost
#

As I said, four.

#

Really just three new ones, as this one would be eliminated.

mossy vine
#

is java really that widely used for discord bots as js and python

marsh frost
#

No, not as widely used, but it's a great solution. I'd like to have more people use it.

amber fractal
#

@mossy vine no

mossy vine
#

so having a channel for java help = more people using java or am i completely missing the point

marsh frost
#

Yep.

#

Anyone who comes here new, would see the dev chat and just assume JS is the only way to go.

amber fractal
#

That's mostly false but yeah.

marsh frost
#

🙄

#

On what basis is that false lol

slender thistle
#

k3llyShrug that'd not be too many new channels, I agree. However, DBL community isn't really that smart overall when it comes to stuff like this.
Like I said before, #topgg-api is a good example. And DBL isn't really mainly for help with bot development, either.

marsh frost
#

So shouldnt we try to better the community and offer real help, not spoonfeed ?

#

JS is all spoonfed.

slender thistle
#

Also some people might still believe that Java is the same as JavaScript at some point, soooooo

marsh frost
mossy vine
#

yikes

marsh frost
#

So having two channels would help that notion I guess? lol.

#

Is there people who think that?

slender thistle
#

Definitely there will always be people like that

marsh frost
#

oof.

slender thistle
#

As quarter/half the bots listed on DBL are made with bot makers or are copies of public bots

marsh frost
#

Anyway, you say dbl community isn't that smart. Segregating channels would be a good way to help with that. As I said, I love using Java as a solution due to it being a full-featured OOP language.

#

Learning how to use a language that uses OOP is a great stepping stone for people.

mossy vine
#

no language wars here nah

marsh frost
#

no not at all. You literally just get asshurt every time someone talks about pros and cons

#

😢

#

Where am I insisting a language war?

As I said, I love using Java as a solution due to it being a full-featured OOP language.
Learning how to use a language that uses OOP is a great stepping stone for people.

slender thistle
#

k3llyShrug Not really sure about the segregating channels tbh. Might work out. Only one way to find out, but then again, I'm just some fucking guy.

marsh frost
#

We're all just some guy haha

mossy vine
#

you say js is all spoonfeed and start praising java. idk im pretty salty rn

marsh frost
#

Im just some guy making a suggestion

#

You seem salty af

#

Generally JS resources are spoonfed. Is that out of line to say?

#

It's true.

mossy vine
#

no, i mostly agree

marsh frost
#

So why are you disagreeing?

slender thistle
#

I'd like to put my 5 cents in but I'm python bloblul

mossy vine
#

its not all spoonfeed by a long shot

marsh frost
#

Go to #python-development @slender thistle !

#

oh wait.

#

No of course not Cyber.

#

No one said that.

mossy vine
#

nope

marsh frost
#

JS Bots are mostly spoonfed info

#

There, does that wording make you happy?

mossy vine
#

sure

slender thistle
#

Eh, I personally wouldn't use that channel much as there isn't that many py devs in DBL who need help with it.
People could get salty seeing a help channel for one lang but not for the other, which could lead to fair fuckshow of itself, imo. chadthonk

#

And creating many help channels isn't something a bot list really needs

earnest phoenix
#

😳

marsh frost
#

eh

#

Back to my cave

earnest phoenix
#

ooka ooka

slender thistle
#

Sounds like a suggestion that might've worked out if DBL community wasn't salty about everything

marsh frost
mossy vine
#

yes but we are salty about absolutely everything

marsh frost
#

Apparently

slender thistle
#

Exactly mmulu

marsh frost
#

How does that advance the knowledge of a community.

slender thistle
#

¯_(ツ)_/¯

amber fractal
#

Tfw you assume most js bots are spoonfed, but disregard every bot that isn't spoonfed because you are attempting to show that java is better than js, which is an opinion.

marsh frost
#

^ more salt. I never once said Java is better.

#

JS is a wonderful language

earnest phoenix
#

you definitely acted like it

marsh frost
#

It is the future.

#

But Java is a great development stepping stone.

mossy vine
#

js is the future? we are fucked

green kestrel
#

real developers write discord bots in C++. ducks

marsh frost
#

JS is the future, yes. Fullstack development is taking the world by storm.

green kestrel
#

today i learned, the big two, dyno and mee6, are written in javascript/node.js

late hill
#

You're suggesting to have multiple channels because certain languages aren't used as much meaning those kind of questions can end up getting burried, that logic means all unpopular languages would require a channel? That's a lot of channels, no?

green kestrel
#

im often surprised at the scalability of node

marsh frost
#

no. I said JS, Java, Python, and Other Languages.

late hill
#

If this server was aimed at being some kind of development help server it would make sense to do something like that

#

On here, meh.

green kestrel
#

it might make sense to consider different channels for different libraries and/or languages, until you realise the js and C# ones would be rammed, and the rest would be ghost towns. i'd be all alone in the perl and php ones.

mossy vine
#

actually, mee6 uses a variety of languages for different purposes

marsh frost
#

Why not aim to be as inclusive as a community as you can be?

#

Libraries would be too many Brain, Java alone has three major ones.

green kestrel
#

@mossy vine im using two languages, as i have a backend and frontend process

earnest phoenix
#

There is a discord.js support server afaik

#

so

#

just go there

green kestrel
#

it lets me update the bot with no visual impression of downtime

earnest phoenix
#

same with other languages

#

find a server for em

#

ez

marsh frost
#

Okay Ricochet, then lets close this channel

earnest phoenix
#

ok

late hill
#

There's a big difference between 1 channel and 10?

marsh frost
#

Why have it at all by that logic

late hill
#

😂

earnest phoenix
#

you don't even know what you are saying now lmao

green kestrel
#

1 channel = manageable... 10 channels = an admin/moderation nightmare

earnest phoenix
#

^

#

it's not like it's easy to moderate

late hill
#

I've asked questions about java in this channel

earnest phoenix
#

they get tons of funky people

late hill
#

And have always gotten a reply

#

It just took a little longer than my JavaScript questions

green kestrel
#

i think ive only ever asked generic api questions

earnest phoenix
#

I've asked a few questions here

#

I always make sure to look up something before I ask it

green kestrel
#

my problem is ive chosen a broken and unmaintained api and decided to fix it, because its lightweight and simple

slender thistle
#

Sit down you masochist

green kestrel
#

so im less asking "how do i do X in api" as to "the code i have is sending X, should it send Y"?

#

@slender thistle shhh, i like pain

#

🤣

earnest phoenix
#

just make your own api 😎

green kestrel
#

why else would i be using perl if i didnt like to hurt myself daily

#

😄

sinful lotus
#

node is great tbh

green kestrel
#

by the time im done, what i have will basically be my own library fork

sinful lotus
#

code your thing efficiently and you can run 20k guilds in a single node process

#

I'm running 15k guilds per node process rn

#

Usually I use js because it isn't strict, kinda faster to code

green kestrel
#

@sinful lotus you can, but should you? isnt that why we have sharding?

sinful lotus
#

4 process 61 shards 👀

green kestrel
#

\o/

earnest phoenix
#

make it 69 shards 😎

sinful lotus
#

Less process = Less Ram Overhead

#

even node is great, spawning a new process costs more memory

#

specially with duplicates on your cache

#

you know the thing

#

so I run as less as possible

lunar crystal
#

What dbl mean ?

sinful lotus
earnest phoenix
#

discord bot list

green kestrel
#

i once wrote a C++ server program that worked a bit like node does... years before node was a thing. people said 'it will never scale', it did, very well, which is why i'd never knock node's performance

#

it's all about socket engines and non blocking multiplexing imho

lunar crystal
#

Ok

sinful lotus
#

there is node.js limitations

#

but you dont run heavy cpu workload on JS engine

green kestrel
#

you have a lot of ram on your server

#

yeah i'd offload it to a queue in an sql database and batch it out to something else

sinful lotus
#

as long as your code is async, your event loop will usually be ready to handle the next process

#

Yes, doing cpu intensive applications on node.js is where node.js do not excell

#

but offloading it in another process or probably "programming language" and just use node to serve or parse it

#

its fine

green kestrel
#

my dev server has 16gb ram, and jira is taking half of it

#

i'm considering moving my bot to my live server now, it has 16gb too but more of its free, and a much faster connection

sinful lotus
#

I got 3 dedicated
one with 40 cores and 32gb of ram
one with 16 cores and 24gb (that server)
one with 8 cores and 16gb of ram

#

the 40 cores is sponsored so I just pay the 2 below

green kestrel
#

sponsorships lucky you, i pay £70 a month for my own dedicated server at OVH

#

im thinking of getting shot of it and downgrading to a £30 a month at digitalocean

sinful lotus
#

its a home based server

#

so the uptime isnt perfect

green kestrel
#

for dev i had a dell T310 in my utility cupboard at home

sinful lotus
#

like for ex: when their power gets cut or etc

#

but internet wise

#

its a 1gbps verizon fios

#

so I use it as our main music node

marsh frost
#

Do companies not do colocation anymore?

sinful lotus
#

the sponsor ship I have is not from a company

#

its an individual person

#

its his personal server

#

and he dedicated half of it to us

#

although we share 1 ip so I always ask him to open ports

#

thats why I have 2 other dedi servers

#

so if I need to open a service or port

#

it would be hassle free

marsh frost
#

Yeah I mean, used to, you could rent space from dedi providers with YOUR hardware.

#

So you basically just pay for reliable power/internet.

sinful lotus
#

or if you want if you have capable internet at your house but with dynamic or cgnat ip, you can buy a cheap bandwith sufficient vps and use ssh tunnel

#

so you can host webservers from your home

sinful lotus
#

I just rent premade dedicated

#

usually those are cheaper than colocation

marsh frost
#

Oh that's a pretty good solution to get around dynIPs

sinful lotus
#

yes since I usually ssh tunnel from my router

#

so our whole home network would get routed

#

and goodbye cgnat ip from my provider

marsh frost
#

Not bad

green kestrel
#

colocation is a pain in the bum

sinful lotus
#

because in reality, buying a static ip is more expensive than renting a cheap vps in my place

green kestrel
#

you have to purchase hardware, in the event of a raid degredation you have to drive to the dc with new disks

marsh frost
#

I live in the country and my internet is unreliable as all hell.
I have a 20' antenna in my backyard running to a 4g modem with a t-mobil simcard in it lol.
I couldn't host anything.

green kestrel
#

and youre responsible for installing it etc

sinful lotus
#

I recently got fiber, 25/25 for 25 dollars

green kestrel
#

it makes more sense to rent a dedi

sinful lotus
#

with a cgnat ip

green kestrel
#

ew. cgnat.

sinful lotus
#

speed wise its reliable at least

#

but I hate cgnat

#

thats why I have ssh tunnel

marsh frost
#

I'd kill for 25/25 lmao

sinful lotus
#

we are lucky they expanded on our place

#

so now I use my laptop to ssh tunnel to my server

#

and host things on my laptop

green kestrel
#

theres some pics of my home server

marsh frost
#

But you're still limited to 25/25 lol.

green kestrel
#

it sits in a utility cupboard above the washing machine and freezer connected to 110mbit down, 15mbit up internet

sinful lotus
#

better than having a cgnat ip

green kestrel
#

cgnat is arse

sinful lotus
#

on cgnat I get blocked on some website I love to visit

#

cause they thought im a BoT

marsh frost
#

I don't have to deal with it being on a mobilke network AFAIK.

#

Everytime my modem restarts I have a new ip though >.>

#

Have to rewhitelist myself to my servers

#

PITA.

sinful lotus
#

I believe mobile networks widely use cgnat, but when you restart your connection, it connects you to other cgnat system

#

so you get a new public ip

#

while on my fiber, even I restart it, Im stuck on the same internal ip and public ip

marsh frost
#

I havent seen fiber being sold with speeds that low around here.

#

Usually fiber starts at 100mbps in the states

sinful lotus
#

while 25 mbps for 25 dollars is the best deal you can get in my place

#

the big telcos charge 30 dollars for 5 mbps in my place

marsh frost
#

What country do you live in?

sinful lotus
#

🇵🇭

marsh frost
#

yikes.

sinful lotus
#

Thats why dont develop anything here

#

and use our internet to host it

slim heart
#

in mongo is it possible just to say if something exists at all? cuz like atm i just have to fetch all and filter as such, the issue is its just an object with different values so i cant tell if it exists or not but i can filter by values which is annoying

#

so like rn i have to do js (await client.database.collection('map').find({}).toArray()).filter(x=>x.city)

hushed berry
#

@slim heart yeah Thonk

slim heart
#

i found a {city: {$exists: true}}

#

yeah

west spoke
#

I read that as sexists help me

jade thistle
#

time to turn you into a computer so you know the difference of S and $ better.

#

neuralink isnt that far away

west spoke
#

Neuralink is most likely not going to be compatible with me.

jade thistle
#

we didnt try yet

west spoke
#

The fact I'm not completely hooman

#

may fuck with it

mossy vine
#

what would be the best way to reward users for chatting but also discourage spamming?

west spoke
#

delay between rewards and spamming their dms if they spam

#

easy

mossy vine
#

i was thinking decreasing reward amount if they spam

#

would that work perhaps?

jade thistle
#

make an exp system but the more posts a day the less exp they get

west spoke
mossy vine
#

hmm

marsh frost
#

xp/msg but not more than 1 xp grant/min and not more than 30 xp grants/hr

sage bobcat
#

One message removed from a suspended account.

eternal mesa
#

thats pretty vague lmao

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

eternal mesa
#

have you tried debugging your code

#

add log statements

#

see if it is reaching parts in your code as you think it should be

sage bobcat
#

One message removed from a suspended account.

eternal mesa
#

i dont know what that means

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

Basically when you do the command it doesn't respond, there is no error in terminal

#

@sage bobcat Have you done a .catch to it

#

if that is the way it works

eternal mesa
#

i mean i dont even know how your command handling works

#

so i cant really help

sage bobcat
#

One message removed from a suspended account.

eternal mesa
#

well is it custom

#

that just shows a message that says a file has loaded

sage bobcat
#

One message removed from a suspended account.

eternal mesa
#

send the repo ill take a look

sage bobcat
#

One message removed from a suspended account.

eternal mesa
#

so i would add log statements to your on message event

#

for example

#

if (!message.content.startsWith(prefix)) return;

#

prefix is not defined at this point

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

eternal mesa
#

i would still add log statements

#

see if you are getting the right values for things

#

at least that is what i would do

west spoke
#
                      await channel.send(file=discord.File('nekos/' + str(neko2) + '.png'))```
#

Am I doing something wrong GWgoaSadness

eternal mesa
#

@west spoke how large is the file you are trying to send

west spoke
#

Lemme check

#

I mean

#

If I'm able to send without nitro

#

8.48mb @eternal mesa

peak bloom
#

that image you just sent is <1mb

west spoke
#

Same image

peak bloom
#

perhaps however you're uploading is compressing it somehow

#

but your bot is trying to upload it raw, and it's too large

#

shrink it below 8mb on disk

west spoke
#

aigjt

#

aight

#

I mean

#

It can do gif files though

#

And those are more than the png

peak bloom
#

doesn't matter what it is as long as it's <8mb

west spoke
eternal mesa
#

i dont really know in this specific situation what is happening

#

but the limit is 8mb

west spoke
#

Ah oke

#

There is a way to limit size in the cdn isnt there?

#

Like ?size=x

amber fractal
#

You can up the limit for nitro boosted servers

#

the cdn I may be missing some context, which cdn? Discords?

west spoke
#

Yes

#

Tbh I could just make some checks with it.

amber fractal
#

Well if you catch exceptions, on a 413, you can error out with a message like "File too large" or you can do checks beforehand.

#

Or if these photos are accessible through a website, like if you have your own cdn, you can post the link, it just wont embed.

slender thistle
#

@west spoke Isn't that >8 MB

earnest phoenix
#

but the limit is 8mb
well yes, but no

#

the limit is 100mb

#

it's just locked

#

by boosting perks

west spoke
#

^

#

God I love redoing every command from scratch

quartz kindle
#

why do you need it do be 3000x4000 lol

earnest phoenix
#

at that point you can use waifu2x

west spoke
#

Who said 3000x4000

sick comet
#

help

west spoke
#

ask2ask

sick comet
#
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  10.x
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 10.x...
       Downloading and installing node 10.16.3...
       Using default npm version: 6.9.0
       
-----> Restoring cache
       - node_modules
       
-----> Installing dependencies
       Installing node modules (package.json + package-lock)
       audited 140 packages in 1.345s
       found 0 vulnerabilities
       
       
-----> Build
       Running build
       
       > discord-bot@1.1.2 build /tmp/build_23ba1adc7ef26e60fb447e95ca413f5b
       > my-framework build --output public
       
sh: 1: my-framework: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! discord-bot@1.1.2 build: `my-framework build --output public`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the discord-bot@1.1.2 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.wOib6/_logs/2019-10-14T15_40_44_398Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed```
#

I'm trying to deploy but its not working

mossy vine
#

sh: 1: my-framework: not found

sick comet
#

what is that?

mossy vine
#

that repo is private or doesnt exist

#

also how do you not know what it is

sick cloud
#

is it better to write docs as you dev or at the end

heavy marsh
#

Discord.js trying to see if words rhyme if not delete - https://www.npmjs.com/package/rhyme-plus#rdorhymeword1-word2

**My code **

//Check Rhymes
const rhyme = require('rhyme-plus');

client.on('ready', () => {
    const channel = client.channels.get("631451610408681472");
    if (!channel) return;
    channel.fetchMessages({ limit: 1 })
        .then(messages => {
            const msg = messages.first();
            if (!msg) return;
            if (!msg.content) return;
            lastMsg = msg.content.toLowerCase();
        });
});

let lastMsg;

client.on('message', message => {
  
    if (message.channel.id !== "631451610408681472") return;
    if (message.author.bot) return;
  
    if (lastMsg && !rhyme.doRhyme(lastMsg, message.content)) return message.delete();
    lastMsg = message.content;
});```
**ERROR**
```js
TypeError: rhyme.doRhyme is not a function
eternal mesa
#

@heavy marsh just looking at the lib, you need to use the 'rhyme handle' to execute on

#

Take a look at how the examples work

heavy marsh
#
var rhyme = require('rhyme-plus');
rhyme(function (r) {
    console.log(JSON.stringify(r.findRhymes(['bed', 'read', 'feed'])));
});
#

like this

eternal mesa
#

Yes

#

Notice how it isn’t rhyme.rhyme('bed')

heavy marsh
#

let me see

#

thanks

hushed berry
#

cant you use arrow funcs for that

eternal mesa
#

You can

#

And in general I would that’s just the lib page

true basin
#

Is JS a good language to use if I plan on making a bot that utilised a data base for auto-moderation?

eternal mesa
#

Go by what language you are comfortable in

vagrant hedge
#

Opps nvm

earnest phoenix
#

lmao

#

twist made rythm i guess

true basin
#

I’m going with python, but a while ago someone stated that JS is not a great language for auto-moderation due to its single threaded nature.

knotty steeple
#

just use an existing bot :wesmart:

#

clyde go away

sick comet
spare goblet
#

Is there a discord api method to check if a user is dm-able?

#

like I want to check if my bot has perms to dm a user kellyhmm without actually dming them

cobalt umbra
#

Not sure, I just use try catch

spare goblet
#

yeah but i don't actually wanna dm them

sick comet
#

There is No way to tell ATM.

#

like in any way.

loud salmon
cobalt umbra
#

I asked Gods they said there is no way

sudden geyser
#

so large bots can reach the 10k temp ban through not being able to dm users

valid frigate
#

how would i get npm packages that "require" glibc to work in a docker container running on a node-alpine based image?

valid frigate
#

i see

humble pendant
#
module.exports.run = async (bot, message, args) => {
    message.delete();
    message.channel.send(":ok_hand: :weary: :ok_hand:")
}
green kestrel
#

hopefully obvious question

#

how do each of you store your api key for your bot's use?

civic scroll
#

process.env

green kestrel
#

do you hard code it into the bot source code, do you have a config file? environment variable? db config?

twilit rapids
#

config.json

civic scroll
#

env

valid frigate
#

across all languages

#

you should store it in the environment

#

not a config.json

civic scroll
#

.json config is easy to be exposed

valid frigate
#

read this

civic scroll
#

unless that is .eslintrc

valid frigate
#

Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.

green kestrel
#

currently i have a .ini which is in "../config.ini" in relation to the bot's directory. i was contemplating an environment variable, but then i still need to store that key in a .env in plaintext so its no better either way right? my config is outside of the application directory.

valid frigate
#

config.json is a file basically full of constants

#

ah if you have access to something similar to process.env like in node

#

store it there or use like a .env file

civic scroll
#

used that

valid frigate
#

mm

#

especially if you're going to be using more env variables

#

with node you can set it like NODE_ENV=production node app.js or something from the cli but that obviously gets tedious after a while

civic scroll
#

for the node some.js i used that in package.json

#

maybe

green kestrel
#

i think i have eight api keys now

#

one for discord, and seven different bot lists including this one

#

php laravel has .env files for config

#

theres only one problem, everyone seems to stash them in webroot.

violet moss
#

Hello! Im coding a Bot with java and want to implement a Tag System. For the b#tag renane [old Name] [new Name] i have to rename a file. But he always send the message Tag existiert nicht wich means in english the tag doesnt exist but the file exists in the correct Folder. Any ideas why it doesnt work?

green kestrel
#

🙂

late hill
#

@violet moss I'd recommend using a database

#

On top of that

#

Seems like a vulnerability in there

#

What if I use "../" in my argument

#

Will your code check for this or

#

Can I just freely go through all your files 👀

#

As for the actual issue I think it might be that you're checking for a file that's entirely lowercase while some of the files in the directory you've shown start with an uppercase character

severe gyro
#

Is it normal to use Gulp for building C code?

mossy vine
#

isnt that like using a makefile for js

severe gyro
#

Well, afaik it's normal to use Make for js, so i assume Gulp+C is normal too?

#

Anyways, i'm going to try it first

mossy vine
#

if it works why not lol

severe gyro
#

The only problem is there's no gulp-clang, yet...

earnest phoenix
#

if i put test in a timeout etc just for well, test, jest wont recognize them

#

nvm jest has a beforeAll() i can just do mongo connect in

#

epic

#

time to cause self pain

green kestrel
#

how can i tell if someones an admin with guild_subscriptions set to false?

quartz kindle
#

fetch the guild using the api to obtain its roles

#

and fetch the member if not cached, to obtain its roles too

slender thistle
#

You get roles when fetching?

#

Or is that just for uncached guilds?

quartz kindle
#

you get a guild object, which contains an array of roles

amber fractal
#

@earnest phoenix you know conneting is a promise right?

#

You can wait for connecting by just awaiting, you'll need to change how you connect in the forst place a little bit tho

#

I do this

let mongoDataBase = await MongoClient.connect('mongodb://localhost:27017', { useNewUrlParser: true }).catch(console.error)

client.db = await mongoDataBase.db('name')```
earnest phoenix
#

how much ram do u need to handle like say 30k users? thonk

steel patrol
#

hey, I have made an app and I can let the bot send messages in the channel I want. I also managed to let the bot send DM to users, but I would like to know whether it is possible to see which messages the bot sent (I don't have the id anymore of the message) and view potential replies from users

earnest phoenix
#

well yes, but no

steel patrol
#

so yes on the sent messages and no on the replies?

earnest phoenix
#

yes, but no on both of those

#

you would have to loop getting messages in batches until you find your bot's messages (which could potentionally take hours on end to finish, and you're going to hit ratelimits), there are many other variables here, like, what if someone deleted your bot's message, how are you certain which message you need to get?

#

store the message somewhere in code and you can track replies from there

quartz kindle
#

@earnest phoenix depends on the library you use, and what optimizations you do to it

earnest phoenix
#

discordjs :)

quartz kindle
#

it can potentially use a few hundred MB, or it could use 50MB

steel patrol
#

I use discord.js

#

curl with php, if possible would also do

quartz kindle
#

@steel patrol you can fetch messages from a channel, if you have the channel id

#

as long as the messages are not older than 2 weeks

earnest phoenix
#

that's for bulk deleting ^

#

you can keep getting messages in bulk without issues

quartz kindle
#

oh

steel patrol
#

yeah, but I need to access the DM I sent

#

if that's not possible that's okay, we're still just testing the app

quartz kindle
#

im not sure, i actually havent tested this

#

do dms have a new channel id everytime you create them?

#

try creating the dm channel again, and fetching messages from it

steel patrol
#

well, correct me if wrong, but wouldn't it be easier to get the message id on creation and then use that to access it later ?

quartz kindle
#

well, yes, but you said you didnt have the message ids anymore

earnest phoenix
#

the dm channel id remains the same

steel patrol
#

no, but for future design that would be better

#

mm ok

#

I'll try that then to retrieve the past id and start designing with future message id's

#

thx

quartz kindle
#

so then yeah, if you create a new dm channel, you should get the same id, which you can then use to fetch messages

green kestrel
#

yay, ignore lists are implemented 🙂

amber fractal
#

This guild has 71k (many bots tho) members alone, so if you're using a gig of ram just for one server you need to think of some optimizations

unique nimbus
#

Python caches everything in every server and this server takes like 100mb ram

quartz kindle
#

i actually misread him and though he said 30k guilds lul

green kestrel
#

in my bot i added a feature where people with the correct permissions on a server can enable 'chatty' mode on a per channel basis. basically the bot becomes talkative, responding to anything it recognises without need for a prefix or mention. if this was on by default it would be an absolute no-no. is there anything that specifically says i cant/shouldnt do this even as an opt-in setting that the admin turns on? even in this state, it still is hard coded to ignore all bots.

slender thistle
#

I would recommend locking it to a channel

quartz kindle
#

imo, nothing should come enabled by default

#

unless its required for whatever it is that the bot was designed to do

#

and even then, if possible, requiring it to be enabled by the guild admins would be better

boreal plaza
#

Hi, when does a bot need the "Embed links" permission? I didn't checked it and my bot was successfully sending "hidden" text links in RichEmbed

quartz kindle
#

i think the embed links permission doesnt stop it from sending, it just wont show the link preview from any of its links

#

i might be wrong tho

mossy vine
#

tim is correct

boreal plaza
#

ok thanks 🙂

earnest phoenix
#

ah yes it do be like that

white rampart
sage bobcat
#

One message removed from a suspended account.

unique nimbus
#
(node:22284) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
    at C:\Users\pnoke\Documents\GitHub\FarmCord\cmds\general\help.js:49:24
    at step (C:\Users\pnoke\Documents\GitHub\FarmCord\cmds\general\help.js:33:23)
    at Object.next (C:\Users\pnoke\Documents\GitHub\FarmCord\cmds\general\help.js:14:53)
    at C:\Users\pnoke\Documents\GitHub\FarmCord\cmds\general\help.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\pnoke\Documents\GitHub\FarmCord\cmds\general\help.js:4:12)
    at Object.module.exports.run (C:\Users\pnoke\Documents\GitHub\FarmCord\cmds\general\help.js:40:50)
    at Client.<anonymous> (C:\Users\pnoke\Documents\GitHub\FarmCord\libs\events.js:15:38)
    at Client.emit (events.js:210:5)
    at MessageCreateHandler.handle (C:\Users\pnoke\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
(node:22284) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:22284) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#

@sage bobcat

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

Different error?

#

or same

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

ye

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

is it a compiler error or a runtime error

unique nimbus
#

Then you would need the error response

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

its when you do the command

#

@earnest phoenix

#

wait

earnest phoenix
#

it's typescript

#

that's why i'm asking if it's a compiler error or a runtime error

#

because typescript is typed

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

ripe dew
#

https://paste.menudocs.org/paste/n23ng Can someone help, I am trying to make it see if the member who sent the message has the role and if he did it would do the verification else it would say Your not a DSG staff member

earnest phoenix
#

you're*

#

also compare ids, not objects

ripe dew
#

If I have/I dont have the role it would send the Error Message

#

wdym?

white gyro
#

has() takes an id.

earnest phoenix
#

has(snowflake)

oak moat
#

Lmao ranger

#

Cross posting on 3 servers now

#

thats sad

ripe dew
#

@oak moat 30 mins in menudocs and Source code....

#

No reply....

#

Tenpi, cry the role is a variable for the id

earnest phoenix
#

i'm aware, but it doesn't replace the id.

oak moat
#

I once waited 2 days for a reply and didnt cross-post mmLol

weary lark
#

anyone know any way to get a ko-fi webhook working with a discord webhook?

slender thistle
#

Whatever you did, let's not fill this place up with pointless fingers pointing

weary lark
slender thistle
#

Can't you host your own webhook to later send the data to a Discord one

earnest phoenix
#

^

#

you need to have a middleware that translates the webhook structure from one to another

weary lark
#

ok

#

thanks!

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

Lowercase the content

earnest phoenix
#

lol ^

amber fractal
#

You cant lowercase an array

sage bobcat
#

One message removed from a suspended account.

amber fractal
#

I mean you can map it to lowercase mmulu

earnest phoenix
#

??? you lowercase the entire message before slicing it

amber fractal
#

Before you turn it into an array lowercase the content

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

ok

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

yes

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

anywhere where you want case insensitivity

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

yes

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

if you use that variable in your command handler yes

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

what then what

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

everywhere where you need to reference the message's content

#

??

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

you're confused because you copypasted somebody else's command handler and now you don't know what your code even looks like

#

or where to navigate, because you didn't write it

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

it kind seems like that ngl

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

"your code" is a snippet that's repeated on google search results for like 10 pages

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

that part could be said about a lot of code

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

my command handler i stole from google

#

didnt make a single modification either 😎

weary lark
#

i used to steal a lot of code

earnest phoenix
#

I stole it long ago

#

so

sage bobcat
#

One message removed from a suspended account.

weary lark
#

@little iron used to just be filled with stolen code and its heavy af, thats why i had to kill it and move on, anyways its a useless bot now lol

earnest phoenix
#

it functions the same if I were to write it so why change it

#

yeah my first bot was filled with stolen code

#

and was just garbage

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

i know what im doing
clearly not because you don't even know how to take basic instructions i gave you and apply it to your command handler

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

because you stole the code (which is why you don't know where) 🙃

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

hmmmmmmmmmmmm

#

so if i take a marvel movie and put my voiceover on it, it's now mine?

#

maybe you should learn some basic nodejs usage first

sage bobcat
#

One message removed from a suspended account.

white gyro
#

This is basic js, slice() returns an array

quartz kindle
#

what are you trying to make case insensitive?

earnest phoenix
#

I copied a command handler but I knew exactly how to make use of the functions

#

args

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

afaik

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

i went through your src and found the command handler within a minute, how the hell do you not know where it is

#

it's just evidence that you stole the code without analyzing what it does

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

the prefix part of it and you removed checks for bots

#

that's the only change you made

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

lol ok

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

look, i'm tired and i don't have the nerve to do this, just go to your command handler and look at your code further than just the if checks

#

try installing it

#

npm install request

sudden geyser
#

npm init

earnest phoenix
#

uh

#

what

#

this feels like a

#

boi

#

cd to the directory

#

run npm init

#

my brain cells are damaged

#

where is your project located

sudden geyser
#

but it says it was installed

earnest phoenix
#

where is your project located

#

where is your bot project located

#

ok

#

find that exact directory

#

the folder

#

cd to it

#

npm init

#

then do things

quartz kindle
#

when you did npm init, the initializer started running, now it wants you to provide information

#

such as name of the package, license, etc

#

you have to type those out

earnest phoenix
#

cd and then the directory

quartz kindle
#

type cd hamumu

#

and press enter

earnest phoenix
#

npm init

quartz kindle
#

how does your console look like now?

#

are you using discord bot maker?

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

yes

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

thats a little harsh

quartz kindle
#

doesnt discord bot maker have a discord server?

earnest phoenix
#

probably

slender thistle
#
>>> 0 and 0
0
``` well up to this day I'm not sure how I haven't noticed this
steady ocean
#

So anyone explain jasn. Jason file in all these neural codes. And there derivatives. Sophie finally got me out. Human AI or a thought bot. I’m new to this side

earnest phoenix
#

w hat

unique nimbus
#

json

#

@earnest phoenix

earnest phoenix
#

ah

unique nimbus
#

who is Sophie

hoary helm
unique nimbus
#

thonk

hoary helm
#

thonk indeed

earnest phoenix
#

@hoary hill You're refused my friend request hmm okey.

#

yep

green kestrel
#

when the user sends a message, where do i find the value that says if theyre a server administrator?

#

ive tried iterating roles, but for the initial server owner, the administrator permission appears to be given absolutely, separate to the roles and i cant see it there

#

if it matters, im using guild_subscriptions=false which seems to hide a bunch of stuff

slender thistle
#

Does it hide their guild permissions too?

green kestrel
#

not sure, where would they be? i can show you the whole 'd' part of the packet for a message, if it helps?

slender thistle
#

Not entirely sure that could help me but why not :p

green kestrel
#

if its part of the user list sent with guild_create, i dont have it

#

i dont get that user list

earnest phoenix
slender thistle
#

Maybe let users set up the admin role?

green kestrel
#

im using a role to denote access right now

#

but i want administrators to override that role and just get access, as they seem to override near everything else

#

otherwise the server owner goes to use the bot and it tells them they dont have the permission they need (manage channels)

#

technically, they do

#

looks like it should be in author.server_permissions

#

i dont have that part of the object 😦

amber fractal
#

@earnest phoenix 2020ms

earnest phoenix
#

thats because that function waits on the database connection etc

#

smh

amber fractal
#

Then why dont you check how long it take to connect in a different test

#

Then it'll be accurate

mossy vine
#

@earnest phoenix isnt that for a discord bot?

earnest phoenix
#

I think he said its also a web based game

#

idk

#

^

#

what rico said

#

but yea its the discord bot portion

#

i generally build out a library that can work independantly of djs events etc

#

so that i can reuse it on multiple platforms

mossy vine
#

damn thats sick

earnest phoenix
#

that also allows for easy test to be written

mossy vine
#

i was asking because ive never really seen unit testing for bots but have wondered about it a few times now

earnest phoenix
#

yea so if you have a complex system its nice

#

but for simpler stuff might not be worth the time

mossy vine
#

fair

earnest phoenix
#

heres a pic

#

i made in ms paint

#

to explain it better

#

thats hd

#

lib should work independantly of anything pretty much

lunar crystal
#

I recently create my moderation commands (kick, ban, ....) But I don't know if the permissions for using this commands are already set or I have to do it ? thonkku

slender thistle
#

If you don't have enough permissions x you can't kick

#

To ensure the command invoker's permissions is up to you

lunar crystal
#

yes but I mean today a member can kick someone by using the rigth command ?

dusky marsh
#

if you made your command locked to a member having certain permissions then users with those permissions can run the command

storm wind
#

I need a little help with markdown code block formatting, I am using Discord.js and for some reason I get the list working but somehow I am getting the code block in italics and I can't figure our how to remove the italics https://imgur.com/a/GEcMLj8 (I am using discord.js)

Imgur: The magic of the Internet

earnest phoenix
mossy vine
#

the previous server name includes a *, simply escape it

late hill
#

erotic code

storm wind
#

I tried replacing the * with nothing but it seems to do nothing am I doing it wrong?

guild.name.replace(/'*'/,'')
#

And I tried adding the * to my test server and it just showed the * and not format it

mossy vine
#

/\*/ as regex?

storm wind
#

I feel dumb

#

I didn't think that would stop the code the server has a name with a ' in it

sudden geyser
#

are you using regex to replace every *

storm wind
#

That wasn't the problem which would explain why that never worked

#

I changed the regex to /\'/ and it worked :/

#

but thanks for the help

lunar crystal
#

@dusky marsh How did I do this ?

dusky marsh
mild escarp
#

can someone tell me how to make a bot send a message when i post a youtube video?
discord.js

earnest phoenix
#

message event -> check if content starts with desired youtube url (e.g https://youtube.com/ or https://youtu.be/) and if the author id matches your id, if both checks pass, send the message

quartz kindle
#

i think he means have the bot detect an upload in youtube (or not)

earnest phoenix
#

Yup can someone help me for change presence of my bot

#

From play to watch ?

warm marsh
#

Language?

vocal phoenix
earnest phoenix
#

is there anyway to visit any of the servers your bot is in ?

green kestrel
#

oh jeesus. after 2 hours debugging, i found out why crappy discordphp can't handle this server. when it adds 75000 users, it does an O(n*n) loop, two foreach's inside each other, one to add members to an array and another to search through the presence list (75000x75000) looking for the presence to associate with each member... ffs.

#

taking out the presence stuff allows it to register, even while using guild subscriptions

heavy marsh
#

discord.js I want it to not display the current playing song in the queue and when the queue has 10+ songs make it to pages - Any Idea how to?

    let embed = new discord.RichEmbed()
        .setColor(`#FFD41C`)
        .setTimestamp()
        .setFooter(`Rhino - Multi Purpose Bot`)
        .setThumbnail(`https://i.ytimg.com/vi/${queue.musics[0].id}/default.jpg?width=80&height=60`)
        .setTitle(`Music Queue`)
        .setDescription(`${queue.musics.map(music => 
            `\`•\` **[${music.title}](${music.url})**`).join('\n')}`);

   message.channel.send(`:arrow_forward: **Currently Playing:** ${queue.musics[0].title}`, embed);
scarlet phoenix
#

@earnest phoenix There is a custom client that lets you login with your bot token, but that was like years ago, I would also think thats against TOS. You could have your bot give you open invite links to servers as well, but thats kinda scummy.

green kestrel
#

also this thing is passing huge (20mb) json objects around as copies, not refs

#

:/

#

🙂

sudden geyser
#

@heavy marsh filter the array (or slice) the playing song and map the rest

#

pages are complicated so you'd have to experiment yourself. Some simple checks can get you what you want

heavy marsh
#

ok thanks

vocal phoenix
#

@heavy marsh ```let page = 1;
let embed = new discord.RichEmbed()
.setColor(#FFD41C)
.setTimestamp()
.setFooter(Rhino - Multi Purpose Bot)
.setThumbnail(https://i.ytimg.com/vi/${queue.musics[0].id}/default.jpg?width=80&height=60)
.setTitle(Music Queue)
.setDescription(${queue.musics.map((music, i) => (i >= (page-1)*10 && i < page*10)?`•` ${music.title}:'') .filter(m=>{return m !== ''}).join('\n')});

message.channel.send(:arrow_forward: **Currently Playing:** ${queue.musics[0].title}, embed);```

heavy marsh
#

ooh wow thanks

earnest phoenix
#

how would I get a variable that gets defined in a function, to save to a constant or something to call for later in a different portion of the script?
discord.js

        const jsonObject = JSON.parse(body);
        var UPDATED NUMBER = jsonObject.UPDATED_COUNT;

the UpdatedNumber var gets defined like this in a function, but is inaccessable and "undefined" outside of that specific function

zealous veldt
#

Question for all you nerds. What's the best way to handle refreshing OAuth access tokens. I'm thinking a cronjob or something that refreshes for every user using my app. Is there a better way or something I should be doing? Please ping me with responses. Thanks

#

@earnest phoenix you could initialize it outside of the function

earnest phoenix
#

didnt think of that tbh, am dumb, thanks ❤ @zealous veldt

zealous veldt
#

Np :)

green kestrel
#

hmm

#

is this overkill?

#
    /* Drop these before we even parse json, it's much more cpu efficient. We dont care for TYPING_START or PRESENCE_UPDATE */
    if (substr($data, 0, 23) == '{"t":"PRESENCE_UPDATE",' || (substr($data, 0, 20) == '{"t":"TYPING_START",')) {
            return;
    } else {
            $data = json_decode($data);
    }
#

parsing presence updates and typing start messages was costing me a constant 2-3% cpu, and this is a dual cpu, quad core xeon

#

that does seem to have helped a fair bit

slim heart
#

well if its noticeably faster then yeah its good lol

valid frigate
#

libs have an array of events you can pass to disable them

#

might not even be necessary

green kestrel
#

this one has such a system, but it parses the event before it decides if it needs to filter it

#

i think im making some progress at making this old unsupported lib actually useful... yeah i love a difficult challenge

deep wedge
#

Anyone here able to help a brother out with the most simplest thing ever?

green kestrel
#

that depends what simplest thing ever it is

deep wedge
#

I'm running on little to no sleep the last 2 days so like the smallest things are just going straight over my head

green kestrel
#

first and best advice youll hear is, after ive given an answer whether its useful or not, go get some sleep.

#

😄

deep wedge
#

Pretty much my plan but I can't sleep when this thing is on my mind

#

If you get me

green kestrel
#

i can relate

#

🙂

#

however its a vicious cycle, the more tired you are the harder it is to concentrate and the more mistakes you make, you just end up introducing bugs 🙂

deep wedge
#

https://hastebin.com/cukeqapemu.js is my command but I have an issue were the 3 error messages get sent at once instead of one at a time. Most likely a issue with not having return in there somewhere but I just cant seem to get it to work

green kestrel
#

you mean you get multiple language versions of each line being sent?

deep wedge
#

No the languages is fine, this is the problem it sends all these at the same time

#

When they are supposed to be like, if it doesnt have perms it will only send the first and if only the embed color is not defined it will only send the second

#

Its just the smallest thing I can feel it but for the life of me I cant figure it out and im gonna just stay up all night till I get somewhere

green kestrel
#

is line 12 supposed to be like this?

#
        if(Guild.language === 'german') {
        message.channel.send(emessage.ge_noembedlinks)
          }```
#

or like this:

#
        message.channel.send(emessage.ge_noembedlinks)
          }```
deep wedge
#

First one

green kestrel
#

yeah it will, unless you put a return after each error, or something

deep wedge
#

I tried adding return but thats no use

earnest phoenix
#

try the second

green kestrel
#

after its executed the "if (!color)" block, it falls through into "if (!title)" and then "if (!message)"

earnest phoenix
#

perhaps

deep wedge
#

The language parts are not the problem they work perfectly its just the error messages

#

will all send at once

green kestrel
#

i dont normally indent like that

#

ive put the returns to the left, so you can easily see what i mean

#

you could even just put one return at the end of each major block

#

the if (!title) and if (!color) etc

#

but the way ive done it i think is clearer

#

btw your indent/brace code style make for some difficult reading, perhaps you should run it through a pretty print, or use the code indenting facilities of your editor?

#

it will make your code easier to follow as you write it

earnest phoenix
#

that just makes the code look nicer tho

green kestrel
#

personally i find it really hard to grok code where its got like 3 or 4 }'s on one line

#

i guess some people find that easy to read

deep wedge
#

I'm able to read the code easily idk I just like the way it is but yes brain those returns you added worked

earnest phoenix
#

also use else if statements 🙏

#

seriously

green kestrel
#

this is an ideal case for switch statements, or simply an associative array of responses

#

i'd have done that, tbh

#

syntax may be a little off, its been a while since i did js

deep wedge
#

I can finally sleep now, damn 2 hours in the last 48 hours

green kestrel
#

is it even js, what language are you using, @deep wedge 🙂

deep wedge
#

discord.js

#

js

green kestrel
#

the ${blah} threw me

#

aah ok

deep wedge
#

i just have some stuff in other files

#

like

#

error codes in a other file it makes it easier instead of writing out the one error code each time

#

i can just have it all together

#

if i ever need to change it

green kestrel
#

thats a good idea, because you can pass those separate files to a translator

#

without giving them source code

#

in an ideal world all strings should be in an external lang file, but im a hypocrite because i never do it... or i start out with best intentions planning to, and then stop doing it part way because its a pain

deep wedge
#

most of my error messages and error codes are just like js ${error.nouserfound} or ${emessage.nouser}

green kestrel
#

that works ok in some instances

#

however, some languages have oddball syntax.... i mean spoken languages

#

like, posessive parts of a sentence having to be listed first, or feminine and masculine different wordings for words that are the same in english

#

etc

deep wedge
#

Yeah that happened in French so I just wrote out the error code and seen where the words went and just plopped it in there

green kestrel
#

a good i18n system accounts for all of that, but like i said im a hypocrite and really should use such a system myself. i think node has several

deep wedge
#

I gotta go asleep damnits really late, Ill see ya around mate thanks for putting my brain to ease after all those return errors and stuff. pikawave

green kestrel
#

also strings and localisation is boring, lets be honest here. nobody likes dealing with it

#

ok night, sleep well!

deep wedge
#

Have a good day or night!

green kestrel
#

thanks you too, its late for me also, im contemplating bed 😛

earnest phoenix
#

wholesome <3

#

can someone give me a quick tutorial about webhooks?

#

🕸 ↪

#

so uh, I got the other stuff working, and everything seems fine however I keep getting back errors when someone DM's the bot and it replies

The reply comes through perfectly fine, and everything in discord seems to be working perfectly but in the console it returns with this

(node:26812) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
    at item.request.gen.end (F:\desktop\Dappers Bot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15)
    at then (F:\desktop\Dappers Bot\node_modules\snekfetch\src\index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:26812) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:26812) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

not really sure whats up, not used to these errors lmao