#development

1 messages ยท Page 595 of 1

earnest phoenix
#

then you're just storing as a plain string

#

so your field in the db should be of a string type

#

then when you retrieve it you parse it

#

let val = JSON.parse(result);

brazen quartz
#

Oh ok, im using DBeaver to create colums and such, when I create the colum should it be a string value or json/jsonb

earnest phoenix
#

string

brazen quartz
#

Ahh ok, and then just JSON.parse the variable in code when retrieving the data

earnest phoenix
#

yes

brazen quartz
#

and JSON.stringify when updating

#

this is how im updating atm .update('yesu', JSON.stringify(yesUsers.push(user.id)))

earnest phoenix
#

json/jsonb types in the db are for things like validating your json when you set it

#

json type just stores it as a string, like string

#

jsonb will actually validate it

#

jsonb does other things but you're probably not concerned with them

brazen quartz
#

so the column chould be json type then

earnest phoenix
#

could

#

but you need to JSON.stringify when pushing to postgres

#

and JSON.parse when retrieving

#

then you should be fine

#

jsonb should work for you too, but the conversion it performs to store it in the db is a performance loss if you don't need the functionality jsonb provides

#

so just plain text as a string/json type is better then

brazen quartz
#

Ok will give that ago and come back inevitably lol

#
    at JSON.parse (<anonymous>)```
#

const yesUsers = JSON.parse(poll.yesu);

earnest phoenix
#

console.log(poll.yesu);

brazen quartz
#

[]

#

that might be useful too

earnest phoenix
#

ok so you're updating the field to a blank array

#

when you go to JSON.stringify

#

console.log() that result too

#

see if you're not using a wrong var or something

brazen quartz
#

I cant because it wont get past the json parse bit

earnest phoenix
#

try catch the parse

#
let yesUsers;
try {
  yesUsers = JSON.parse(poll.yesu);
} catch () {}```
brazen quartz
#

ok so i just set the variable to a blank [] array just to test, and this console log
console.log(JSON.stringify(yesUsers.push(user.id)));
returns 1

#

should I try just basic string data instead of json maybe

earnest phoenix
#

er

#

yesUsers.push() returns the length of the array

#

not the result of the push

#

you need to stringify yesUsers itself

brazen quartz
#

OMG im so stupid

earnest phoenix
#

hah we all come across some mistake we make like that

brazen quartz
#

Thank you aha it is working now ๐Ÿ˜ƒ

#

What is more efficient for just simple arrays, string or json type?

earnest phoenix
#

both are string

#

json just helps you identify the field stores json data and not just random strings

brazen quartz
#

Ahh ok, cheers for all your help, been stuck on this for weeks, and now i know why, I knew how to json data store all this time, just noe how to use .push properly xD

earnest phoenix
#

np

brazen quartz
#

Just another quick question since your so helpful aha, everytime I delete a id from the array it leaves null, any quick fix?

earnest phoenix
#

how are you deleting it

brazen quartz
#

await delete noUsers[i];

#

i is just the num of loop when it finds the correct entry

earnest phoenix
#

delete sets it to undefined/null

brazen quartz
#

Ahh ok, is there a .pop/.slice sort of method to removing it?

earnest phoenix
#

splice

#
let test = [1,2,3];
console.log(test);
test.splice(1, 1);
console.log(test);```
#
> Array [1, 3]```
brazen quartz
#

Oh i see

earnest phoenix
#

splice( index, count )

brazen quartz
#

yes yes, cool thank you so much ๐Ÿ˜ƒ

#

make me feel like a day 1 noob again XD

#

thats as simple as .splice(i, 1) ๐Ÿ˜ƒ

earnest phoenix
#

eh don't feel too bad

#

as if i'm all that good at js

#

i had to look that up just to make sure

#

my specialty is c++. js is just my side thing

brazen quartz
#

Yeah but your just that level above me where you know what to look for aha, I was too busy googling json data storage when I should have been looking at why the result was 1, I assumed knex was the issue but nope, my stupidity was ๐Ÿ˜›

#

this is great tho theres been a lot of commands and features i couldnt add without this type of storing

#

now I can finally do them

earnest phoenix
#

but, now you know for the future, if you're ever not getting the expected result, you'll know to verify the data you're working with first

#

potentially save you time in future instances

#

then you can count yourself among that "level" :P

brazen quartz
#

Yes i need to be more 'console.log' dependent, I always assume too much

#

Again thank you, ๐Ÿ˜ƒ

earnest phoenix
slender thistle
earnest phoenix
#

How do we add sites to the description?

earnest phoenix
#

when i create role how do i put it on the top

#

or on the highest slot i can

opaque eagle
#

What lib

grave pilot
#
let reactionObject = {
      type: reactionType,
      roleid: role.id,
      nameorid: nameorid
};

let reactionArray = [];
reactionArray.push(reactionObject);
let arrayString = JSON.stringify(reactionArray);
```When I console log ``arrayString`` it logs ``[object Object]`` how do I fix this?
potent frost
#

@grave pilot not even going to lie

#

why are you pushing to a blank array

shrewd lintel
#

Array.toString()?

grave pilot
#

Becasue I am adding more to it

potent frost
#

oh okay

#

i wouldn't tostring it,

grave pilot
#

I have to

#

Becusae its inserting to mysql

shrewd lintel
#

Just for the console.log part

#

Oh

opaque eagle
#

What's the equivalent of __dirname in import/export syntax?

junior summit
#

is this correct const db = require('quick.db');? I also used npm i quick.db to install it but its giving me an error

lusty dew
#

@junior summit That is how you would require it

#

and quick.db requires some things before you install it

junior summit
#

wot things

lusty dew
#

Personally I suggest using a real database

#

I can't remember them I just know it does.

#

iirc it required build tools or something like that

junior summit
#

wait

#

can u only use

#

nwm

lusty dew
#

But anyway

#

I suggest using a database like

junior summit
#

npm i quick.db i did this

#

but i am not sure

#

wot

#

why it says

gleaming tulip
#

mongoose

#

mlab

#

mongodb

scenic kelp
#

mongodb best

junior summit
#
internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module 'quick.db'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\Users\chillbot\Desktop\ChillBot\discord-bot\bot.js:6:12)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

C:\Users\chillbot\Desktop\ChillBot\discord-bot>pause
Press any key to continue . . .```
lusty dew
#

mongoose is a npm package for mongodb @gleaming tulip

scenic kelp
#

Mlabs offers 500MB free

lusty dew
#

mlab is a hosting for mongodb

slender thistle
#

SQL or non-SQL

gleaming tulip
#

cool

scenic kelp
#

No-SQL

slender thistle
#

Which one to pick is up to you

scenic kelp
#

ftw

junior summit
#

yea

#

no

scenic kelp
#

Mongodb works well with node.js

lusty dew
#

Yea

gleaming tulip
#

mongodb was what discord used to store it's stuff

junior summit
#

wot is mongodb

scenic kelp
slender thistle
#

Isn't it now MariaDB

gleaming tulip
#

GoOGlE

scenic kelp
#
lusty dew
#

Db

#

Database

#

Mongo Database

#

it is a database

#

smh

junior summit
#
    "quick-db": {
      "version": "1.0.5",
      "resolved": "https://registry.npmjs.org/quick-db/-/quick-db-1.0.5.tgz",
      "requires": {
        "archiver": "^1.2.0",
        "bluebird": "^3.4.6",
        "config": "^1.24.0",
        "copy": "^0.3.0",
        "fs-extra": "^1.0.0",
        "mongodb": "^2.2.11",
        "yargs": "^6.3.0"
      }
    },```
#

idk

#

why it wont work

lusty dew
#

Why are you so stuck on quick.db?

#

If you really want to use it

#

Join the support server for that npm package

#

it has one

#

and ask them

opaque eagle
#

Here's all my code as-is: https://github.com/SinistreCyborg/CENSORD```sh
yarn run v1.15.2
$ node -r esm main.js
/Users/sinistercyborg/Projects/censord/main.js:1
Error: Cannot find module './stuctures/CommandStore'
Require stack:

  • /Users/sinistercyborg/Projects/censord/main.js
    at Object.<anonymous> (/Users/sinistercyborg/Projects/censord/main.js:1)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.```
grim aspen
#

i don't know yarn so i can't help

opaque eagle
#

yarn is just another package manager

grim aspen
#

fucking hell

#

imma just go die3

amber fractal
#

well it cant find the module /structures/CommandStore

opaque eagle
#

ik

loud salmon
#

i assume you have tried googling it

opaque eagle
#

yes

loud salmon
#

try uninstalling and reinstalling in npm

opaque eagle
#

wdym

#

it's a local file

loud salmon
#

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

#

idk how npm works

opaque eagle
#

me neither

#

i use yarn

amber fractal
#

if it's a local file, you probably have the wrong path

opaque eagle
#

You can see the github repo above bud

#

That's exactly what my project looks like, without anything censored.

#

Even the name... it's "censord" for real

amber fractal
#

It wouldnt give you this error if it was the correct path bud

opaque eagle
#

But... but... just look at the github repo

earnest phoenix
#

hi im trying to create a snipe command but it wont work if I put the "if (message.content == "snipe"" around it, does anyone know what might cause this? There are no errors as well

hoary helm
#

aAAA every once in a while when my bot sends an embed, the image doesn't show and I have to restart the bot to fix it

amber fractal
#

You misspelled structures @opaque eagle

#

Told you, path is wrong

opaque eagle
#

OMG. YOU. ARE. A. GOD.

#

I've spent the last 4 HOURS tryna figure out what's wrong.

#

It's 11:55 AM here... I first got this error at 7:13 AM

amber fractal
#

You wake up early, it's 11:56 AM here and I just woke up mmLol

opaque eagle
#

Now to go after the other errors that show up

#

nvm

#

me is dumb

amber fractal
#

I was about to say

opaque eagle
#

wait it still shows up if the directory exists

#

It doesn't show in github since the dir is empty

#

GitHub Repo, containing latest version of entire project: https://github.com/SinistreCyborg/CENSORDsh (node:14979) UnhandledPromiseRejectionWarning: TypeError: (intermediate value) is not a constructor at walk (/Users/sinistercyborg/Projects/CENSORD/main.js:25:27)

earnest phoenix
#

do you know javascript

#

How can I make the bot ignore private messages?

   if(primaryCommand=='server'){
        let server_embed=new Discord.RichEmbed()
            .setColor('RANDOM')
            .setFooter(message.guild.owner.user.tag,message.guild.owner.avatarURL)
            .addField('Server Name',`${message.guild.name}`,true)
            .addField('Server ID',`${message.guild.id}`,true)
            .addField('Server Region',`${message.guild.region}`,true)
            .addField('Server Owner',`${message.guild.owner.user}`,true)
            .addField('Owner ID',`${message.guild.owner.id}`,true)
            .addField('Members',`${message.guild.memberCount}`,true)
            .addField('Created At',`${message.guild.createdAt}`)
            .setTimestamp()
    return message.channel.send(server_embed)
    }
opaque eagle
#

yes i know javascript pls help

shrewd lintel
#
bot.on('message', msg => {
  if(message.channel.type !== text) return
})
earnest phoenix
#

dont spoonfeed

opaque eagle
#
// ./events/ready.js
export default class {
   // ok whatever
};``````js
// ./main.js
const events = ["./events/ready"];
events.forEach(event => {
   // how would I import that here
});```
wet wedge
#
C:\Users\nop\OneDrive\Documents\programming stuff\nop\node_modules\discord.js\src\structures\MessageEmbed.js:13
    Object.defineProperty(this, 'client', { value: message.client });
#

help please

#

nvm

marble needle
#

if you're gonna spoonfeed at least do it properly lmao

earnest phoenix
#

.

soft eagle
#
    at Object.module.exports.run (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\commands\mute.js:17:22)
    at Client.bot.on (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\bot.js:153:33)
    at Client.emit (events.js:197:13)
    at MessageCreateHandler.handle (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:197:13)
    at Receiver._receiver.onmessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\websocket.js:137:47)
    at Receiver.dataMessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\receiver.js:409:14)
    at Receiver.getData (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\receiver.js:347:12)
    at Receiver.startLoop (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\receiver.js:143```
#

cant get past that error

#

and i tried message.channel.awaitMessage also it trows the same error

opaque eagle
#
  1. You can't run awaitMessage() on a User. User#awaitMessage() isn't a thing.
  2. It's TextChannel#awaitMessages() (plural), not singular. @soft eagle
soft eagle
#

ik

#

i tried channel its does the same thing

opaque eagle
#

Did you make sure to make it plural?

soft eagle
#
const filter = m => m.content.startsWith(`a.mute ${rUser}`)
      message.reply("Please State A reason this will Expire In 1 Minute").then(r => r.delete(60000));
      message.channel.awaitMessage(filter, {
          max: 1,
          time: 60000
      }).then(collected => {
          if (collected.first().content === "stop") {
              return message.channel.send("stoped")
          }```
opaque eagle
#

So you didn't make it plural like I told you to... have fun then.

soft eagle
#

idek what plural is

#

im going off a video

opaque eagle
#

"apple" is singular. "apples" is plural.
"apples" refers to more than one apple.

#

It's not about code. It's English.

soft eagle
#

oh i see noe

#

awaitMessages not awaitMessage

opaque eagle
#

Yes.

soft eagle
#

lol my brain is dead today

opaque eagle
#

(Then how are you speaking...)

soft eagle
#

idek

#

been up allnight last night

opaque eagle
#

Anyways, does anyone know of a way to shorten this? js // assume that eventPath is a string let event = await import(eventPath); event = new event.default(this);

gleaming tulip
#

? js const event = new (await import(eventPath).default(this))

opaque eagle
#

I think you meant to say const event = new (await import(eventPath)).default(this); but ty

soft eagle
#
(node:10396) UnhandledPromiseRejectionWarning: ReferenceError: m is not defined
    at message.channel.awaitMessages.then.collected (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\commands\mute.js:34:24)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:10396) 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)```
opaque eagle
#

Define m @soft eagle

lusty dew
#

Does anyone know how to use Lavalink?

soft eagle
#
const filter = m => m => m.content.startsWith(rUser);
      
      message.reply("Please say a Reason... Will Expire in 60 seconds!").then(r => r.delete(60000));
      message.channel.awaitMessages(filter, {max:1, time: 60000}).then(collected => {
          if(collected.first().content === "stop") {
              return message.reply("STOPED")
          }```
lusty dew
#

why are you doing m => m =>

#

shouldn't you only have to do that once?

soft eagle
#

ugg my brain realy is dead

lusty dew
#

const filer = m => m.content.startsWith(rUser)

#

filter*

#

Wait, is that filter even correct anyway?

#

Oh wait nvm

#

I am thinking of something else

soft eagle
#
(node:19340) UnhandledPromiseRejectionWarning: TypeError: message.channel.awaitMessages(...).then(...).cacth is not a function
    at Object.module.exports.run (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\commands\mute.js:56:8)
    at Client.bot.on (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\bot.js:153:33)
    at Client.emit (events.js:197:13)
    at MessageCreateHandler.handle (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:197:13)
    at Receiver._receiver.onmessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\websocket.js:137:47)
    at Receiver.dataMessage (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\receiver.js:409:14)
    at Receiver.getData (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\receiver.js:347:12)
    at Receiver.startLoop (C:\Users\Gamea\OneDrive\Desktop\Airi Sena\node_modules\ws\lib\receiver.js:143:16)
gleaming tulip
#

cacth

#

misspelled catch

lusty dew
#

catch*

opaque eagle
#

Use a linter. @soft eagle

soft eagle
lusty dew
#

Does anyone know Lavalink?

#

I mean as how to use it?

soft eagle
#

im using videos here this is why it errors out bc im learning it

#

hard to find help when this happens

opaque eagle
#

The video didn't tell you to misspell catch, did it?

#

jk

#

Just use a linter next time lmao

unique nimbus
#

Using videos doesn't really teach yoy

soft eagle
#

i have autism just letting u know so i freack easily

opaque eagle
#

People who actually have autism don't say that they have autism.

#

Now, please use eslint.

unique nimbus
#

I also got autism however showing off to show sympathy is not good

#

Oof I don't know java script have fun

opaque eagle
#

How can I add a getter on foo.js that gets the filename of bar.js?js // foo.js export class Foo {}``````js // bar.js import { Foo } from "./foo"; export class Bar extends Foo {}``````js // main.js import { Bar } from "./bar"; new Bar();

#

I have an abstract command class that all the command files extend and export. And, rn, the command files have to pass in the name of the command, which I'd like to inference from the command's file's name.

soft eagle
#

this is killing me await msgs trying to get it to work no matter what i do it fails

inner jewel
#

thing.__proto__.constructor.name

#

eg ```js

(new (class C{})()).proto.constructor.name
'C'```

soft eagle
#

@inner jewel can u help me out with something

inner jewel
#

maybe

soft eagle
#

im about to die over it

lusty dew
#
java.lang.IllegalStateException: Failed to load property source from location 'file:./application.yml'```
#

If anyone knows how to use lavalink

#

please explain why this isn't working

inner jewel
#

never used those ยฏ_(ใƒ„)_/ยฏ

#

try using a debuger

lusty dew
#

Hm??

#

A debugger in what?

amber fractal
#

Most IDE's have built in debuggers dont they/

#

?*

lusty dew
#

Yea

#

But what would I be debugging

#

It should all be correct

amber fractal
#

No idea mmLol

lusty dew
#

I was told to copy the application.yml

#

and change it to my liking

#

so I did

earnest phoenix
#

are you sure the yaml file is correctly formatted

lusty dew
#

I copied the example yaml file

#

so it should be

inner jewel
#

i wasn't referring to you @lusty dew

earnest phoenix
#

post it in hastebin

lusty dew
#

@inner jewel Ah ok

#

Lol

#

Thought you was talking to me xD

#

There you go

earnest phoenix
#

it isnt

#

you're missing indentation on the last property

lusty dew
#

Oh?

inner jewel
#

the file in github seems to be broken

earnest phoenix
#

nah the file's fine

inner jewel
#

it isn't

#

i just copy pasted it into a file

#

and the indentation for the last line was gone

earnest phoenix
#

its github cp that doesnt work properly

inner jewel
#

always worked properly for me

#

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

lusty dew
#

I won't lie

#

I had indentation problems with github as well

earnest phoenix
#

adding an extra line with no chars would fix the problem

lusty dew
#

Let's try this again

earnest phoenix
#

otherwise you could just get the raw file and copypaste that

lusty dew
#

See if the problem is fixed now

#

Yep, that worked.

#

Thanks cry I probably would have been sitting here for hours not noticing the indentation problem

earnest phoenix
#

๐Ÿ‘

lusty dew
#
const { Node } = require('lavalink')

module.exports.load = (client) => {

    const voice = new Node({
        password: 'kawaiipanda',
        userID: '',
        shardCount: 0,
        send(guildID, packet) {
            return gateway.connections.get(Long.fromString(guildID).shiftRight(22).mod(this.shardCount)).send(packet);
        },
    });
    client.on('raw', pk => {
        if (pk.t === 'VOICE_STATE_UPDATE') voice.voiceStateUpdate(pk.d);
        if (pk.t === 'VOICE_SERVER_UPDATE') voice.voiceServerUpdate(pk.d);
    });
}
#

oof

#

wrong thing

#

Rip

opaque eagle
lusty dew
#

Client is undefined

#

jkjk

#

Show code as well

#

not just error

amber fractal
#

he did

opaque eagle
#

Yes, I sent the link to a gist

amber fractal
#

it's a github

lusty dew
#

oh

#

Just saw that

#

LOL

amber fractal
#

You arent calling load before the constructor are you?

#

Is that even possible Thonk

#

without it being static

#

Because this is undefined for some reason

opaque eagle
shy rose
#

@mossy vine try in here less other chat

#

so does it show you an error page or does it do that dumb login then leave you at login screen still

mossy vine
#

latter

shy rose
#

cya

trail dagger
#

I am not that person to ask for a code but in this case i am. i need a discord.py async code to stop my bot from responding to other bots

idle basalt
#

i dont ask for code
btw can i get some code

#

just check if the author is a bot with an if statement

trail dagger
#

ok

inner jewel
#

@opaque eagle const f = this.commands.load; f(cmd) and this.commands.load(cmd) are different

idle basalt
#

it changes the meaning of this

inner jewel
#

this.commands.load(cmd) is equivalent to const f = this.commands.load.bind(this.commands); f(cmd)

idle basalt
#

yes good explanation

inner jewel
#

which is stupid but js is full of these things

#

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

idle basalt
#

haha yes thats how you create private variables

#

js is pretty dumb with object-oriented code. i try to stay away from that when possible

lusty dew
#

How could I get my bot connected to the Lavalink server?

#
const { Node } = require('lavalink')

module.exports = (client) => {

    const voice = new Node({
        password: 'secret',
        userID: '561619932442394627',
        send(guildID, packet) {
            return gateway.connections.get(Long.fromString(guildID).shiftRight(22).mod(this.shardCount)).send(packet);
        },
    });
    client.on('raw', pk => {
        if (pk.t === 'VOICE_STATE_UPDATE') voice.voiceStateUpdate(pk.d);
        if (pk.t === 'VOICE_SERVER_UPDATE') voice.voiceServerUpdate(pk.d);
    });
}
#

This is my ode

#

code*

#

I am using

inner jewel
#

looks like it's copy pasted

#

with missing requires

#

and undefined variables

lusty dew
#

yea

#

I am trying to figure this out

#

and define everything

#

it is missing some things

#

like the part on it connecting to the lavalink

#

sever

#

I am using

mossy vine
#

okay im having some issues with cloudflare. or maybe its my nginx config, idk

im trying to run a Flask webserver at test.mydomain.xyz
regularly connecting to it works, but connecting to https://test.mydomain.xyz throws a cloudflare error 521 (web server is down)

my nginx config:

server {
  listen 80;
  listen [::]:80;

  server_name test.mydomain.xyz;

  location / {
      proxy_pass http://localhost:5000/;
  }
}```
inner jewel
#

what encryption settings do you have on cloudflare?

#

depending on the setting, it'll only connect to your server over port 443 (and will expect a valid ssl certificate on your end)

mossy vine
#

ssl is set to full (tried flexible, no change)
always use https is off, as turning it on throws a whole other error

inner jewel
#

try listening over port 443 as well then

#

also, use letsencrypt (certbot) for free ssl certs

mossy vine
#

how do i set up letsencrypt for cloudflare

inner jewel
#

certbot should configure nginx to listen on proper ports

mossy vine
#

oh

inner jewel
#

you don't

mossy vine
#

double oh

inner jewel
#

you just run certbot on your server

#

certbot-auto --nginx --preferred-challenges http renew --renew-hook 'service nginx reload'

#

this is what i use

#

you'll probably have to remove the renew parts

mossy vine
#

so just certbot-auto --nginx 'server nginx reload'?

inner jewel
#

if you just run certbot-auto --nginx --preferred-challenges http it should ask for a list of domains

mossy vine
#

ah

#

can i provide subdomains as well?

inner jewel
#

you may have to disable cloudflare proxy while it grabs the certs

#

it'll detect any domains nginx is listening on

#

including subdomains

#

wildcard is slightly more complicated

#

certbot-auto --nginx --preferred-challenges http --pre-hook "service nginx stop" --post-hook "service nginx start" should work

mossy vine
#

still trying to figure out how to install certbot

#

i have installed certbot but it says certbot-auto: command not found

inner jewel
#

try using only certbot

#

i use certbot-auto because it's two commands user@webserver:~$ wget https://dl.eff.org/certbot-auto user@webserver:~$ chmod a+x ./certbot-auto

mossy vine
#

ow

#

that did not really work

#

nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)

#

installed certbot-auto and ran the same command with it

#
Rolling back to previous server configuration...
nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
lusty dew
#

Doesn't websocket support ports?

mossy vine
#

regular http:// throws error 502 and https:// throws error 521

#

reee

steep hatch
#

help

#
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
mossy vine
#

the connection timed out

steep hatch
#

but I do not connect

#

how to solve

mossy vine
#

then what are you doing

#

are you making a bot? trying to use rich presence? something totally unrelated to discord?

steep hatch
#

I'm doing a bot but it won't open

#

Not logged in

#

He's pinging when he does

mossy vine
#

yes, your connection timed out

#

can you send your code?

steep hatch
#

Which code?

#

Error ?

slender thistle
#

Bot code

#

And the error as well

steep hatch
#
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
(node:14175) 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(). (rejectio                                                                                                 n id: 2)
(node:14175) [DEP0018] DeprecationWarning: Unhandled promise rejections are depr                                                                                                 ecated. In the future, promise rejections that are not handled will terminate th                                                                                                 e Node.js process with a non-zero exit code.
#

I can't send the bot

earnest phoenix
#

are you using any free hosting e.g glitch or heroku

lusty dew
steep hatch
#

noo

lusty dew
#

never heard of tht

earnest phoenix
#

which plan

steep hatch
#

Turk a host

#

pls my help

grim aspen
#

what

earnest phoenix
#
        [Command("New"), Summary("New Ticket")]
        public async Task Ticket(string ChannelName)
        {
            await Context.Guild.CreateRoleAsync(ChannelName);
            var Role = Context.Guild.Roles.FirstOrDefault(x => x.Name == ChannelName);
            await (Context.User as IGuildUser).AddRoleAsync(Role);
            await Context.Guild.CreateTextChannelAsync(ChannelName);
        }

So here's the psudeo of what I'm trying to do:
When the user enters the command the bot will create a private text channel for him and the owner and who ever is also eligable now my problem is that I can't find out how to make the channel private and assign the specified people to it (admins, the user itself)

#

I tried doing it with an shared role there

#

there's a few things that could be fixed up in your code beforehand
CreateRoleAsync returns a RestRole that you can still pass to AddRoleAsync, searching for it with LINQ by name can return the wrong one

#

are you on 1.x or 2.x

#

wdym?

#

2 I think

#

ye

#

2

lusty dew
#
const { Node } = require('lavalink')

module.exports = (client) => {

    const voice = new Node({
        password: 'kawaiipanda',
        userID: '561619932442394627',
        ws: {
            url: "localhost",
            options: {
                port: 2333
            }
        },
        send(guildID, packet) {
            return gateway.connections.get(Long.fromString(guildID).shiftRight(22).mod(this.shardCount)).send(packet);
        },
    });
    client.on('raw', pk => {
        if (pk.t === 'VOICE_STATE_UPDATE') voice.voiceStateUpdate(pk.d);
        if (pk.t === 'VOICE_SERVER_UPDATE') voice.voiceServerUpdate(pk.d);
    });
}

Could I connect to the Lavalink server by doing this? (using http://npmjs.com/package/lavalink)

earnest phoenix
#

CreateTextChannelAsync returns a RestTextChannel, you can then call AddPermissionOverwriteAsync which allows setting permissions for a role/user with specific OverwritePermissions which you can create a new instance of with permissions set to whatever you want, e.g to have the Send Message perm disabled you'd do new OverwritePermissions(sendMessages: PermValue.Deny) @earnest phoenix

gleaming tulip
#

is that your actual password or did you just put that because why not

earnest phoenix
#

thx

lusty dew
#
const { Node } = require('lavalink')

module.exports = (client) => {

    client.lavaLinkConnect = (callback) => {
        const voice = new Node({
            password: 'kawaiipanda',
            userID: '561619932442394627',
            ws: 'localhost:2333',
            send(guildID, packet) {
                return gateway.connections.get(Long.fromString(guildID).shiftRight(22).mod(this.shardCount)).send(packet);
            },
        });
        callback();
    }
    client.on('raw', pk => {
        if (pk.t === 'VOICE_STATE_UPDATE') voice.voiceStateUpdate(pk.d);
        if (pk.t === 'VOICE_SERVER_UPDATE') voice.voiceServerUpdate(pk.d);
    });

}
#

I did this.

gleaming tulip
#

guildID is not defined

#

packet is not defined

#

gateway is not defined

#

Long is not defined

lusty dew
#

it is

#

all in the lavalink files

gleaming tulip
#

hm

#

i've never used lavalink actually

lusty dew
#

that is what the dev told me anyway

#

Welll

#
March 30th 2019, 2:47:26 pm :: Sucessfully connected to Lavalink Server!
March 30th 2019, 2:47:28 pm :: Loaded commands.
March 30th 2019, 2:47:29 pm :: Successfully connected to database.```
#

It looks like it worked...

earnest phoenix
#
AlmeidaToday at 10:51 PM
hm
i've never used lavalink actually```
#

then... don't help and spew bullshit?

lusty dew
#

yea

#

apparently it didn't connect?

#

Idk

#

I pinged localhost:2333

#

and it couldn't find it

earnest phoenix
#

try ws://localhost:2333

lusty dew
#

I did

earnest phoenix
#

hm

oak moat
#

Hmmmmm

#

Maybe NOTHING IS RUNNING THERE?

earnest phoenix
#

does lavalink offer any logs

oak moat
#

;3

lusty dew
#

...

oak moat
#

Wait idk about lavalink

#

Sorry for disturbing

lusty dew
#

Then don't offer help

#

Also yes

oak moat
#

Stfu.

lusty dew
#

Lavalink does have logs

#

I will send them rn

earnest phoenix
#

hastebin them please

#

@oak moat stop being toxic

oak moat
#

Sos bby

lusty dew
#

There

earnest phoenix
#

correct me if im wrong but ws: 'localhost:2333', is supposed to go under a hosts object

lusty dew
#

๐Ÿคฆ

#

I forgot to add that didn't I?

#

I meant to add hosts object as well

#

Fffs

#

I hate myself ....

#

but how do I tell if it really is connected to it?

earnest phoenix
#

codewise or visually

lusty dew
#

visually

#

I think you can ping it and see right?

#

like ping ws://localhost:2333

#

in cmd prompt

earnest phoenix
#

lavalink offers logs

#

you'll see a log come up when you try to connect

inner jewel
#

pinging localhost does nothing

#

also for ping
a) there's no protocol
b) there's no port

lusty dew
#

yea

#
2019-03-30 15:29:24.724  INFO 10596 --- [XNIO-2 task-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-30 15:29:26.478  INFO 10596 --- [XNIO-2 task-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 1743 ms
2019-03-30 15:29:28.829  INFO 10596 --- [XNIO-2 task-1] l.server.io.HandshakeInterceptorImpl     : Incoming connection from /127.0.0.1:52468
2019-03-30 15:29:30.253  INFO 10596 --- [XNIO-2 task-1] c.s.d.l.tools.GarbageCollectionMonitor   : GC monitoring enabled, reporting results every 2 minutes.
2019-03-30 15:29:33.809  INFO 10596 --- [XNIO-2 task-1] lavalink.server.io.SocketServer          : Connection successfully established from /127.0.0.1:52468
2019-03-30 15:29:34.715  INFO 10596 --- [XNIO-2 I/O-4] lavalink.server.io.SocketServer          : {"op":"configureResuming","key":"0.3lziz9p8lrw","timeout":60}
2019-03-30 15:30:40.581  WARN 10596 --- [lava-daemon-pool-manager-3-thread-1] c.s.d.l.tools.GarbageCollectionMonitor   : Suspicious GC results for the last 2 minutes: [Bucket 0 = 0] [Bucket 20 = 0] [Bucket 50 = 2] [Bucket 200 = 2] [Bucket 500 = 0] [Bucket 2000 = 0] 
2019-03-30 15:31:30.300  WARN 10596 --- [lava-daemon-pool-manager-7-thread-1] c.s.d.l.tools.GarbageCollectionMonitor   : Suspicious GC results for the last 2 minutes: [Bucket 0 = 0] [Bucket 20 = 0] [Bucket 50 = 2] [Bucket 200 = 1] [Bucket 500 = 0] [Bucket 2000 = 0] ```
#

it connected!

#

Thanks cry for pointing out my mistake

#

:3

earnest phoenix
#

๐Ÿ‘

lusty dew
#

How do I get the voice channel id that a user is in?

earnest phoenix
#

d.js?

lusty dew
#

ye

amber fractal
lusty dew
#

Thanks

amber fractal
#

Mhm

lusty dew
#

(node:2352) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'players' of undefined

#
            const player = client.music.voice.players.get('561588141761495045');

            player.join(message.member.voiceChannelID)
#

I console logged

#

client.music.voice

#

and it returned undefined

#

and I can't understand why

#

then I did

versed pawn
#

huh

lusty dew
#

const { voice } = require('./library/LavalinkManager.js')

#

and console logged voice

#

and got undefined again

#

I don't know why it is returning undefined

#

it is clearly defined

#
const { Node } = require('lavalink')

module.exports = (client) => {
    const voice = new Node({
        password: 'kawaiipanda',
        userID: '561619932442394627',
        hosts: {
            ws: "ws://localhost:2333"
        },
        send(guildID, packet) {
            return gateway.connections.get(Long.fromString(guildID).shiftRight(22).mod(this.shardCount)).send(packet);
        },
    });
    client.on('raw', pk => {
        if (pk.t === 'VOICE_STATE_UPDATE') voice.voiceStateUpdate(pk.d);
        if (pk.t === 'VOICE_SERVER_UPDATE') voice.voiceServerUpdate(pk.d);
    });

}
#

It is defined

inner jewel
#

it's not exported

lusty dew
#

yea

#

I just saw that

#

I did

#

client.music = voice

#

now I am getting

#

that gateway is undefined

#

(node:3880) UnhandledPromiseRejectionWarning: ReferenceError: gateway is not defined

#
return gateway.connections.get(Long.fromString(guildID).shiftRight(22).mod(this.shardCount)).send(packet);```
lusty dew
#

Nvm I got that fixed

#

Yeet

earnest phoenix
scenic kelp
earnest phoenix
#

i did

#

couldnt find it

#

but i got it

buoyant wagon
#

how do i make the prefix customizable in discord.js?

bright spear
#

@buoyant wagon you'll need to store the prefix for each server in a database

#

and load the prefixes from it

buoyant wagon
#

ok...

bright spear
#

do you use a framework?

#

or are you using your own command handler

buoyant wagon
#

nvm i got it now

sinful lotus
#

@lusty dew what lib

#

is that lavalink

pallid zinc
#

Hello

lusty dew
#

@sinful lotus D.js

#

the lavalink it'self is written in java

#

but I am using d.js

sinful lotus
#

@lusty dew why not try d.js lavalink if you want

lusty dew
#

Huh?

#

d.js lavalink?

inner jewel
lusty dew
#

Oh

#

I know about that one

#

I decided not to use it though

#

Plus I already have everything working

sinful lotus
#

it just simplifies the packet sending

#

if you dont want to use it that fine as well

lusty dew
#

I figured it out

spare glen
#

Hi

scarlet bane
#

So

#

I hear you use glitch

spare glen
#

How do u know

scarlet bane
#

I looked at ur previous messages here

spare glen
#

Ok

scarlet bane
#

i'm thinking

#

maybe you sent server count

#

a while ago

#

and you made it not send anymore

#

but it never changed on dbl site

#

is that possible do you think?

spare glen
#

Maybe

scarlet bane
#

Because that is the only thing i can think of

spare glen
#

Lemme check something

#

I found out

#

I accidently deleted the dbl.on event

scarlet bane
#

that shouldn't change anything

spare glen
#

Apperintly it does

scarlet bane
#

the on only tells you if the stats was sent or not

#

it doesn't affect if it was sent or not

spare glen
#

No look

scarlet bane
#

hm?

spare glen
scarlet bane
#

yes

spare glen
#

Wait

scarlet bane
#
const dbl = new DBL('Your discordbots.org token', client);
spare glen
#

Gotta wake up

scarlet bane
#

that is the important part

#

if you put "client" there, you tell dblapi to send server count

#
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
#

notice how webhook does not have client

#

aka: it wont send data for u

#

and it will only do webhook

potent frost
#

@scarlet bane hey

scarlet bane
#

hey

potent frost
#

ive decide to attack css

scarlet bane
#

how so

potent frost
#

would you like to see what ive decided to fuck up ๐Ÿ˜‚

scarlet bane
potent frost
#

oh right

#

i need to remove that button

scarlet bane
potent frost
#

oh no

#

infinite loops ๐Ÿ˜‚

scarlet bane
#

for some reason it wont let me open it a third time

#

:/

potent frost
#

probs a good thing

scarlet bane
#

sad

potent frost
#

i needa fix it up

#

i recon its cool

spare glen
#

@scarlet bane

#

u there mate

lament meteor
#

aren't u supose to link the client to it rather than ur bot token

potent frost
#

@spare glen u

#

did you retrieve your api token?

spare glen
#

yeah

lament meteor
#

that code u hv only works for webhooks u gotta use ```js
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);

// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})

dbl.on('error', e => {
console.log(Oops! ${e});
})``` to post stats

spare glen
#

so what do i do

#

i dont understand

potent frost
#

so your new to bots?

spare glen
#

no

#

do i have to remove the webhookServer etc and replace it with bot

potent frost
#

webhookServer isnt needed unless you are going to post stats to your website

spare glen
#

i need the webhookServer

#

but what do i do to fix my issue

lament meteor
#

ig u make 2?

spare glen
#

what?

#

wdym?

lament meteor
#
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);
 const dblvote = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
//voting stuff
dblvote.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblvote.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

//Posted stuff
dbl.on('posted', () => {
  console.log('Server count posted!');
})
 
dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})```
#

something like that

earnest phoenix
#

what code can i use to limit my bot's commands usage per person (discordjs)

quartz kindle
#

you can use your brain

earnest phoenix
#

good idea , i don't have one tho

quartz kindle
#

you can grow one

spare glen
#

thank you @lament meteor

west skiff
#

you could make a ratelimiter

spare glen
#
setInterval(() => {
  dblServerCount.on('posted', () => {
    console.log('Server count posted!');
  })
}, 1800000);
#

will this work

west skiff
#

no, because you're just setting a new posted listener

spare glen
#

ok, but how do i make it send server count automaticly, since now i have to restart my bot for it to post, and what if i dont restart in like a month and im at 115 servers but it says 75 on dbl

west skiff
#

lmao you need to post the count in that interval instead of what it's doing right now

spare glen
#

wdym

west skiff
#

in that interval

#

post the server count

spare glen
#

i am

#

aren't i

#

do u have a example

west skiff
#

lmao I'm good. Look at the docs for dblServerCount and you'll find it

spare glen
#

u mean this?

west skiff
#

Yup

spare glen
#

i tried that

#

it didnt work

west skiff
#

setInterval doesn't run immediately after calling

coral trellis
#

Is your bot sharded?

spare glen
#

no

west skiff
#

So you'd have to wait 30 minutes to see the first run

coral trellis
#

Then don't include that, it will error

spare glen
#
const dblServerCount = new DBL("CENSORED", bot);

  bot.on('ready', () => {
    setInterval(() => {
        dblServerCount.postStats(bot.guilds.size);
    }, 1800000);
});
#

so like this?

#

and then i wait 30 min for the first run?

west skiff
#

Idk you could reduce the interval to test it or just run it the first time and then set the interval. Use your brain

quasi forge
#

You could copy paste the post stats outside the interval and inside too to post it once instantly as the bot starts

#

And keep on posting after regular intervals

west skiff
#

Or you could be more efficient and only post results when you join or leave a server

quasi forge
#

That too^

spare glen
#

yep it works

#

i reduced it to 5 sec

late hill
#

But make sure you don't spam in that case^

spare glen
#

and it works

west skiff
#

Ok well you should probably increase it again

earnest phoenix
#

How do I edit an embed description? I've fetched the embed and reacted to it with ๐Ÿ‘. But I want to edit it so it uses the old embed, but adds \n\nResponse from ${message.member.displayName}: ${args.response}

#
        message.guild.channels.find(c => c.name.includes("suggestion")).messages.fetch(args.suggestionID)
        .then(function (message) {
            message.react("๐Ÿ‘")
        });

this is my current code

wicked star
#

@earnest phoenix, try this:

message.guild.channels.find(c =>
c.name.includes("suggestion")).messages.fetch(args.suggestionID)
        .then(function (message) {
            message.react("๐Ÿ‘")
            message.edit(message.embeds.first().setDescription(message.embeds.first().description+`\n\nResponse from ${message.member.displayName}: `+args.response)
        });```
If it doesnt work, tell me
#

Yes, im on my phone, thats why its formatted bad

earnest phoenix
#

stop spoonfeeding

wicked star
#

oh oops

earnest phoenix
#

yeahh no

#

(node:10392) UnhandledPromiseRejectionWarning: TypeError: message.embeds.first is not a function

echo pasture
#

read the error

#

it says message.embeds.first is not a function

wicked star
#

oh, it's an array. try getting the first object instead of .first()

earnest phoenix
#

yeah

#

uh

#

how do I get the first object

wicked star
#

You add this behind the array: [index]
Index is the number, what you want
Keep in mind: Arrays start at 0

Example:

var array = ["Hello","there"]
array[1] // returns there```
earnest phoenix
#

i know how arrays work

#

but im confused

wicked star
#

embeds is an array

earnest phoenix
#

ok

#

but what do I do

sinful lotus
#

get the embed from array

#

you dont work with arrays?

earnest phoenix
#

not that often no

sinful lotus
#

if you said not that often then you know how to access an item in array

earnest phoenix
#

yeah

sinful lotus
#

thats how you do it

earnest phoenix
#

ok

#

but how do i get from an embed

#

ive never edited an embed

sinful lotus
#

use message.embeds

#

its an array. how do you access the first item of array in embed?

earnest phoenix
#

array[0]

sinful lotus
#

then thats how you do it

#

not that hard Thonk

earnest phoenix
#

wait so message.embeds.description[0]?

#

no

sinful lotus
#

no

earnest phoenix
#

Hello, how can I fix this error?

(node:9408) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at item.request.gen.end (F:\eary\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:79:15)
    at then (F:\eary\node_modules\discord.js\node_modules\snekfetch\src\index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:9408) 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: 10)
sinful lotus
#

message.embeds[0] not that

#

smh

earnest phoenix
#

you get the permissions @earnest phoenix

echo pasture
#

@earnest phoenix

sinful lotus
#

I already said that message.embeds is an array

echo pasture
#

your bot missing perms

#

to do a thing

earnest phoenix
#

oh

echo pasture
#

like send messages / ban a member / kick a member

spare glen
#

hi

echo pasture
#

give me administrator perm first

earnest phoenix
#

This error occurs when the bot is always opened.

spare glen
#

how would you send a message to the owner of the server, if the bot doesnt have admin permission

wicked star
#

Your bot is missing permissions somewhere

#

@spare glen I would get the owner from the guild and just send
Should work without permissions

earnest phoenix
#

On which server missing the permissions of my bot, how can I see it?

#

it uses the bots username instead of me

#

im using message.author.tag

wicked star
#

Replace the message in message.member.displayName with your original's message name
idk what your original message is called

#

The message you fetched is called message

earnest phoenix
#

message

#

uh

wicked star
#

Find another name for the one in then

#

msg, fetchedMsg idk

#

your choice

earnest phoenix
#

hmn

#

Python
User configurable Prefix
Anyone have some pointers?

slender thistle
#
async def get_pre(bot, message):
  return "prefix"  # or a list, ["pre1","pre2"]

bot = commands.Bot(command_prefix=get_pre ...

the callable will be called on each command process, and can return something different each time

earnest phoenix
#

nodeJS code to check if the user voted?

#

Hey My .close Command is not working for my ticket system .new does work any help?

#

What language? And paste bin the code.

#

node.js

#

how to get the server icon? I tried in two ways but I did not succeed

.setImage(message.guild.avatarURL)
.setThumbnail(message.guild.avatarURL)
coral trellis
#

Read the docs @earnest phoenix

earnest phoenix
#


module.exports.run = async (Discord, client, message, args) => {

 if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel!`);

  message.channel.send(`Are you sure? Once confirmed, you cannot reverse this action!\nTo confirm, type \`confirm\`. This will time out in 10 seconds and be cancelled.`)
  .then((m) => {
    message.channel.awaitMessages(response => response.content === 'confirm', {
          max: 1,
          time: 10000,
          errors: ['time'],

      })
      .then((collected) => {
        message.channel.delete();
      })
    .catch (() => {
      m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
        m2.delete();
      }, 3000);
    });
});


}```
opaque eagle
#

Weirdly, when I console.log message.flags, I get { node: 'node' }, but when I console.log message.flags.node, I get undefined.

unreal plover
#

where can I find the reason for rejection?

#

about bot approvin

unique nimbus
#

It should of be sent to you by DM

#

and find your bot

whole condor
#

Someone can help me :

was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
 the module (for instance, using `npm rebuild` or `npm install`).

I keep having this error when I play music.

quartz kindle
#

it tells you exactly what you need to do

whole condor
#

yes but it does not work

quartz kindle
#

what did you do

whole condor
#

"npm install"

quartz kindle
#

..

#

do you know what compilation and building means?

opaque eagle
#

My head is about to burst

#
console.log({ flags: message.flags, ok: message.flags["node"] });
// { flags: { node: 'node' }, ok: undefined }```
quartz kindle
#

the only way i can see that happening is if somehow the value is not there yet at the moment its called for some reason. can you try something like setTimeout(() => { console.log(message.flags.node) },100) or something

lusty dew
#

How could I add a timer for like 5m

#

and the bot will leave whatever vc they are in

#

for inactivity

quartz kindle
#

google how to do "timeouts" in whatever language you're using

lusty dew
#

Well I know how to do

#

timeouts

#

I just don't know how to check for inactivity in the vc

#

Does anyone know how to check for inactivity in a vc?

quartz kindle
#

which lib?

lusty dew
#

d.js

quartz kindle
#

try playing around with this

lusty dew
#

Ouuu?

#

Okie

#

Thanks Tim

#

If I have any further questions I will come here :D

#

After goggling them ofc

#

Actually I have a question rn

#

I notice how it says voiceChannel.join

#

then it has all that bit

#

it is making it join the create a receiver?

#
player.join(message.member.voiceChannelID)
.then(connection => {
const  receiver = connection.createReceiver();
})
#

I was wondering if I could do that

#

I am using lavalink

inner jewel
#

then you can't use that

lusty dew
#

Rip.

#

How else would I listen for inactivity?

inner jewel
#

check for leaves

lusty dew
#

Ah, didn't think about that

#

or could I just check for a specific amount of people?

#

like

if(message.guild.me.voiceChannel.members.size === 1)
#

since the bot counts as a member

quartz kindle
#

yeah, you can use setInterval to check for number of people connected, or use the onLeave event (or whatever the event is called)

lusty dew
#

Ah

#

ok

#

I don't know which event you are talking about though

quartz kindle
#

voiceStateUpdate

lusty dew
#

Ah ok

#

Question though.

#

After it gets down to just the bot

#

how do I make it leave after 5m?

earnest phoenix
#

i dont know js, but terminologically i would set up a timer/timeout that fires after 5 minutes, check if there are any users except the bot in the channel and then leave if there arent

lusty dew
#
                    if (message.guild.me.voiceChannel.members.size === 1) {
                        setTimeout(() => {
                            message.guild.me.voiceChannel.leave();
                        }, 1000)
                    }

I had the idea of doing this.

#

cause I heard the bot counts as a member in the vc

#

But it threw an error since when I do -joinc

#

it isn't in a vc yet so it threw the error

#

saying TypeError: Cannot read property 'members' of undefined

quartz kindle
#

you should wait for the bot to join the channel

lusty dew
#

Yea, I had that thought.

quartz kindle
#

first make the bot join the channel, and wait for the promise, then create a setInterval that checks for members size

#

if the check passes, leave channel and destroy the setInterval

#

also dont forget to destroy the setInterval when manually making the bot leave

lusty dew
#

Wait how do I wait for the promise?

quartz kindle
#

await or .then()

#

depending on your setup

lusty dew
#

Ah ok

#

and sorry for being dumb

#

but how do I create an interval that checks for the member size?

quartz kindle
#

give it a function

#

same as setTimeout

earnest phoenix
#

why is channel.deletemessagesasync missing for me

lusty dew
#
.setInterval(() => {
//check member count here
})
#

like that?

quartz kindle
#

yes, just missing the timer

lusty dew
#

yea

quartz kindle
#

and without the .

lusty dew
#

Ah yea

#

Always forget that

#

Lol

#

I do the same thing with setTimeout

#

wait how would I do it with .then

#

I am probably being dumb

#

brb

#
                player.join(message.member.voiceChannelID).then( msg => {
                    setInterval(() => {
                        if(msg.guild.me.voiceChannel.members.size === 1){
                            msg.guild.me.voiceChannel.leave();
                        }
                    }, 1000 * 60 * 5)
                })
#

So something like this?

inner jewel
#

you'd need to store the value returned by setInterval

#

and stop it when leaving

#

otherwise you're going to spam useless tasks forever

#

and probably leak all your memory over time

lament meteor
#

iirc the function for it is clearInterval(variable of the interval)

inner jewel
#

yes

lament meteor
#

and probs u would attach it to a cache ig

quartz kindle
#

ye

lusty dew
#

cache?

#

Never worked with that before

inner jewel
#

or even better

quartz kindle
#

you will need a cache so you can access it both from inside the function and also from an external call like a leave command

inner jewel
#

don't use timers

#

use events

lament meteor
#

tru

inner jewel
#

on event, check if vc empty/has only bots

#

if true, schedule a leave

#

on join, check if leave is scheduled

#

if yes, cancel it

lusty dew
#

so I could use voiceStateUpdate

#

?

#

Like tim said earlier

quartz kindle
#

yes

inner jewel
lusty dew
#

Ah mk

#

I will try and use and use

#

voiceStateUpdate

#

real quick

#

if I have any further questions I will ask :3

#

Thanks for the help so far guys.

quartz kindle
#

showing god knows what language as an example for a javascript problem

#

lmao

inner jewel
#

that's what i use and has worked for the past 18 months

west raptor
#

it's not that hard to really understand what's going on tbh

quartz kindle
#

it is if you're not very experienced with programming

lusty dew
#

I can kinda understand what is going on

#

thing is what language even is that?

inner jewel
#

scala

lusty dew
#

Ah ok.

lusty dew
#

for the event

#

would I check the member size of the vc

#

using oldMember?

earnest phoenix
#
    usage: "[video url (Youtube, Vimeo)",
    description: "ArkadaลŸlarฤฑnla video izleyebilmek iรงin watch2gether'de oda oluลŸturur!",
    process: function(bot,msg,suffix){
        var watch2getherUrl = "https://www.watch2gether.com/go#";
        msg.channel.send(
            "watch2gether link").then(function(){
                msg.channel.send(watch2getherUrl + suffix)
        })
    }
}```
#

what is the problem?

#

!important

amber fractal
#

not in here

#

lol

#

in your code, it's a css tag

earnest phoenix
#

lel

steep hatch
#

hello

#
client.on('message', async message => {
                     ^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.runMain (module.js:611:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:160:9)
#

Help me

gleaming tulip
#

async function (message) {

}

mossy vine
#

can you send your whole code?

gleaming tulip
#

or async (message) => {} that should work as well maybe

mossy vine
#

async message => {} should work

amber fractal
#

You're missing a closing braxket

gleaming tulip
#

uhm

amber fractal
#

bracket*

#

he is

scenic kelp
#

Yeah he's most likely missing the closing ) after the function

#

client.on('message', (message) => {

});

spring ember
#

the parentheses aren't needed for 1 argument lambda function

steep hatch
#

.

amber fractal
#

Why post a dot

#

It helps no one

west spoke
#

Mmmmmhok

earnest phoenix
#

Heyo

#

Need some help quick.

#

I have my bots files on both my PC and my VPS

west spoke
#

...?

mossy vine
#

does vscode not have intellisense for pip modules/packages/whatevertheyrecalled?

west spoke
#

Are you trying to edit the VPS or computer file?

earnest phoenix
#

When it's running off of my PC, it is able to flaulessly run every command, However, When it's on the VPS, it is unable to run any command that used the dblapi.js module.

mossy vine
earnest phoenix
#

are you using any free hosting

west spoke
#

The VPS may not support it

earnest phoenix
#

How would i know if it supports it or not?

#

which host are you using

west spoke
#

^

earnest phoenix
#

And no, It's not free hosting, Its a contaboo 300 VPS

mossy vine
#

what do you mean by "unable to run command"

#

does it give an error?

earnest phoenix
#

No, I have a command which is ss!voted, That checks to see if the user voted, When its on my PC it will either tell them that they have or haven't voted, When it's on my VPS, is doesn't respond.

#

It has 0 error messages from what i can see

slender thistle
#

@mossy vine It shows what was entered in the file before

#

Or something of that sort

mossy vine
#

i managed to fix it by adding

"python.autoComplete.extraPaths": [
        "/home/cyber28/.local/lib/python2.7/site-packages"
    ]```
to my vscode settings.json file
earnest phoenix
#
npm ERR! path /home/screensharebot/node_modules/dblapi.js/npm-shrinkwrap.json
#

anyone have any clue on how the fix this

#

this is the error

#
npm ERR! code ELOOP
npm ERR! errno -40
npm ERR! syscall open
npm ERR! ELOOP: too many symbolic links encountered, open '/home/screensharebot/node_modules/dblapi.js/npm-shrinkwrap.json'
#

Full error there

proud pivot
scenic kelp
#

@spring ember I know they aren't needed, but I still like to use them for consistency

lime fiber
#

How to check that a user is in a same voice channel as the bot? Python


        server = ctx.message.server
        uservoice = ctx.message.author.voice.voice_channel
        botvoice = client.voice_client_in(server)
        if uservoice == botvoice:

Some code here, but it doesn't important for this question....

I tried this, but it didn't work. I got the something that I wrote in the ** else:** thing.

earnest phoenix
#

first check if uservoice is None, then compare their ids

lime fiber
#

ok, thanks

glacial sentinel
#

Are the webhooks not working only for me?

#

Worked before ๐Ÿ˜…

#

Testing seem to not do anything either

spring ember
#

Same

glacial sentinel
#

@bitter sundial EyesFalling

#

Webhooks not working

#

Kinda major

lusty dew
#

How do I get a bot to leave a voice channel?

#

isn't it

#

message.guild.me.voiceChannel.leave();

amber fractal
#

Should be

earnest phoenix
#

if you're using lavalink do it through lavalink

#

actually no nvm i forgot lavalink just sends packets it doesnt control connecting

lusty dew
#

Yea

#

I looked at lavalink

#

and it just makes it join

#

not leave

#

and I just tried

#

message.guild.me.voiceChannel.leave()

#

nothing happened

#

not even any errors

spare glen
#

Are webhooks working now

lusty dew
#

Hm?

earnest phoenix
#

After 5 hours

#

I have given up

#

that's it

#

just

#

no- I will not have any checks for if they voted.

#

that's it

#

I never want to type npm i dblapi.js --save or any other variant again

dull bobcat
#

can i share my projects here or is this just like, "helping" channel?

coral trellis
#

This is for help with bot development, so if you have problem with coding your bot, you can come here

alpine cliff
#

how can the bot get 2 prefixes?

buoyant wagon
#
if (!(message.content.startsWith(prefix) || message.content.startsWith(prefix2)))```
alpine cliff
#

@buoyant wagon how can i const that?

buoyant wagon
#

u can use a list then see if it starts with a prefix in the list

alpine cliff
#

hmmm

#

how can i do that

buoyant wagon
#
const prefixes = [prefix1, prefix2];
for (var i = 0; i < prefixes.length; i++) {
    if (message.content.startsWith(prefixes[i]) {//run some code}
}```
#

well i used something different

alpine cliff
#

hmmmm

#

i will test that

#

wait a minute

#

hmmm

buoyant wagon
#

nvm u do

amber fractal
#

you could probably use regex

alpine cliff
#

what is regrex

amber fractal
#

Regular Expressions

alpine cliff
#

hmmm

#

what do i do

#

@amber fractal

amber fractal
#

The easiest way would probably be to use the loop

alpine cliff
#

ok

#

but