#development
1 messages ยท Page 595 of 1
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);
Oh ok, im using DBeaver to create colums and such, when I create the colum should it be a string value or json/jsonb
string
Ahh ok, and then just JSON.parse the variable in code when retrieving the data
yes
and JSON.stringify when updating
this is how im updating atm .update('yesu', JSON.stringify(yesUsers.push(user.id)))
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
so the column chould be json type then
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
Ok will give that ago and come back inevitably lol
at JSON.parse (<anonymous>)```
const yesUsers = JSON.parse(poll.yesu);
console.log(poll.yesu);
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
I cant because it wont get past the json parse bit
try catch the parse
let yesUsers;
try {
yesUsers = JSON.parse(poll.yesu);
} catch () {}```

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
er
yesUsers.push() returns the length of the array
not the result of the push
you need to stringify yesUsers itself
OMG im so stupid
hah we all come across some mistake we make like that
Thank you aha it is working now ๐
What is more efficient for just simple arrays, string or json type?
both are string
json just helps you identify the field stores json data and not just random strings
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
np
Just another quick question since your so helpful aha, everytime I delete a id from the array it leaves null, any quick fix?
how are you deleting it
await delete noUsers[i];
i is just the num of loop when it finds the correct entry
delete sets it to undefined/null
Ahh ok, is there a .pop/.slice sort of method to removing it?
splice
let test = [1,2,3];
console.log(test);
test.splice(1, 1);
console.log(test);```
> Array [1, 3]```
Oh i see
splice( index, count )
yes yes, cool thank you so much ๐
make me feel like a day 1 noob again XD
thats as simple as .splice(i, 1) ๐
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
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
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
Yes i need to be more 'console.log' dependent, I always assume too much
Again thank you, ๐

Memes go to #memes-and-media my fam
How do we add sites to the description?
What lib
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?
Array.toString()?
Becasue I am adding more to it
What's the equivalent of __dirname in import/export syntax?
is this correct const db = require('quick.db');? I also used npm i quick.db to install it but its giving me an error
@junior summit That is how you would require it
and quick.db requires some things before you install it
wot things
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
mongodb best
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 . . .```
mongoose is a npm package for mongodb @gleaming tulip
Mlabs offers 500MB free
mlab is a hosting for mongodb
SQL or non-SQL
cool
No-SQL
Which one to pick is up to you
ftw
Mongodb works well with node.js
Yea
mongodb was what discord used to store it's stuff
wot is mongodb

Isn't it now MariaDB
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
"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
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
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.```
i don't know yarn so i can't help
yarn is just another package manager
well it cant find the module /structures/CommandStore
ik
i assume you have tried googling it
yes
try uninstalling and reinstalling in npm
if it's a local file, you probably have the wrong path
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
It wouldnt give you this error if it was the correct path bud
But... but... just look at the github repo
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
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
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
You wake up early, it's 11:56 AM here and I just woke up 
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)
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)
}
yes i know javascript pls help
bot.on('message', msg => {
if(message.channel.type !== text) return
})
dont spoonfeed
// ./events/ready.js
export default class {
// ok whatever
};``````js
// ./main.js
const events = ["./events/ready"];
events.forEach(event => {
// how would I import that here
});```
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
if you're gonna spoonfeed at least do it properly lmao
.
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
- You can't run awaitMessage() on a User.
User#awaitMessage()isn't a thing. - It's
TextChannel#awaitMessages()(plural), not singular. @soft eagle
Did you make sure to make it plural?
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")
}```
So you didn't make it plural like I told you to... have fun then.
"apple" is singular. "apples" is plural.
"apples" refers to more than one apple.
It's not about code. It's English.
Yes.
lol my brain is dead today
(Then how are you speaking...)
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);
? js const event = new (await import(eventPath).default(this))
I think you meant to say const event = new (await import(eventPath)).default(this); but ty
(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)```
Define m @soft eagle
Does anyone know how to use Lavalink?
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")
}```
ugg my brain realy is dead
const filer = m => m.content.startsWith(rUser)
filter*
Wait, is that filter even correct anyway?
Oh wait nvm
I am thinking of something else
(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)
catch*
Use a linter. @soft eagle
im using videos here this is why it errors out bc im learning it
hard to find help when this happens
The video didn't tell you to misspell catch, did it?
jk
Just use a linter next time lmao
Using videos doesn't really teach yoy
i have autism just letting u know so i freack easily
People who actually have autism don't say that they have autism.
Now, please use eslint.
I also got autism however showing off to show sympathy is not good
Oof I don't know java script have fun
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.
this is killing me await msgs trying to get it to work no matter what i do it fails
thing.__proto__.constructor.name
eg ```js
(new (class C{})()).proto.constructor.name
'C'```
@inner jewel can u help me out with something
maybe
can u help me with awaitMessages
i keep getting errors or it dosnt do anything
https://hastebin.com/latuyuzaku.js
im about to die over it
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
No idea 
are you sure the yaml file is correctly formatted
i wasn't referring to you @lusty dew
post it in hastebin
Oh?
the file in github seems to be broken
nah the file's fine
it isn't
i just copy pasted it into a file
and the indentation for the last line was gone
its github cp that doesnt work properly
adding an extra line with no chars would fix the problem
Let's try this again
otherwise you could just get the raw file and copypaste that
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
๐
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
https://gist.github.com/SinistreCyborg/e2ead7f2ca89aa5560d1601bddb92eb8sh (node:16515) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'client' of undefined at load (/Users/sinistercyborg/Projects/Felicia/structures/CommandStore.js:11:67)
he did
Yes, I sent the link to a gist
it's a github
You arent calling load before the constructor are you?
Is that even possible 
without it being static
Because this is undefined for some reason
Hmm... weirdly, changing the callback on this line to cmd => this.commands.load(cmd) did the trick:
(Links you directly to line): https://gist.github.com/SinistreCyborg/e2ead7f2ca89aa5560d1601bddb92eb8#file-main-js-L25
@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
latter
cya
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
i dont ask for code
btw can i get some code
just check if the author is a bot with an if statement
ok
@opaque eagle const f = this.commands.load; f(cmd) and this.commands.load(cmd) are different
it changes the meaning of this
this.commands.load(cmd) is equivalent to const f = this.commands.load.bind(this.commands); f(cmd)
yes good explanation
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
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
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
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/;
}
}```
what encryption settings do you have on cloudflare?
Understand which Cloudflare SSLย options encrypt traffic between Cloudflare and the origin web server.
Overview
The SSLย section of the Cloudflare Cryptoย app contains several options that determine ...
depending on the setting, it'll only connect to your server over port 443 (and will expect a valid ssl certificate on your end)
ssl is set to full (tried flexible, no change)
always use https is off, as turning it on throws a whole other error
try listening over port 443 as well then
also, use letsencrypt (certbot) for free ssl certs
how do i set up letsencrypt for cloudflare
certbot should configure nginx to listen on proper ports
oh
you don't
double oh
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
so just certbot-auto --nginx 'server nginx reload'?
if you just run certbot-auto --nginx --preferred-challenges http it should ask for a list of domains
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
still trying to figure out how to install certbot
i have installed certbot but it says certbot-auto: command not found
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
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"
Doesn't websocket support ports?
the connection timed out
then what are you doing
are you making a bot? trying to use rich presence? something totally unrelated to discord?
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
are you using any free hosting e.g glitch or heroku

never heard of tht
which plan
what
[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?
on which discord.net version are you
2 I think
ye
2
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)
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
is that your actual password or did you just put that because why not
thx
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.
guildID is not defined
packet is not defined
gateway is not defined
Long is not defined
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...
AlmeidaToday at 10:51 PM
hm
i've never used lavalink actually```
then... don't help and spew bullshit?
yea
apparently it didn't connect?
Idk
I pinged localhost:2333
and it couldn't find it
try ws://localhost:2333
I did
hm
does lavalink offer any logs
;3
...
Stfu.
Sos bby
correct me if im wrong but ws: 'localhost:2333', is supposed to go under a hosts object
๐คฆ
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?
codewise or visually
visually
I think you can ping it and see right?
like ping ws://localhost:2333
in cmd prompt
pinging localhost does nothing
also for ping
a) there's no protocol
b) there's no port
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
๐
How do I get the voice channel id that a user is in?
d.js?
ye
Thanks
Mhm
(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
huh
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
it's not exported
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);```
how do i check if a user has a role in discord.py?

how do i make the prefix customizable in discord.js?
@buoyant wagon you'll need to store the prefix for each server in a database
and load the prefixes from it
ok...
nvm i got it now
Hello
@lusty dew why not try d.js lavalink if you want
Oh
I know about that one
I decided not to use it though
Plus I already have everything working
I figured it out
Hi
How do u know
I looked at ur previous messages here
Ok
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?
Maybe
Because that is the only thing i can think of
that shouldn't change anything
Apperintly it does
the on only tells you if the stats was sent or not
it doesn't affect if it was sent or not
No look
hm?
yes
Wait
const dbl = new DBL('Your discordbots.org token', client);
Gotta wake up
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
@scarlet bane hey
hey
ive decide to attack css
how so
ladies and gentlemen, we gotem
probs a good thing
sad
@scarlet bane
u there mate
https://hastebin.com/ulasosoyep.coffeescript
Thats my dbl code, and it still doesn't upload the server count to dbl
aren't u supose to link the client to it rather than ur bot token
yeah
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
so your new to bots?
webhookServer isnt needed unless you are going to post stats to your website
ig u make 2?
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
what code can i use to limit my bot's commands usage per person (discordjs)
you can use your brain
good idea , i don't have one tho
you can grow one
thank you @lament meteor
you could make a ratelimiter
setInterval(() => {
dblServerCount.on('posted', () => {
console.log('Server count posted!');
})
}, 1800000);
will this work
no, because you're just setting a new posted listener
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
lmao you need to post the count in that interval instead of what it's doing right now
wdym
lmao I'm good. Look at the docs for dblServerCount and you'll find it
Yup
setInterval doesn't run immediately after calling
Is your bot sharded?
no
So you'd have to wait 30 minutes to see the first run
Then don't include that, it will error
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?
Idk you could reduce the interval to test it or just run it the first time and then set the interval. Use your brain
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
Or you could be more efficient and only post results when you join or leave a server
That too^
But make sure you don't spam in that case^
and it works
Ok well you should probably increase it again
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
@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
stop spoonfeeding
oh oops
yeahh no
(node:10392) UnhandledPromiseRejectionWarning: TypeError: message.embeds.first is not a function
oh, it's an array. try getting the first object instead of .first()
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```
embeds is an array
not that often no
if you said not that often then you know how to access an item in array
yeah
thats how you do it
use message.embeds
its an array. how do you access the first item of array in embed?
array[0]
no
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)
you get the permissions @earnest phoenix
@earnest phoenix
I already said that message.embeds is an array
oh
like send messages / ban a member / kick a member
hi
give me administrator perm first
This error occurs when the bot is always opened.
how would you send a message to the owner of the server, if the bot doesnt have admin permission
Your bot is missing permissions somewhere
@spare glen I would get the owner from the guild and just send
Should work without permissions
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
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
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
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)
Read the docs @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);
});
});
}```
Hmm... Code: https://gist.github.com/SinistreCyborg/76b583a3536f398a8d01b6385dbd0403
Even though message.flags.node is a truthy value, it always sends the result of this.normalStats()...
When I console.log message.flags, I get this: { node: 'node' }
Weirdly, when I console.log message.flags, I get { node: 'node' }, but when I console.log message.flags.node, I get undefined.
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.
it tells you exactly what you need to do
yes but it does not work
what did you do
"npm install"
My head is about to burst
Code: https://gist.github.com/SinistreCyborg/76b583a3536f398a8d01b6385dbd0403
Even though message.flags.node is a truthy value, it always sends the result of this.normalStats()...
When I console.log message.flags, I get this: { node: 'node' }
console.log({ flags: message.flags, ok: message.flags["node"] });
// { flags: { node: 'node' }, ok: undefined }```
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
How could I add a timer for like 5m
and the bot will leave whatever vc they are in
for inactivity
google how to do "timeouts" in whatever language you're using
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?
which lib?
d.js
try playing around with this
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
then you can't use that
check for leaves
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
yeah, you can use setInterval to check for number of people connected, or use the onLeave event (or whatever the event is called)
voiceStateUpdate
Ah ok
Question though.
After it gets down to just the bot
how do I make it leave after 5m?
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
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
https://hastebin.com/jodejolecu.js (full command if anyone needs it)
you should wait for the bot to join the channel
Yea, I had that thought.
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
Wait how do I wait for the promise?
Ah ok
and sorry for being dumb
but how do I create an interval that checks for the member size?
why is channel.deletemessagesasync missing for me
yes, just missing the timer
yea
and without the .
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?
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
iirc the function for it is clearInterval(variable of the interval)
yes
and probs u would attach it to a cache ig
ye
or even better
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
tru
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
yes
something like this https://javascript.is-bad.com/2wem6NK.png
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.
that's what i use and has worked for the past 18 months
it's not that hard to really understand what's going on tbh
it is if you're not very experienced with programming
scala
Ah ok.
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
lel
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
async function (message) {
}
can you send your whole code?
or async (message) => {} that should work as well maybe
async message => {} should work
You're missing a closing braxket
uhm
Yeah he's most likely missing the closing ) after the function
client.on('message', (message) => {
});
the parentheses aren't needed for 1 argument lambda function
.
Mmmmmhok
...?
does vscode not have intellisense for pip modules/packages/whatevertheyrecalled?
Are you trying to edit the VPS or computer file?
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.
are you using any free hosting
The VPS may not support it
^
And no, It's not free hosting, Its a contaboo 300 VPS
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
@mossy vine It shows what was entered in the file before
Or something of that sort
i managed to fix it by adding
"python.autoComplete.extraPaths": [
"/home/cyber28/.local/lib/python2.7/site-packages"
]```
to my vscode settings.json file
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
its a python youtube_dl play after a while i have this eror ๐ฆ
@spring ember I know they aren't needed, but I still like to use them for consistency
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.
@proud pivot Try this:
first check if uservoice is None, then compare their ids
ok, thanks
Are the webhooks not working only for me?
Worked before ๐
Testing seem to not do anything either
Same
How do I get a bot to leave a voice channel?
isn't it
message.guild.me.voiceChannel.leave();
Should be
if you're using lavalink do it through lavalink
actually no nvm i forgot lavalink just sends packets it doesnt control connecting
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
Are webhooks working now
Hm?
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
can i share my projects here or is this just like, "helping" channel?
This is for help with bot development, so if you have problem with coding your bot, you can come here
how can the bot get 2 prefixes?
if (!(message.content.startsWith(prefix) || message.content.startsWith(prefix2)))```
@buoyant wagon how can i const that?
u can use a list then see if it starts with a prefix in the list
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
nvm u do
you could probably use regex
what is regrex
Regular Expressions
The easiest way would probably be to use the loop
