#development

1 messages · Page 651 of 1

viral plover
#

If my Discord laggs when a bot I'm running tries to send a message, does it cause it to crash?
I think this has been the case a couple times but I'm not sure. If this can happen, is there a way to prevent it in the code or do you just have to rely on Discord running smoothly?

pale marsh
#

Depends on the lib you're using tbh

warm marsh
#

Your bot connects to the API, So if you/your provided crashes then possible but not likely.

pale marsh
#

Some libs have internal error handling that reports to an event handler that you specify. They're mostly 404 errors though when the API dies

nocturne hazel
viral plover
#

What do you mean by "lib"?

warm marsh
stray garnet
#

@warm marsh i just fixed that the red embed gets delteted atfer ;help

warm marsh
#

Why'd my name change? lmao.

grim aspen
#

because it's hard to ping you with that name

warm marsh
#

Oh Fair.

viral plover
#

Okay, thanks.
It's a shame I can't really do anything about it but it's also relieving that it's not my fault.

quartz kindle
#

it depends on your code and your library, most likely you can do something about it

#

the cases where you cant really do anything are very rare

pale marsh
#

@warm marsh I can set it to Dillon if you want

warm marsh
#

Sure.

viral plover
#

Oh, that changes things.
I'm using Javascript, node.js, and Discord.js.

quartz kindle
#

alright, are you catching your promises?

#

the leading cause of crashes in js are uncaught promises

warm marsh
#

@stray garnet it sends now? Or not?

stray garnet
#

@warm marsh Wait was that was in DM? or seever

viral plover
#

I don't think I have a catch for everything.
I guess I'll just do that then.

warm marsh
#

I did it inside a guild. Then I got a dm saying Testing!

stray garnet
#

tf? @warm marsh it dont sends me anything

quartz kindle
#

every promise that connects to the api, such as .send() has a chance to fail, and if it fails and there is no error handling, the error will climb up the process and make it crash

stray garnet
#

@warm marsh in dm

warm marsh
#

Hold on.

viral plover
#

What are other common ones besides .send() that I may accidently neglect?

quartz kindle
#

everything that interacts with the api

#

functions that do not rely on caches

viral plover
#

So checking a member's roles would count?

quartz kindle
#

fetching, sending, setting, editing, changing, configuring, emojis, roles, etc

#

just checking them no, because it checks them from the user cache

#

but setting them yes

viral plover
#

Ah, okay.
Anything that causes a visual or functional change in Discord then.

quartz kindle
#

anything that requires you to "await" for an answer from discord

#

yes

earnest phoenix
mossy vine
#

start the bot without sharding and it might give you more information

earnest phoenix
#

i fixed it somehow

restive light
#

Bot puts "," to its messages as space

earnest phoenix
#

i just had to keep deleting the files and replacing them

restive light
#

Like "Hello,guys,how,is,it,going?"

#

How to solve that?

mossy vine
#

@restive light pasting the relevant code would be helpful

restive light
#

'''client.channels.get("Loby").send(" " + arguments)'''

#

issue is in ("" + arguments)

topaz fjord
#

What is arguments

restive light
#

my message

#

( !say message )

earnest phoenix
#

oof a say cmd

topaz fjord
#

it should be arguments.join(" ") instead of " " + arguments

#

The latter turns in an array into a string and adds it to a string

#

Which is why you get the commas

mossy vine
#

^

restive light
#

I just want to remove all ","

topaz fjord
#

And that's how you do it

#

'''client.channels.get("Loby").send(arguments.join(" "))'''

restive light
#

will it work?

topaz fjord
#

Yes

restive light
#

For example when i type !say good morning all
bot says: good,morning,all

mossy vine
#

try the code turtle sent

feral hornet
#

installation of bots on my android error

#

Helpme

nocturne hazel
#

Can you post a screenshot?

#

Of the error?

topaz fjord
#

@restive light

#

It works

restive light
#

@topaz fjord

#

yes it worked

#

thanks

feral hornet
#

Wait @nocturne hazel

nocturne hazel
#

k

alpine heath
#

@earnest phoenix

lofty lantern
#

@nocturne hazel can you help me to install the bot?

#

Helpme

mossy vine
#

@lofty lantern you want to add a bot to your server?

bright mortar
#

i can

#

i can add it

lofty lantern
#

@mossy vine yess

bright mortar
#

@lofty lantern inv me to the server

pale marsh
#

@lofty lantern this is the wrong server dude

bright mortar
#

and give me the link

#

i will add it for you

#

i will add it @lofty lantern

#

invite me to it via dm

pale marsh
#

Talk in DM's already and leave this channel

bright mortar
#

oof

lofty lantern
#

@bright mortar link server discord me?

bright mortar
#

@pale marsh how long does it generally take

pale marsh
bright mortar
#

for my thing to be verified

#

my bot

pale marsh
bright mortar
#

on DBL

#

k

lofty lantern
#

@bright mortar hello

bright mortar
#

DM

earnest phoenix
#
	if(message.author.bot) return;
	if(message.channel.type === "dm") return;
	let server = message.guild.id;
	if(!message.guild.me.hasPermission("MANAGE_MESSAGES")) return;
	if(!db.get("citadelle").find({ serveur: server }).value()) {
		let user = message.member;
		message.delete(user);
		user.send("**⚠ Ce serveur a activé le mode citadelle.**").catch(err => {
			if(err) {
				return 
				} 
			}) 
		} else {
			return
		} 
});```

When the citadelle system is active, why the bot doesn't delete any messages ?
#

i put this in async ?

earnest phoenix
#

🤔

quartz kindle
#

thats not how you delete messages

#

well, depends on what you want to delete

earnest phoenix
#

I want the system to be activated and a user sends a message to any channel, its to delete it directly.

quartz kindle
#

the argument of .delete() is a timeout, you're giving it a member object?

#

and idk what kind of value you're getting from your db, but the ! in the beginning means "NOT"

maiden mauve
#

javascript question:

#

Why is my string targetId turning into an array

#

the white space is irrelevant code

#

the variable is being logged above the error as a correct string of numbers

quartz kindle
#

concatenating a string and an array will force the array to stringify

#

but its still an array

#

if player.lastTarget strictly requires a string, it wont work

maiden mauve
#

right, but why is targetId becoming an array?

quartz kindle
#

where does targetId come from?

maiden mauve
#

it exits a function as a string

#
        console.log(tag + ' enters formatID');
        if(!tag) return null;

        if(tag.length > 1) 
            tag = tag[0];

        var flakeID = tag.toString();
        var flake = flakeID.match(/^\d+|\d+\b|\d+(?=\w)/g);
        if(flakeID.length < 18) return null;
        console.log('returning ' + flake.join(''));
        return flake;
    },
#

this is the function returning it as a string, the console logs work both in and out

quartz kindle
#

.match doesnt return a string

maiden mauve
#

hm

#

thank you

#

I just realized what I did

#

console.log('returning ' + flake.join(''));
return flake;

#

I wrote the join in the console

#

but not the return lol

quartz kindle
#

happens to the best xD

maiden mauve
#

I think I had that exact comment on match once too

#

// returns an array

#

strange that console wasn't logging it as an array

#

targetId = c.formatID(args); console.log('targetId in attack.js: ' + targetId);

#

was returning the "correct" value

#

instead of [' string ']

quartz kindle
#

because its concatenating

#

"string" + ["string"] = "string string"

maiden mauve
#

Ooooh

#

didn't connect that when you first said it

rugged pawn
#

I can not get the bot Luca on my server!😐

slender thistle
#

Luca is a private bot

earnest phoenix
#

Why you want luca ?

rugged pawn
#

Oh

#

My Name is two Luca😅

split hazel
#

It's our personal server bot

#

You can always use the source code though

rugged pawn
#

what a shame

earnest phoenix
#

the source is fake

#

speedy

split hazel
#

Oh 😂

rugged pawn
#

😭

#

What a shame

split hazel
#

I mean luca isn't impossible to rewrite on your own with a bit of knowledge

rugged pawn
#

Please

cursive dagger
#

It's pretty easy

earnest phoenix
#

ik I did most of it

#

lol

#

@rugged pawn what do you want with luca ?

rugged pawn
#

First try what he can and then use.

earnest phoenix
#

My bot just copy the "case system" of luca idk if its what do you want

split hazel
#

But i can guarantee copying code you don't understand will never get it to work

topaz fjord
#

I have the Luca case system but it will be gone soon

rugged pawn
#

i would like to have all the functions of luca

earnest phoenix
#

My bot is a copy of luca

split hazel
#

It's pretty simple to make your bot exactly like luca

topaz fjord
#

Most of Lucas features only work in this server

amber fractal
#

I also rewrote luca lmao

#

I wonder how many people actually have their own copy of it with their code

#

I mean mine is private and I havent seen anyone elses, but I also havent been on the dbl site in like 2 months mmulu

quartz kindle
#

did you also copy its amazing troll functions?

split hazel
#
		return message.reply('Aleyküm selam.');
	  }```
west spoke
#

lul

amber fractal
#

Not that lol, just a rewrite of the actual luca in here

valid frigate
#

ok so basically how do i get the status of a client in djs (ready, disconnected, reconnecting) or is that shard specific

topaz fjord
#

Each shard has its own status

#

Once the client is ready it fired the ready event

#

There are also events for disconnect and reconnecting

#

@valid frigate

valid frigate
#

ah so store this status in an object?

opaque eagle
#

Can someone help? idk why im getting that error```ruby
#!/usr/bin/ruby

def triangle_num(n)
return (1..n).inject(:+)
end

def find_divisors(n)
return (1..n).select { |i| n % i == 0 }
end

i = 0
until find_divisors(triangle_num(i)).length > 500
i += 1
end

puts triangle_num(i)``````
012/012.rb:7:in find_divisors': bad value for range (ArgumentError) from 012/012.rb:11:in <main>'```

valid frigate
#

thanks for the reference tho, didn't notice lmao

dusky marsh
#

I am making some music commands and I want the current time left of the song playing in the nowplaying command. I have access to the song's length in milliseconds. How would I go about this? Any tips or pointers in the right direction would be wonderful as I am a bit stumped.

unique nimbus
#

convert it into minutes

dusky marsh
#

That doesn't fix the problem, I can convert it into minutes but I want to be able to show the user how much time is left in the song

late hill
#

Save a timestamp of when the song starts playing?

#

Unless whatever you're using has some way to get the remaining time

latent oasis
#

how to run html from js file?

dusky marsh
#

Well I save the timestamp but I'm stumped on what to do with it.

    const songObj = {
        song: song,
        requester: message.author.id,
        requestedTime: new Date()
    }

I have this, the timestamp is the requestedTime and I can access the song's length in ms with song.info.length

#

I just need a push in the right direction what to do with this data

wheat jolt
#

help please

#

does someone know why it's falling?

earnest phoenix
#

Bot doesn't found the member/role

wheat jolt
#

ablobthinking thanks

smoky spire
#

@wheat jolt member uncached

wheat jolt
#

wdym

smoky spire
#

the member isn't cached

#

you have to fetch it

wheat jolt
#

i did

#

fetchUser

smoky spire
#

but you member() it

#

member() relies on cache

wheat jolt
#

he left the guild

#

that's why error showed up

#

thanks anyway

latent oasis
#

what lang?

#
.setPresence({game: {name: `${bot.guilds.size} guilds}`,type: "WATCHING"},status: "idle"});
#

sorry

#

lol

twilit rapids
#

What are you calling it on

#

@earnest phoenix

latent oasis
#

@earnest phoenix bot.user

#

add it

#

bot = your-client

#

now i use setPresence

#

no

#

but it works

#

11.5.1

#

as i know

#

d.js

#

i didnt update it yet

#

yw

late hill
#

@dusky marsh You take the current time and subtract the start time, that's how long it's been playing.
You take the total time and subtract the time it's been playing, that's how long is left.
👀

#

You can also add the total time to the start time and then subtract the current time

#

It's just a math question rly 👀

dusky marsh
#

yeh i just couldnt really get it through my head, you would think a college calculus kid would be able to think easier about it lmao, thank you

trail dagger
#

Discord.py
Command raised an exception: KeyError: 0

#

wait

#
for x in data:
          print("lol1")
          if int(x) == ctx.guild.id:
            print("lol2")
            if data[x][0]["ChannelId"]:
              channel = self.bot.get_channel(data[x][0]['ChannelId'])
              with open('data/moderation.json') as rfile:
                data = json.load(rfile)
slender thistle
#

What's data[x]

#

It doesn't seem to be a list

trail dagger
#

didnt send all code tho

#

this is one of the parts

def getjson():
  with open('data/setmodlog.json') as rfile:
    data = json.load(rfile)
  return data
#

dont bully me for using json 😂

abstract crow
#

Does anyone know if it is possible to see what a user's status is(Not DND, etc) but like their game or whatever in D.JS?

#

@trail dagger Why u bully me 🤣

trail dagger
#

huh?

abstract crow
#

Its just a thing online, its a joke 😛

trail dagger
#

ok?

slender thistle
#

It's usually named activity

trail dagger
#

That wasnt the part that had any error Furuhashi

#
              channel = self.bot.get_channel(data[x][0]['ChannelId'])
              with open('data/moderation.json') as rfile:
                data = json.load(rfile)
                global case
                try: 
                  case = len(data[x])
                except Exception:
                  case = 0
                documented = False```
#

this had

#

why is discord f up my spaces?

twilit rapids
#

<User>.presence.game.name

#

@abstract crow

abstract crow
twilit rapids
#

Not sure

slender thistle
#

What does data look like

#

It doesn't seem to me that data[x] in that iteration has any lists involved

trail dagger
#

I fixed it btw

#

i removed [0]

#

that was the error

slender thistle
#

Sigh

trail dagger
#

I should have figured that out for a long time ago when the error was
Command raised an exception: KeyError: 0

earnest phoenix
#

hello an anybody can give me the code to check if the message author is the owner of the guild where the message was send ?
lib: discord.js

west spoke
#

Message.guild.owner??

earnest phoenix
#

yes thanks

#

(i'm too lazy to check in the doc)

trail dagger
#

stop being lazy

#

check docs

opaque eagle
#

I mean let's be thankful he gave us the lib at least lol

latent river
#

Hi all!!.
I want to implement a command in my Bot that erases all the messages that the Bot did without deleting the messages of other people.

If I use "await ctx.channel.purge (limit = limit)" all messages are deleted.

By the way I use Python

#

any idea?

twilit rapids
#

For each message, filter the author to be the bot

latent river
#

but how?

cursive dagger
#

@latent river read docs... it literally has what you are doing as a example

west spoke
trail dagger
tight nimbus
#

reason:LOL

trail dagger
#

yea

#

i just tested if it worked and it did

tight nimbus
#

ok

trail dagger
#

I just made a copy of it just because i was bored

mossy vine
#

is it possible to use discord rich presence only with http requests?

sinful fable
#

Hi

#

How do I make a hot

#

Bot

covert turtleBOT
sinful fable
#

@tiny lodge

#

@pastel dews son

slender thistle
#

@mossy vine I believe not

mossy vine
#

why did you send that image Thonk

#

and alright

#

what do i exactly need then

#

docs are so confusing

slender thistle
#

/shrug, never worked with those. It's just my opinion on the HTTP requests. You might wanna take a look at SimplePresence source code

lofty bane
#

hello guys any one here ? i wanna ask for something

twilit rapids
#

Sure, ask away

lofty bane
#

oh sorry !

#

i fixed my problem XD i tried for 30 min

#

but now it fixed

twilit rapids
#

Oh ok

mossy vine
#

nice

lofty bane
#

i have another problem

#

let emoji = client.guilds.get("565270757102452756").emojis.find(r => r.name === "right");

#

and the error :

#

TypeError: Cannot read property 'emojis' of undefined

#

thats because the id is wrong ?

#

i mean the id of emoji "565270757102452756"

#

hello everyone ?

amber fractal
#

The guild isnt found, you also said your getting the id of an emoji

#

Your doing client.guilds.get, it needs a guild id

lofty bane
#

yea

#

i need to get the right ID

#

but i dont know how.. if you can help me.please help XD

amber fractal
#

You just copy the id of the guild MegaThonk

split hazel
#

On mobile to enable dev mode its settings - behavior - developer mode

#

probably similar on pc

earnest phoenix
#

your settings are going to sync anyways with your phone

split hazel
#

Unless you have it turned off

#

The sync clients option

earnest phoenix
#

ah yeah

west spoke
#

Tru

#

I have mine off

halcyon nymph
#

On iPhone it’s in settings>appearance>developer mode

earnest phoenix
#

True

#

Umm someone know how should i get a stats from a link?

#

if(msg.content.startsWith(prefix + "stats")) { const args = msg.content.split(" "); const name = args[1]; const url = "https://osu.ppy.sh/api/get_user" const key = osu; if(name) { let data = `${url}?u=${name}?k=${key}`; console.log(data); msg.reply(data); } else{ msg.reply("Username Not Found") } }

#

The command

#

[{"user_id":"PRIVATE","username":"Tedy No Joke","join_date":"2018-05-31 11:46:27","count300":"523402","count100":"105315","count50":"12770","playcount":"6741","ranked_score":"273415270","total_score":"1521917899","pp_rank":"255151","level":"61.3654","pp_raw":"1304.62","accuracy":"88.74329376220703","count_rank_ss":"3","count_rank_ssh":"2","count_rank_s":"39","count_rank_sh":"27","count_rank_a":"61","country":"RO","total_seconds_played":"277489","pp_country_rank":"1345","events":[]}]

#

and this looks if i acces it from browser

slender thistle
#

What's the exact issue here? That seems fine to me

earnest phoenix
#

@slender thistle i want to get the data

#

but i don't know how could i can get it

#

like `` let data = data.pp_raw; and to show the data

#

pp*

#

value

#

i want to get this "pp_raw":"1304.62"

#

but i don;t know how from a url

slender thistle
#

Use a package that sends HTTP requests and then send GET request to that URL, transform the response into JSON and you're good

#

As I'm not js dev, I have found axios that can help you (might be not the best)

earnest phoenix
#

oh

split hazel
#

yeah i'll take a look at your sql error

earnest phoenix
#

me , or the other one?

split hazel
#

@grim quest SQLite doesn't like '

#

use " instead

earnest phoenix
#

Speedy

#

Can you help me?

split hazel
#

Depends

earnest phoenix
#

i want to get something

#

but it's says underfined

#

but in browser works

slender thistle
#

You aren't sending any HTTP requests...

split hazel
#

I don't see any code that gets data

#

yeah ^

earnest phoenix
#

How

slender thistle
#

Did you read my previous messages

earnest phoenix
#

i did

split hazel
#

If you don't know how to send HTTP requests, you should learn a bit more JS/NodeJS first

spare goblet
#

@earnest phoenix Getting stats - use jquery and jsdom to create a window and GET https request
A quicker an easier alternative is using the package request

quartz kindle
#

jquery in node 🤔

split hazel
#

yeah dont use jquery on node

spare goblet
#

It works if you use jsdom rollonthefloor_rolypoly

split hazel
#

use something like request or whatever

#

i like using axios for json payloads

spare goblet
#

Warning tho request gets p messy if it's not json

earnest phoenix
#

oh

inner jewel
#

just use fetch :^)

opaque eagle
#

Also cheerio is pretty much just jquery in node tbh

quartz kindle
#

or just use node's internal http modules

harsh robin
#

Anyone here know how to use SQL in java and wanna show me how?

#

I need to learn how to use a database so I can finish my web crawler I'm working on.

unique nimbus
#

readthedocs?

harsh robin
#

I have, the java docs for SQL are pretty shit bit I haven't looked at them in a few months and I've improved a lot so I'll look again but help is always apreciated.

lusty dew
#

I don't understand what is causing it personally if anyone could please explain what the possible causes could be it'd be much appreciated

earnest phoenix
#

you're probably using an older version of lavalink

#

if you're using the newest one, either copyright or region restriction

lusty dew
#

@earnest phoenix Where can I get the latest version I though I downloaded the latest version

#

But the link I clicked brought me to an outdated version

earnest phoenix
#

just download the jar file if you aren't using docker

lusty dew
#

Thank you @earnest phoenix

opaque eagle
#

I'm using TypeORM and I'm getting this error:ts console.log(message.channel.guild.id); // logs the guild id const guild = await Guild.findOneOrFail({ select: [ "prefix" ], where: { id: message.channel.guild.id } });`````` 🚫 null value in column "id" violates not-null constraint

gritty bolt
#

How do I prevent my bot from going offline after an error?

opaque eagle
#

catch and handle it properly

gritty bolt
#

It will go offline for 2 seconds, then reappear

#

if you want I can send my catch

opaque eagle
#

Also what's the error

gritty bolt
#

Mainly permission errors

opaque eagle
#

Ur bot shouldn't go offline for those

gritty bolt
#

idk why it does

opaque eagle
#

show ur code

gritty bolt
#

then(err => bot.emit('error', err, message));

#

triggers

opaque eagle
#

How do u handle the error event

#

And that event would be emitted regardless of whether u include that code or not

gritty bolt
#

``bot.on('error', error => {
console.log(error);
message.send("stuff")
});

opaque eagle
#

message.send() isn't a thing

gritty bolt
#

oh wait thats the old version

#

the new one is the same but message is channel

#

which is a variable

opaque eagle
#

ok

#

Are u 100% sure the bot crashed for a discord permisison error and nothing else?

gritty bolt
#

Yes

opaque eagle
#

Can u show the error

#

which crashed the bot

gritty bolt
west spoke
#

@gritty bolt that's a permission error.

#

It can't send to the channel

gritty bolt
#

thats what I thought, which is weird

#

Think I got it semi-fixed though

west spoke
#

K

pastel spear
#

Anyone know a simple line i can add to restrict a command to nsfw?

amber fractal
#

Yeah, check the channel type

#

Not type

#

There's a prop for nsfw channels

lusty dew
#

I am trying to scrap a website but it doesn't bring up the websites info it brings up my internet page info, like the page it would pop up if the thing is inappropriate

amber fractal
lusty dew
#

But the website I am trying to scrape isnthat inappropriate

amber fractal
#

Well what wevsite is it, if it isnt too nsfw to share

#

Also

#

Not all websites allow that

lusty dew
#

Ah mk

#

Some parts of it are nsfw so I can

#

cant share it

#

I'll keep trying

amber fractal
#

A better approach

bright spear
#

urban dictionary?

amber fractal
#

Would be to see if it had an api

lusty dew
#

It has a bunch of apis but none of them work

bright spear
#

@lusty dew sounds like there some network block, is it running on your computer or a server?

lusty dew
#

or do what I am looking for

#

Computer

#

My internet restrictions are turned all off

#

I can go to the website myself

#

but when I try and scrape the website it brings up the restricted page info instead

amber fractal
#

Restricted page?

earnest phoenix
#

how are you scraping 🤔

#

if you're actually programatically scraping, unsafe warnings don't exist

lusty dew
bright spear
#

its def something on your network

pastel spear
#

@amber fractal were both talking about restricting a command in the script itself right? Im new to discord.js so everythings confusing. Lmao

amber fractal
#

Request doesnt scrape does it?

lusty dew
#

Cause I can't remember how to use cheerio

bright spear
#

@amber fractal what

lusty dew
#

Someone told me it did

bright spear
#

iirc request sucks

#

but yeah that is scraping

lusty dew
#

In the discord.js server

amber fractal
#

@pastel spear restricting certain commands to only be used in nsfw marked channels is what I meant

#

I use request to make http calls to apis

#

Used to

pastel spear
#

Ah ok.

amber fractal
#

I just use node built in now

lusty dew
#

How would I use cheerio to scrape

earnest phoenix
#

they have examples on their readme

lusty dew
#

cause someone suggested it to me at first but I forgot how to use it

earnest phoenix
#

probably on the website too

lusty dew
#

OKie

#

Does cheerio have a website?

bright spear
#

you still need to use request or another request lib first

#

you can use cheerio to analyze the data you get from it

lusty dew
#

Yea I know

bright spear
acoustic citrus
#

what's a good pastebin alternative with like no limits that i can send evaled text to?

acoustic citrus
#

(js)

bright spear
#

@acoustic citrus hasteb.in, paste.bisoga.xyz, or one of the many other hastebin clones

acoustic citrus
#

is hasteb.in just hastebin with a different url or

bright spear
#

its just hastebin but hosted by someone else

#

cuz hastebin is open source

acoustic citrus
#

ah i see

bright spear
#

ngl

#

there are a ton of hastebin clones

#

haste.unbelievable.pizza, h.mayo.pw, file.properties/paste

#

but btw some of them expire after a while

acoustic citrus
#

aight thats cool

stray garnet
#

possible to do ${user.tag} with an @?

#

so that the User gets mentioned

#

ok

bright spear
#

no

#

@stray garnet just ${user} should work, @${user.tag} would not work

modest remnant
#

Hello

bright spear
#

hi

modest remnant
#

I make a bot and it's offline

#

What i do

mossy vine
#

did you write code for your bot

gritty pike
#

are you running your code?

modest remnant
#

@mossy vine no

#

Who to write

#

Say

gritty pike
#

you have to write, in your preferred language

mossy vine
#

and thats the wrong mindset

gritty pike
#

and run the code

mossy vine
#

please learn a programming language PROPERLY first

modest remnant
#

Who to learn programming language

#

Any

mossy vine
#

you learn whatever language you want

modest remnant
#

Website

mossy vine
#

just google

#

beginners usually prefer javascript or python

modest remnant
#

Can I codeing bot in android

mossy vine
#

no

#

you didnt define files

#

send your code

#

ah youre just copying and pasting without understanding, nice

#

in the fs.readdir callback you declare the recieved files as file but refer to them as files

nocturne viper
#

I don't see why everyone is using the file structure command layout

mossy vine
#

also you wrote lenght instead of length

late hill
#

Guess he copied code but wrote it himself

nocturne viper
#

Everyone just copies each other

late hill
#

And added some mistakes 👀

mossy vine
#

basically

nocturne viper
#

XD

mossy vine
#

in Discord.Client the option disableEveryone is false by default, no need to set it to false

nocturne viper
#

Later today I'll publish my structure

gritty pike
#

typo is so annoying btw

indigo geyser
acoustic citrus
#

😮 ik milky

indigo geyser
#

I'm MickyBot

acoustic citrus
#

ill let him know

indigo geyser
#

No milky

acoustic citrus
#

oh lol

#

still probably stolen from his

#

looks the same

indigo geyser
#

Did you understand that the code for that bot was stolen?

acoustic citrus
#

yes

indigo geyser
#

Stolen by Miky

#

Ok GG

acoustic citrus
#

milky is who it looks like its stolen from

indigo geyser
#

Oh ok

#

Miky is the real dev

mossy vine
#

if the bot is open source it isnt "stolen"

indigo geyser
#

No it isn't

quartz kindle
#

what are you trying to do?

stray garnet
#

@indigo geyser oof copy and paste

quartz kindle
#

are you trying to scrape your own router's panel? if so, you just leaked all your devices mac addresses and names lol

#

Aarons-iPad Bigfoot MAXIMUSIII

indigo geyser
#

@stray garnet yes

mossy vine
#

oof

stray garnet
#

@indigo geyser Whats the Owners Name?

split lantern
#

@lusty dew your router may have an api

lusty dew
#

@quartz kindle No I'm trying to scrape another website but it scrapes my routers panel instead

quartz kindle
#

whats the link you're scraping?

lusty dew
#

It's nsfw

#

So not posting iy

#

It

quartz kindle
#

does it work on your browser?

lusty dew
#

Yea

#

I can search it manually but when I scrape it doesn't work

quartz kindle
#

what are you using to scrape it?

lusty dew
#

Request then cheerio

quartz kindle
#

if you use only request, does it work?

lusty dew
#

Nope

quartz kindle
#

are you scrapping it from your own pc?

#

or from a vps?

lusty dew
#

Pc

latent oasis
#

js

how to make prefix none case sensetive?

lusty dew
#

I'm using my beta bot rn to test the command

quartz kindle
#

two things you can try:
change your dns to google/cloudflare dns
the website might be checking browser presence, such as referral or requested-by headers, so you'd need to figure them out and emulate them

lusty dew
#

Hm I'll try

#

Later

#

It's late asf rn

#

And I'm working on another project lmao

#

So many projects at once

quartz kindle
#

@latent oasis when you check the prefix, convert everything to lower case or upper case, so that everything is equal-cased

latent oasis
#

i tried to lower case and it just work with lower (not working without upper case)

lusty dew
#

Which if anyone wants to help me with this project dm me please help is much needed for this important project

quartz kindle
#

you need to convert both sides

#

the thing you're comparing, and the thing you want to compare to

latent oasis
#

like
.toLowerCase().toUpperCase()

#

?

quartz kindle
#

no need for both

latent oasis
#

hmm

quartz kindle
#

just pick one and do it to both sides

#

prefix.toLowerCase() === message.toLowerCase()

#

or message.toLowerCase().startsWith(prefix.toLowerCase())

#

or whatever system you're using

latent oasis
#
  var prefix = config.prefix //Default prefix
    let fetched = await db.fetch(`prefix_${message.guild.id}`);
    if (fetched === null) prefix = config.prefix
    else prefix = fetched
  if (message.content.indexOf(prefix) !== 0) return;  
#

i cant understand how to make it in my part

gritty pike
#

Making a rpg game, so for item details should I save them making class object or just fetch the details of item from database, which one will be more efficient? using sql3 database and python 3.7

quartz kindle
#

@latent oasis you have message.content, and you try to see if prefix exists in it

latent oasis
#

oh

quartz kindle
#

so make the message content lower case, then try to see if a lower case prefix exists in it

#

@gritty pike if those details will never change, it is safe to hardcode them

#

but if you think you will ever change/balance them in the future, put them in the database

gritty pike
#

ohk, understood

maiden mauve
#

hmm

#

const args = message.content.slice(prefix.length).split(/ +/);

#

would it be a lot of uphill work to change that into a class?

#

command.execute(player, message, args);

#

so that it passes a "Class of arguments" with properties for data validating etc

#

rather than every "file.js" having validating of a string array

stray garnet
#

How to that?

example

User: @sterile zinc

Bot: My Prefix is ;

maiden mauve
#

pull the prefix from a file?

#

message.channel.send (config.prefix)

quartz kindle
#

it shouldnt be much work, you can make a class, or simply a function that returns the checked and formatted args

maiden mauve
#

I was thinking the class route for readability, but then I'd have to require the definition in every file right?

quartz kindle
#

you can make that operation in the main file, before passing it to other files

maiden mauve
#

Ah I think you just answered it

#

"passing a class" keeps the definition

#
case "rss":
                if(!args[2] || !args[3] || !args[4] || !args[5]) return c.reply(message,'\`Invalid quantities. Be sure to include all 4 resources. (wood, stone, gold, trophy)\`');

                target.rsWood += +args[2];
                target.rsStone += +args[3];
                target.rsGold += +args[4];
                target.rsTrophy += +args[5];
                replyStr = `\`${target.name} gains ${args[2]} wood! ${args[3]} stone! ${args[4]} gold! ${args[5]} trophies!\``;
                break;
#

ew

#

thats the type of stuff thats starting to get on my nerves

#

if anyone else reads it they are like "wtf is all this"

quartz kindle
#

looks like a normal switch case to me

maiden mauve
#

yeah, the switch is fine

#

its just the persistant use of "args[ ]" and "args" throughout the code

#

if you recall my small dilemma yesterday about array type

quartz kindle
#

you can do the validation before the switch

#

if you know for sure everything is valid, then you dont need to check for validation during the switch

#

you can have a "prepare/validate" function to validate the args

maiden mauve
#

I guess the better argument I need to make is that the "args" array contains different data types

#

strings/integers

#

for example I use this command line in just about every file:
var targetId = (args=="")?message.author.id:c.formatID(args);

quartz kindle
#

you can either include different validations for different commands in the validation step, or you can do a general validation, such as checking for undefined/null, and then inside the switch you check for typing

maiden mauve
#

where the function has to format the first element of the array

#

and the null check is checking for no input

#

it's really just a question of readability

#
        var repeat = args[1];
        var cmd = args[0].toString().toLowerCase();
#

that's what I did in a few files

#

but I'd prefer to keep every file using the same variables

#

every command will have special handling to some degree

twilit moat
#

iiii.iiii

slim heart
#

I see

winter hawk
#

Question time.
I have a empty global Array []. The data is pushed to it in a function.
Now I wan't to return the Array with the (pushed) data outside the function, but it says the array is empty idk
Any idea?

slim heart
#

Are you pushing inside of a promise?

#

And then the grab code is ran after it

winter hawk
#
    var testArray = []

    //Fetch all planned work-activities
    const endpoint = 'https://ns-api.nl/reisinfo/api/v2/disruptions'
    fetch(endpoint, {
    }).then(function (response) {
        return response.json();
    }).then(function (nsjson) {

        let payloads = nsjson.payload
        for (i in payloads) {
            let payload = payloads[i]
            let type = payload.type

            if (type == "werkzaamheid") {
                let title = payload.titel
                let gevolg = payload.verstoring.gevolg
                let periode = payload.verstoring.periode

                testArray.push("title + gevolg + periode")
            }
        }

    }).catch(function (response) {
        console.error("Oops, something went wrong.")
    })

    console.log(testArray)

MegaThonk

#

returns empty

earnest phoenix
#

Hey

#

How can I get an role from bot

#

Not from message but from bot.

twilit rapids
#

what lib

earnest phoenix
#

Js

twilit rapids
#

get the guildMember object

earnest phoenix
#

Hm?

#

@twilit rapids

twilit rapids
#

Only members have roles, so get the member object

earnest phoenix
#

How to get it?

twilit rapids
#

Multiple ways to get it

#

Since you don't want to use the message object, you can use the guild object

earnest phoenix
#

so, I am looking to add someone to an role when he adds an reaction

#

So when I got the "user"

twilit rapids
#

Then you can get the member object from the event

earnest phoenix
#

Oh.

#

So change user for member?

#

Then member.addRole(bot.roles.get)?

#

How yo get the role?

twilit rapids
#

You can do <Guild>.roles.get(id) or <Guild>.roles.find('name', 'your role name')

earnest phoenix
#

How get guild? @twilit rapids

#

bot.guild?

split mesa
#

Hi

pallid zinc
#

My bot was on for 1 month and without any change it is showing err can't find module discord.js

maiden mauve
#

code skipping return

#

why

#

angry 😠

pallid zinc
#

What u mean

maiden mauve
#

its just processing past the return;

twilit rapids
#

show code

#

@pallid zinc install discord.js again, that might fix it

pallid zinc
#

Nope

#

It's not installing

#

I try npm I discord.js

twilit rapids
#

Are you installing it to the right directory

pallid zinc
#

Yup

#

Package.json

twilit rapids
#

what return is it skipping

pallid zinc
#

Seems like u cant help

#

It's even given err when I try to install npm

winter hawk
#
var testArray = []

fetch('https://ns-api.nl/reisinfo/api/v2/disruptions', {
        headers: {
            'Content-Type': 'application/json',
            'x-api-key': key
        },
    })
        .then(res => res.json())
        .then(json => {

            let payloads = json.payload
            for (i in payloads) {
                let payload = payloads[i]
                let type = payload.type

                if (type == "werkzaamheid") {
                    let title = payload.titel
                    let gevolg = payload.verstoring.gevolg
                    let periode = payload.verstoring.periode

                    testArray.push(title + gevolg + periode)
                }
            }
        });

    console.log(testArray)

testArray still empty? It works fine when placed straight under the push. idk

#

Anyone any idea

late hill
#

Yes

#

Because the piece of code inside your .then() is async

#

The rest of your code continues to run while that bit is waiting for the fetch to finish

winter hawk
#

makes sense, but then how to solve it.
I've now a work-around with writing the data away to a json file, but you'll always parse the previous file when running the command

keen karma
#

How do I make a bot

#

I wana do one

earnest phoenix
#

magic

maiden mauve
#

do you know a programming language?

keen karma
#

............
... ........

#

Oh yeah

keen karma
#

But I’m bored

#

Is there another easy way

#

Cuase this is boring

maiden mauve
#

...

#

maybe its not for you then lol

#

If you don't enjoy programming a bot just use someone elses

keen karma
#

Well is there a bot that can make messages like this command here
*messages

earnest phoenix
#

like what

maiden mauve
#

I'm sure there are a bunch of bots with custom silly commands

#

I think MEE6 does that

keen karma
#

No he doesn’t I tried

#

He doesn’t sadly

earnest phoenix
#

bots have a gender 👀

keen karma
#

I know

#

Wait what

#

Ehh

#

Idc about enters

#

Bye thanks for no help

maiden mauve
#

btw

#

disregard my problem

#

I am a neanderthal

#

apparently if you call a function twice it doesn't behave like you called it once

#

imagine that

#

especially with different variables

earnest phoenix
#

Does anyone has commands for Discord.js cause I made my bot

#

I need a list full

maiden mauve
#

commands?

earnest phoenix
#

Yea

maiden mauve
#

like the discord API?

earnest phoenix
#

Think so and help commands as well

maiden mauve
#

that has all the objects/properties of discordjs

earnest phoenix
#

So I can put it in my bot command tools

maiden mauve
#

stick to general chat I think you have a general problem 😉

unique nimbus
#

MPIG you need to code it yourself

#

look at the docs which Loaf sent

winter hawk
maiden mauve
#

There seem to be a lot of people who show up here not knowing a bot requires programming

unique nimbus
#

yes

earnest phoenix
#

Yep

near igloo
#

hi

#

can any 1 send me a invetation link of this server

west spoke
soft plaza
#

Can I change the bots pfp through the api

west spoke
#

I dont think you can anymore

earnest phoenix
#

you can

#

you always have been able to

west spoke
#

Oh

#

Ok

earnest phoenix
#

i'm not sure if all libs support it, but you sure can

soft plaza
#

OK thx

quartz kindle
#

d.js definitely supports it

hidden heron
#

how can i send a message to everyone in a guild? js

quartz kindle
#

thats illegal

hidden heron
#

i just want to know how

quartz kindle
#

fetch all members and send them messages in a loop, but that will possibly get you banned

hidden heron
#

people r already doing that in their guilds, i keep getting messages by a bot every hour

quartz kindle
#

the fact that other people are doing it doesnt make it any less bad

#

you can always report those bots

hidden heron
#

hmm

#

aight thx

mossy vine
#

"oh yeah, some people are murdering people, that must mean i can do it as well"

nocturne hazel
#

Can someone please help me on how I can get image data from the reddit api using superagent?

#

Using the reddit api's random.json feature?

wicked pivot
opaque eagle
#

Get a VPS

#

Don't use heroku for bots

grim aspen
#

heroku is shit

nocturne hazel
#

^

twilit rapids
#

All free hosts are bad

nocturne hazel
#

Yeah

wicked pivot
opaque eagle
#

I thought we already answered your question... get a proper VPS

wicked pivot
#

these just the time I pay my web host

earnest phoenix
#

ignore the first item in the args array

#

no

pine crater
#

Hi

slender thistle
#

Please stop sending the same message in every channel

warm marsh
#

@earnest phoenix make a command variable e.g. const command = args.shift().toLocaleLowerCase(); below your args variable. Then when creating a command do if (command == prefix+'command') {}

#

No worries.

opaque eagle
#

the locale in .toLocaleLowerCase() doesn't really matter... the locale part is only useful when using JavaScript in the browser, not with node. String.toLowerCase() would do just fine.

warm marsh
#

Yeah I know, I've just used that so long that it's just what I type.

#

Yeah

#

Ok, have fun. Any questions about developing ask here.

earnest phoenix
#

xyz pls help

#

xyz pls serverinfo

split hazel
floral stone
#
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [140.82.114.4] port 22.
debug1: Connection established.
debug1: identity file /home/antonio/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/antonio/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/antonio/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/antonio/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/antonio/.ssh/id_ecdsa type -1
#
debug1: identity file /home/antonio/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/antonio/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/antonio/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: Remote protocol version 2.0, remote software version babeld-93408c70
debug1: no match: babeld-93408c70
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/antonio/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey```
#

I'm getting this output when running ssh -vT git@github.com.

#

I'm trying to setup github ssh login if that helps. Here's the rest of it: debug1: Offering RSA public key: /home/antonio/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Trying private key: /home/antonio/.ssh/id_dsa debug1: Trying private key: /home/antonio/.ssh/id_ecdsa debug1: Trying private key: /home/antonio/.ssh/id_ed25519 debug1: No more authentication methods to try. Permission denied (publickey).

#

It's fixed, hopefully.

drowsy yew
#

I'm trying to get my bot online, but nothing's working. (I'm using Visual Studio, Node, and TypeScript, so I'm running it on a json Script).

    console.log("Bot Online");
})

client.login(ConfigFile.config.token)```
The only thing it's giving me in the console is 

``SyntaxError: Unexpected token *
    at new Script (vm.js:80:7)
    at createScript (vm.js:264:10)
    at Object.runInThisContext (vm.js:316:10)
    at Module._compile (internal/modules/cjs/loader.js:670:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)``

And I just don't know how to fix Syntax Errors.
mossy vine
#

you have an unnecessary * somewhere. in the code

drowsy yew
#

Checking now

#

Can't find one

#

I only have 4 Asteriks, and removing them logs them into the Problem Output

mossy vine
#

send your whole code with sensitive data removed, and if its too big just put it on pastebin or smth

drowsy yew
#

Kk

earnest phoenix
#

{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'neilcorp_admin'@'ip' (using password: YES)

#

what is this ?

#

mysql error

#

everything is good, the password the db and the host

mossy vine
#

well it likely isnt

#

im not familiar with mysql, but maybe theres output on the server side?

mossy vine
#

oh i see whats happening

#

ts compiles your code into a syntax that your node doesnt understand

drowsy yew
#

Hec

#

I got it online before

#

(Using a different bot application)

#

So should I try to get the new node?

mossy vine
#

or compile to an older js syntax

drowsy yew
#

I don't think I know how, it's been a while lol- specifically...last year october

mossy vine
#

ive barely used something

#

theres an option is your tsconfig.json

drowsy yew
#

So just run that in the terminal?

mossy vine
#

run what?

drowsy yew
#

wait no Im dumb

#

that's a folder I forgot hec

mossy vine
#

you can do it from your terminal if you have a tsc command already for compiling it

drowsy yew
#

I think I do have a tsc compile command

mossy vine
#

what do you run to compile it

drowsy yew
#

The TypeScript site says the compile command is "tsc helloworld.ts"

mossy vine
#

oh

#

theres a cli option/argument for specifying what syntax/version it should compile to

#

read docs, i forgot lol

drowsy yew
#

i think I should redo the code idk

#

or not

#

Im completely puzzled on what to do at this point

mossy vine
#

i told you what to do

#

i just forgot what the option is called

#

a quick google search should help you tho

drowsy yew
#

Kk

#

What do I search though im an idiot lmao

#

Im literally thinking about going on y ou t u be

mossy vine
#

typescript compile to es6
the search results will likely direct you to a compiler option, read docs on that option

drowsy yew
#

Kk

#

So i'm trying to allow JS files to be compiled?

mossy vine
#

no, you want to compile to an older version of js

#

you could also update to node 12, but afaik that breaks some modules

drowsy yew
#

o

#

I can't find anything so ima update

#

oh heck its a software

mossy vine
drowsy yew
#

Im on a family comp, and my dads the admin lol

mossy vine
#

wait

#

so you dont have node installed?

drowsy yew
#

I do

mossy vine
#

oh

drowsy yew
#

the problem is my parents are gone atm

#

and my laptop charger is gonezo

mossy vine
#

well then just wait

drowsy yew
#

If I can't get node 12 im probably just gonna weep and eat eggs then delete my code and start over

mossy vine
#

if you dont have to use ts, you could just use js

drowsy yew
#

Oof

#

Welp I need administration to install it

amber fractal
#

You can bypass that

#

I did it at my school

drowsy yew
#

GG

#

But how

#

Lol it's dis kinda admin

quartz kindle
#

try tsc file.js --target ES5

mossy vine
#

oh its target

quartz kindle
#

although the docs say the default is ES3, i dont see why node wouldnt be compatible with that

drowsy yew
#

Trying

#

error TS6054: File 'file.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.

Found 1 error.

mossy vine
#

dont run it in a ts file

#

and certainly dont copy paste without understanding

drowsy yew
#

Im legitimately confused

warm marsh
#

You must compile your TypeScript to JavaScript before being able to run it. You'll want to create a ts config file. Then use tsc -w or the file you want. Then run as node.

floral bloom
#

What does this mean?

- parse error: Expected another key-value pair at line 20, column 3

Discord.js

#

Ping with response please

warm marsh
#

tsconfig.json - The settings I used when using TypeScript.

{
    "compilerOptions": {
        "outDir": "dist",
        "module": "commonjs",
        "inlineSourceMap": true,
        "target": "es6",
        "strictNullChecks": true,
        "strict": true,
        "skipLibCheck": true,
        "noImplicitThis": true
    },
    "exclude": [
        "node_modules"
    ],
    "compileOnSave": true
}```
#

I used tsc -w in the console

#

and then created a folder called dist

#

where the compile code went.

mossy vine
#

change target to something else

warm marsh
#

But don't copy without actually understanding.

#

Why?

mossy vine
#

can you just send what your typescript code compiles ro

#

to*

warm marsh
#

Me or him?

mossy vine
#

you

warm marsh
#

Alright

#

one sec

#

That's one of my olds bots so the code is a bit meh.

mossy vine
#

wait

#

how are you running the bot

warm marsh
#

node sharding.js

mossy vine
#

@floral bloom extra comma on line 17

#

@warm marsh is that your sharding.js file

floral bloom
#

@mossy vine Wow, I can't believe I missed that 🤦 Thank you!

warm marsh
#

Nah, Index file.

#

But it's the same.

mossy vine
#

and whats the error youre getting again?

warm marsh
#

I'm not getting any?

#

I was telling the guy that's getting the error how I did mines.

#

Lmao.

mossy vine
#

oml im so stupid

quartz kindle
#

Lol

mossy vine
#

my only excuse is that its 1:30am tyvm

warm marsh
#

Fair.

shy rose
#

servers diff makes sense but shard are um...

opaque eagle
#

lol

amber fractal
#

Well when did they upload the shards

#

It only updates every so often

shy rose
#

been running 2 shards for ~a year now

amber fractal
#

But when did you start uploading shards

shy rose
#

ages ago

amber fractal
#

Oh

#

Rip

shy rose
#

its not recent put it that way

#

oh hey thats just over a year

opaque eagle
#

wait nvm... for a sec i thought marco's site was open source

shy rose
#

yeah thats my commit

opaque eagle
#

cool

limber swan
#

Is this well defined?

rollbar: new (require('rollbar'))(process.env.ROLLBAR_ACCESS_TOKEN),```

3|PentaHub  | TypeError: Cannot read property 'minimumLevel' of undefined
topaz fjord
#

I would personally define require('rollbar') as its own variable

#

for cleanliness

floral bloom
#

Discord.js
How do I get a users last message using their ID?
I want to get their last message from the server the command is run in as well as any server the bot is in with that user.
I've tried all that I can think of...

#

Ping with response, please

amber fractal
#

Uh

#

Have you ever read the docs?

floral bloom
#

Yes, I have

#
message.channel.send(message.author.lastMessage)
```This works, but only for the author...
amber fractal
#

You'd fetch the member you need

floral bloom
#

Oh, wait! Yay, I got it!

#

Well, for the current server

#

Gotta figure out the global one Thonk

amber fractal
#

Then fetch the guild then the member

floral bloom
#

Mhm

#

The only problem is, I want it to get the last message from any guild that both the bot and the user are in.

#

So I don't have a guild ID...

amber fractal
#

Well you cant get messages from a user that the bot isnt in

#

Not only would that be a violation of tos, it's literally not possible
Edit: read that wrong lol, thought you were talking about unshared servers

floral bloom
#

I know, but from a server they're both in

amber fractal
#

Well what do you need it for

floral bloom
#

For a userInfo command ¯_(ツ)_/¯

amber fractal
#

Why would you need their latest message from any other guild than the one the command is used in tho

#

You would have to loop over every guild and see if the user is in it. Im not sure if it's allowed by tos to share their last message from other servers tho Thonk

floral bloom
#

Eh, that's too much work 😂
I guess I won't do it. Thanks for the help though!

floral bloom
#

Discord.js
Isn't there a way to use a code block in an embed without doing MESSAGE?
I Googled but found nothing...

shy rose
#

nope

#

``` tells discord its a code block

floral bloom
#

Hmm

pastel spear
#

For the life of me i cant figure out how to restrict a command like this to nsfw channels. Am i just dumb or is it alot harder in discord.jsif(command === "kiss") { console.log(${message.author.tag} used the kiss command); message.delete().catch(O_o=>{}); if(message.mentions.members.size == 1) { let member = message.mentions.members.first() message.channel.send(${message.author} kissed ${member}!, { file: "https://media3.giphy.com/media/G3va31oEEnIkM/giphy.gif" }); }

#

Alot of my commands for sending images are based on this same code.

west spoke
#

uhh

uneven rover
#

if (!message.channel.nsfw) return message.channel.send('Has explicit content.');

west spoke
#

^

#

I am forced to use api calls since py async doesnt have it

pastel spear
#

ah

west spoke
#

Ima make a release for async that includes most rewrite things

floral bloom
#

Please ping with response. Thank you!

shy rose
#

more specific?

#

oh that flag

#

yeah bots cant access that

#

only users can via the get profile endpoint users only last i heard

acoustic citrus
#

what am i doing wrong with this code?
client.sql.user = sql.prepare("SELECT * FROM users WHERE id = ?");
should it not work? (it worked before i changed it)

                 ^

TypeError: Cannot read property 'server' of undefined
    at module.exports (E:\Canine\events\ready.js:77:18)
    at Client.emit (events.js:194:15)
    at WebSocketConnection.triggerReady (E:\Canine\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:125:17)
    at WebSocketConnection.checkIfReady (E:\Canine\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:141:61)
    at GuildCreateHandler.handle (E:\Canine\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:13:31)
    at WebSocketPacketManager.handle (E:\Canine\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (E:\Canine\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (E:\Canine\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocketClient.internalOnMessage (E:\Canine\node_modules\@discordjs\uws\uws.js:103:5)
    at native.client.group.onMessage (E:\Canine\node_modules\@discordjs\uws\uws.js:57:12)```
shy rose
#

client.sql isnt defined

#

client is defined but not sql property on it

acoustic citrus
#

oof then what should i define it as?

shy rose
#

you need to assign it somthing ;-;

acoustic citrus
#

oof aight

shy rose
#

can you have multiple on ready /on message events in discord.py

if so how

slender thistle
#
@bot.listen('your_event')
async def aaa():
 etc```
bright spear
#

@pastel spear d.py async is deprecated and unsupported, switch to rewrite

earnest phoenix
#

wat

acoustic citrus
#

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    console.log(`Loading command: ${command.name}`);
    client.commands.set(command.name, command);
}``` i cant find out how to detect a command in a file inside /commands bc im stupid and tired
acoustic citrus
#

what error message u getting

late hill
#

add if (message.author.bot) return; on top to prevent the bot replying to other bots (including itself)

#

top of your bot.on("message" .. that is

#

Your library tells you if it's a bot or not

#

No need to use roles

#

As in other servers ppl probably won't always have a bot role

#

Well it would still be more efficient

#

And if you ever forget to give the bot role to one

#

It won't mess with anything

#

And I see you're doing some checks if the cooldown isn't active

#

You're not doing those checks if it is on cooldown

#

Meaning any message would trigger that?

quartz kindle
#

the channel and bot checking should both be the first thing to be checked

#

then you go to message checking

#

also your scopes look weird

#

your cooldown.add is outside the else

quartz kindle
#

you want to lock the bot to only work on that channel right?

#

if you do the channel checking only after, then on other channels the bot will still be creating cooldowns for no reason even though it wont say anything

earnest phoenix
#
bot.on('message', message=>{
if (commandcooldown.has(message.author.id)) {
    message.channel.send("You have to wait 1 minute to do this again! - " + message.author);
} 
commandcooldown.add(message.author.id);

    if(message.channel.id !== "595279742744133682") return;
    if(message.content === "6") return message.author.send(`You choose 6!`)
    if(message.content !== "6") return;

            
            setTimeout(() => {
commandcooldown.delete(message.author.id);
            }, 60000);
        
        }
     
    )```
#

i think

quartz kindle
#

first of all, you shouldn't be using multiple listeners to the same event

#

put all numbers under the same .on("message") event, if you're not already doing that

#

also you dont need to have multiple Sets, you can just prepend or append the command to the id