#development
1 messages · Page 1203 of 1
try running it in worker mode
because in process mode you're wasting a ton of resources
18 processes for 17k guilds is way too much
aye, especially if you've only got 1 cpu
@faint prism but then I can just do normal methods on it like it existed and mongodb will create the collection anyways
@earnest phoenix Try to get the value for a collection, if it returns null it doesn't exist. Unless you are telling it to insert/upsert, then it won't create the collection?
aye still
the optimal setup in this situation would be 7-8 processes with 2-3 shards each
im getting an UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot execute action on a DM channel
what does that mean
in my console btw
i see, i shall give that a shot Tim
so if i do:
client.db("userData").collection(userID /*/ no need to worry userID is defined /*/).insertOne(userData,(err,result) => {
if (err) throw err;
});
Will it throw an error if the collection doesn't exist since you can't run functions on null
yes ik i have the worst way of storing user data cuz YEEEEEEES
im pretty sure mongodb creates it if it doesnt exist
^
how do i handle shards with shoukaku? I just change this?
that'll take up shit tonne of index space from what i recall
just use one collection and make a new doc

what the hell is Shoukaku
db should be per process, for example .db(bot name)
then collection should be a section of your bot, for example .db(bot name).collection(users)
@earnest phoenix client.db("userData").collection(userID) wouldn't this return null if it's empty?
So can't you check it like this?
let collectionData = client.db("userData").collection(userID)
if (!collectionData) // is non-existant
my db does nothing but store my bot data
idk if that'd work, but 🤷♂️
k
so its .db("data").collection("prefixes") etc etc
lemme https://tryitands.ee
What happens if we delete our bot once after we get the Dev badge
imagine throwing the tryitandsee bomb on yourself that's suicide

What happens if we delete our bot once after we get the Dev badge
@earnest phoenix but WHY
oops, sorry mods 
how do i handle shards with shoukaku? I just change this?
@tight plinth afaik, there's nothing documented on a shard manager in shoukaku
hm
same in the source
will ask in the support server of shoukaku ig
well it seems to me its on purpose they dont have one built in
you could use d.js shard manager or another one out there
hm
What the difference between 5 mph and 20 mph other than speed
Oh the hertz difference
That's the wave size iirc
So 2.4 has a longer range and less bandwidth than 5ghz
higher frequency gives you higher speed limit in exchange for shorter signal distance
^
higher frequency also has stronger power, which makes it less susceptible to interference
My router is modern
there is no difference unless your actual internet speed is 100mb+
802.11n's theorical limit is 300mbps
My router has a 150 limit
But it’s not like a crap 150
It’s a good 150 it’s just my service provider
well, theorical limits are from the technology itself, so the sellers arent really lying
but real world implementations never reach these because of interference, material quality, etc
also, the theorical speeds are likely for a single link, while real world uses multiple links, ie upload+download
then you also have to factor in how many devices are connected
whats the colour for rounded embeds again
Yeah I found out my router can reach about a quarter of a mile or half a mile I can’t tell very well
thanks shiv
oh
u can do it in js maybe I could translate it
well in js you could split by spaces, and check if the first string[0] contains the bot's ID
Depends on if you want bot mention to be a prefix or just literally check for mention
startsWith()
yea but in a on_message event no?
and|| operator
something like:
if theMsg.split(' ')[0].contains(botId)
Depends on if you want bot mention to be a prefix or just literally check for mention
@slender thistle literally check for mention
So it's not a prefix?
or that yeah, but have fun parsing it
no
[
'���',
MessageReaction {
message: Message {
channel: [TextChannel] ...
``` ```for (const value of collected) {
console.log(value)
}``` I'm Having Trouble accessing values from a awaitReactions Colllection
just the mention
How can I access the object?
if (message.content.startsWith(prefix) || message.content.startsWith(mention)) => execute code

or check regex
message.content.replace("<@!", "<@") == client.user.mention
cuz ! might annoy a bit
like this
/<@!?BOT_ID>/.test(message.content)
They asked py code tho
you can do regex too so you dont have to do another check for nickname
haha the !? is a great use for that optional pattern
eh regexes in Python are trickier than that
mhmm
eh
I'd use ==
That's not as robust
but yeah
What if its <@!botId>?
Gotta handle that
@floral creek remember what i said? nickname
and how do u send msg in on_message event?
you COULD use mentions aswell
as a parameter
idk how py handles it, but message payload also comes with mentions in it
message.mentions
^^
could probably use that aswell rather than matching content if regex isnt as easy as js
is js you have a test() method
Honestly, though. That'll only check if a mention is included
message.mentions
@slender thistle You'd have to parse something like this then, yeah?
something @bot command
@bot command
something @bot
but you could use mentions aswell to snag the id
add message parameter to the function
dont you need in?
Also, don't use str
why?
I gave them that talk a few minutes ago and meh
because you'd be converting True to string
i assume equal operator would be perfect match
and that will be a true value always
Py?
since "True" is not an empty string
I know
How i can cut lines ?
py also has startswith() no?
How i can cut lines ?
@earnest phoenix ??
Yeah it does, but they want to reply to just a mention
oh i see
they want to reply to @bot
so they check basically if the message.content (mention) is in the string
oh i see
Hi i ave a little Problem with discord.js: I just fresh installed it but now i cant login into the user and it just gives this error:
_http_agent.js:444
options = req[kRequestOptions];
^
TypeError: Cannot read property 'Symbol(requestOptions)' of undefined
at Agent.removeSocket (_http_agent.js:444:20)
at Agent.<anonymous> (_http_agent.js:171:10)
at Agent.emit (events.js:314:20)
at TLSSocket.onFree (_http_agent.js:362:11)
at TLSSocket.emit (events.js:314:20)
at emitFreeNT (_http_client.js:725:16)
at processTicksAndRejections (internal/process/task_queues.js:79:21)
so they check basically if the message.content (mention) is in the string
@slender thistle string
Cool thanks guys
use == please
and I meant literally add a second statement that starts with or
or maybe I didn't even send it
content == mention with <@! or content == mention with <@
Use it in embed description or field value
those are the only fields that support custom emojis
Ah, thanks
how i can check length of this eval(args.slice(0).join(" ")) and slice it to 2000 characters
: ))
Slice '2000'?
yes
eval(args.slice(2000).join(" "))
Hi i ave a little Problem with discord.js: I just fresh installed it but now i cant login into the user and it just gives this error:
_http_agent.js:444 options = req[kRequestOptions]; ^ TypeError: Cannot read property 'Symbol(requestOptions)' of undefined at Agent.removeSocket (_http_agent.js:444:20) at Agent.<anonymous> (_http_agent.js:171:10) at Agent.emit (events.js:314:20) at TLSSocket.onFree (_http_agent.js:362:11) at TLSSocket.emit (events.js:314:20) at emitFreeNT (_http_client.js:725:16) at processTicksAndRejections (internal/process/task_queues.js:79:21)
how do u turn a int into a string
what language
oki
nah?
a init to string
that makes a string into a number afaik
not string to number
silly Lite :p
@misty sigil how do u slice ur eval output ?
i feel like toString() should have worked 😔
I use a paginator
paginator ?
yes
oh
but how u slice the first page
like the output is 1000+ lines
and how u slice it ?
@cunning gorge how did you use it, because it should work.
i genuinely cannot see the music code
@misty sigil
if (message.content.startsWith(`${prefix}play`)) {
function play(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));
server.queue.shift();
server.dispatcher.on("end", function() {
if (server.queue[0]) {
play(connection, message);
} else {
connection.disconnect();
}
});
}
const args = message.content.slice(prefix.length).split(' ');
const command = args.shift().toLowerCase();
if (!args[0]) {
message.channel.send("You need to provide a link!");
return;
}
/* Old connection code
const channel = message.member.voice.channel;
if (!message.member.voice.channel || channel.join == null) {
message.channel.send("You must be in a voice channel!");
return;
} else {
channel.join().then(connection => console.log('Connected!')).catch(console.error);
}
*/
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
const channel = message.member.voice.channel;
if (!message.member.voice.channel || channel.join == null) {
channel.join().then(function(connection) {
play(connection, message);
})
}
}
Regarding: https://discordapp.com/channels/264445053596991498/272764566411149314/749639149405077534
this part doesnt make sense
!message.member.voice.channel || channel.join == null)
your bot only joins the voice channel if the channel doesnt exist
it send the embed but the img dosent load
Alright. My bot joined the VC, however I get this error:
https://hatebin.com/dewhugnqwa
Updated code: https://hatebin.com/lqiderqyus
The role not existing is not related to the music, however the last error is.
(once again using OpusScript and FFMPEG to malke a music bot)_
hey @quartz kindle so i started messing around with worker mode in dev environment and i'm getting this error: TypeError: Cannot set property message of which has only a getter it seems to be happening when using broadcastEval? i've done some digging and really haven't seen anyone come across a solution
const evaluted = eval(args.slice(0).join(" "));
let array = stringTools.toChunks(JSON.stringify(evaluted), 5);
const narary = array.slice(0, Math.floor((1500 / 5))).join('');
console.log(narary.length);
let output = `\`\`\`json\n${beautify(narary, {
format: "json",
})} \n\`\`\``
await message.channel.send(`Type of: ${typeof(evaluted)}`);
message.channel.send(output);
length = 1500
(node:7280) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
content: Must be 2000 or fewer in length.
Best logic ever seen
beautify(narary, {format: "json"}).length
beautify first, check length after
ok
2117
wtf
how
Don't use beautify
This is why it gets the string bigger
what should i use then?
because beautify is adding tons of spaces for indentation
congrats
Pog?
check if beautify has an option for using tabs instead of spaces
@quartz kindle yes, I have that already:
if (!args[0]) {
message.channel.send("You need to provide a link!");
return;
}
/* Old connection code
const channel = message.member.voice.channel;
if (!message.member.voice.channel || channel.join == null) {
message.channel.send("You must be in a voice channel!");
return;
} else {
channel.join().then(connection => console.log('Connected!')).catch(console.error);
}
*/
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if (!args[0]) {
message.channel.send("You need to provide a link!");
return;
}
And:
server.queue.push(args[1]);
why push args[1] if you're checking for args[0]
some how my code can't read Map() :((
@earnest phoenix just use util.inspect
its node's built in way of serializing js objects and data
so i just need to type util ?
it also has built in beautification
like process ?
thx :))
I have this weird bug with collections and mongodb
If I insertOne it gets updated in my collection, without a set in the collection
Matthew wdym?
huh
but it is like default
of mongo
if u remove it from database maybe it will fives error
I know mongo uses indexes
ok
But I never fetch id from mongodb and update it in the collection
I give up
@ebon kelp the id is returned by default unless you specify for it not to
which can be done using projection
Still trying to make a Music bot using OpusScript and FFMPEG. I have installed everything correctly to my knowledge, however when my bot joins the channel it doesn't play anything. I also get this error:
(node:89300) UnhandledPromiseRejectionWarning: TypeError: connection.playStream is not a function
at play (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:770:36)
at C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:814:6
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:89300) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:89300) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
index.js 770 is this line:
server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));
hi who know if dm all members in a server is breaking TOS
yes
i wanted to know
you are
but if there is cooldown?
still violates ToS
oh ok
still does violate tos
thx
hey
may i have ask
i merged nsfw function into my bot. the function is fetch an image on booru sites.
the question i have
,which sites that break discord TOS except lolibooru?
here my route
@simple stump .playStream => .play
https://discord.js.org/#/docs/main/stable/class/VoiceConnection?scrollTo=play is it not just .play() in d.js v12?
yes it is
it is
@ebon kelp the id is returned by default unless you specify for it not to
@sinful belfry Yeah but how is it updated in a collection?
wdym
can you not just give screenshots/explain here?
Okay
So
When a guild is created it adds some variables in cache
Collection (Key = guildId, object with variables)
for example prefix, ignored channels etc
guildCache is the collection with variables
@tight plinth I'm a bit confused. What do I change?
I got about this far:
if (!message.member.voice.channel || channel.join == null) {
message.channel.send("Channel doesn\'t exist or you're not in a voice channel!");
} else {
channel.join().then(function(connection) {
channel.play(connection, message);
})
}
EDIT: I'm not asking for a spoonfeed. Just confused as to what connection in the documentation is
yeah...
Ah i see. Ty
Connects to MongoDB and adds it in collection
lol i accidnetally pressed enter
When I console log all my guildCache it shows _id in the added guild
TypeError: channel.play is not a function
_id is for indexing iirc
Error:
(node:90872) UnhandledPromiseRejectionWarning: TypeError: channel.play is not a function
at C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:814:14
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:90872) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:90872) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const channel = message.member.voice.channel;
if (!message.member.voice.channel || channel.join == null) {
message.channel.send("Channel doesn\'t exist or you're not in a voice channel!");
} else {
channel.join().then(function(connection) {
channel.play(connection);
})
}
As you can see in the first image (https://discordapp.com/channels/264445053596991498/272764566411149314/749722630214385794) I don't add _id
Right?
yep
its created by mongodb automatically
@simple stump connection.play
Uhm
be nice
ah ok ill try that thx
@simple stump lol why
MongoDB creates the _id for indexing automatically ofc
wdym 😉
But I never add this in the guildCache
But when I console log guildCache it contains the _id
owo another error
(node:63176) UnhandledPromiseRejectionWarning: Error [VOICE_PLAY_INTERFACE_BAD_TYPE]: Unknown stream type
at VoiceConnection.play (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\voice\util\PlayInterface.js:84:11)
at C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:814:17
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:63176) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:63176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const channel = message.member.voice.channel;
if (!message.member.voice.channel || channel.join == null) {
message.channel.send("Channel doesn\'t exist or you're not in a voice channel!");
} else {
channel.join().then(function(connection) {
connection.play(connection);
})
}
Sorry. Now I feel bad for sending so many messages 0-0
omg
And it puts everything in a db so when I restart the bot, everything gets loaded into guildCache.
And I filter _id out of there
Which works
Before I've even completely finished my bot, I already have an idea for a new one. I ALSO have the remains of an old bot I scrapped because I had an idea before finishing Nooko too. Anyone else get that problem?
Too many ideas ;;
New guilds who didn't came out of the database have _id, without this key
It's confusing starman
yeah i see
It's easier by showing in screenshare
i see what you're saying
console.log(client.guildCache.get("ID"));
First object = before insertOne
Second object = after InsertOne
console.log(client.guildCache.get("ID"));
First object = before insertOne
Second object = after InsertOne
@ebon kelp that's internal mongo id
I know I know
If it was
ID: {
Data-here
}
You couldve used get
It is
Ok if u know, whats the issue
I'm very confused why I get the error "Unknown stream type" when I'm using ytdl.
(node:63176) UnhandledPromiseRejectionWarning: Error [VOICE_PLAY_INTERFACE_BAD_TYPE]: Unknown stream type
at VoiceConnection.play (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\voice\util\PlayInterface.js:84:11)
at C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:814:17
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:63176) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:63176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have installed it correctly (I'm using localhost hosting and did npm install --save ytdl-core opusscript. Got no errors whatsoever) and have added const ytdl = require("ytdl-core"); at the top of my file, however I still get that error. Below is the relevant code (I'll include my full file as well). Note that in the full file I use connection.play(message) instead of .play(connection), but I tried both ways. No luck.
const channel = message.member.voice.channel;
if (!message.member.voice.channel || channel.join == null) {
message.channel.send("Channel doesn\'t exist or you're not in a voice channel!");
} else {
channel.join().then(function(connection) {
connection.play(connection);
})
}
Jesus man
How are you playing the connection 😂
Connection isnt a file or a buffer
What do you think? @sinful belfry
You're trying to play the connection to the voice channel?
In your hatebin post, you try passing message which doesn't make sense either. There are some examples on how to properly use it in the documentation: https://discord.js.org/#/docs/main/stable/class/VoiceConnection?scrollTo=play
Also you defined channel as message.member.voice.channel, so there's no need to repeat it in your if statement.
honestly, i have no clue why it is changing it after it has been cached lol
seems very weird to me, but ig there must be a reason somewhere
Ikr
It doesn't cause a problem, but I have no idea where the cache has been updated with the _id attribute
console.log(client.guildCache.get("ID"));
First object = before insertOne
Second object = after InsertOne
@ebon kelp and here, you're definitely fetching both from cache?
yes

Else it won't be in there
Anyhow about to upload this bot for the 3rd time, because it crashed twice. Like I edited 1 line and didn't test it for production 
90 days to get a bot approven 
Thanks Lite, e, and alhassan. It works! Accidentally did some weird stuff
how can i check if a user's avatar is gif?
oof
@sinful belfry Unless
@earnest phoenix check the file extension i guess
if it ends in .gif then it would be safe to assume it is a gif
[Starman] Unless
@ebon kelp wouldn't be fair ofc, but saves some time
Is anyone aware of some method for checking whether there are uncommitted changes in SQLite before committing?
easy but unreliable would be to check the differences in file size
a proper way would be to loop through everything in the database in both files (local and the most recent one in the branch)
you shouldn't be committing your db file anyways 👁️ 👄 👁️
it's called transparency
I'm trying to create a g!stop command for my bot, however I get a GIANT error:
https://hatebin.com/noqtbgstdc
Probably the most important part is this:
TypeError: Cannot read property 'end' of undefined
at Client.<anonymous> (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:817:23)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\ws\lib\websocket.js:797:20)
PS C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot>
I don't know why line 817 (server.dispatcher.end();) is not a thing.
Code: https://hatebin.com/sqaehshawb
https://i.callumdev.pw/4gt7f.png
https://i.callumdev.pw/xlar1.png
https://i.callumdev.pw/vpf3r.png
logs absolutely fine but returns bloody undefined?? what even
how do i check if a user has the house_balance badge?
check its flags
türkmüydün sen
yes (#memes-and-media for turkish)
what is your djs version
12.3.1
<User>.flags.has()
ok thanks, im trying
Oa türk
😄
just do message.channel.send 
it's not the fault
yes.. it is
cannot read property 'has' of undefined
message is not defined
code?
show kullanıcı-bilgi.js 117th line
we aint got a clue what has is
also just do message.channel.send
continuous console node. I did such a thing because I applied
if (kisi.user.flags.has('HOUSE_BALANCE')) rozetler.push();
Otherwise I can't use node index.js
I made that mistake on purpose.
what is "kisi"
I'm trying to create a g!stop command for my bot, however I get a GIANT error:
https://hatebin.com/noqtbgstdc
Probably the most important part is this:
TypeError: Cannot read property 'end' of undefined
at Client.<anonymous> (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:817:23)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\ws\lib\websocket.js:797:20)
PS C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot>
I don't know why line 817 (server.dispatcher.end();) is not a thing.
Code: https://hatebin.com/sqaehshawb
const kisi = blablabla
@earnest phoenix "blablabla" very helpful mate
@simple stump how do you store your queue?
@earnest phoenix what is kisi
let kisi = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(r => r.user.username.toLowerCase() === args.join(' ').toLocaleLowerCase()) || message.guild.members.cache.find(r => r.displayName.toLowerCase() === args.join(' ').toLocaleLowerCase()) || message.member;
Jesus
i-
if(message.attachments.size > 0){
message.attachments.map(async(r) => {
await bot.channels.cache.get('708100886198616064').send("save", {file: r.url})
})
}```it does not work
@pure lion sorry for late reply. I store my queue in an array.
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
and when i want to add a song:
server.queue.push(args[0]);
module.exports = (client) => {
setInterval(() => {
const db = client.db.fetch("cmb.commandUses", true);
var sortable = [];
for (var command in db) sortable.push([command, db[command]]);
sortable.sort((a, b) => a[1] - b[1]);
sortable.forEach((item) => {
var objSorted={};
objSorted[item[0]] = item[1];
client.mostUsedCommand = objSorted;
delete client.mostUsedCommand["total"];
let totalUses = 0;
client.totalCommandUses = Object.keys(client.mostUsedCommand).map(x => x == "evaluate" ? "" : totalUses = totalUses + Number(db[x]));
client.mostUsedCommand = Object.keys(client.mostUsedCommand)[Object.keys(client.mostUsedCommand).length - 1];
client.totalCommandUses = totalUses;
// IF I LOG HERE, IT LOGS FINE
});
}, 1000);
// IF I LOG HERE, ITS UNDEFINED ALL OF A SUDDEN
};
https://discordapp.com/channels/264445053596991498/272764566411149314/749746161195286630
what
is
wrong
@simple stump what is servers
@snow urchin because its inside an interval
the interval runs for the first time after 1 second, before that everything inside doesnt exist
the interval aint the issue m8, it worked before
it is whats causing it to log undefined, which is what you asked
thats why it logs fine inside it but not outside
@pure lion var server = servers[message.guild.id];
rectangles are both the same, only difference is it logs undefined the second time https://i.callumdev.pw/2jnc0.png
just save that to the db?
var channel = await ...channels.create
i want to store the channel and then send a message and some more
yes
var channel = await ...channels.create
@summer torrent and how can i send a message?
bob.send(bob)
channel.send is not a funktion
<your channel variable>.send
Hello,anyone have an idea on how to make an afk command like a!afk Sleeping so when someone pings the user the bot replies and when the user sends a message it removes the afk?
i use mongoDB btw
rectangles are both the same, only difference is it logs undefined the second time https://i.callumdev.pw/2jnc0.png
it will be undefined if you log it outside of the interval before the interval is executed
this is inside the interval..
console.log(Object.keys(client.mostUsedCommand)[Object.keys(client.mostUsedCommand).length - 1])
// => botinfo
client.mostUsedCommand = Object.keys(client.mostUsedCommand)[Object.keys(client.mostUsedCommand).length - 1];
console.log(client.mostUsedCommand)
// => undefined
im still confused as to why use ```js
Object.keys(client.mostUsedCommand)[Object.keys(client.mostUsedCommand).length - 1]
rather than ```js
client.mostUsedCommand?[0]
actually
i see
i guess you could sort as well technically
I'm trying to create a g!stop command for my bot, however I get a GIANT error:
https://hatebin.com/noqtbgstdc
Probably the most important part is this:
TypeError: Cannot read property 'end' of undefined
at Client.<anonymous> (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\index.js:817:23)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot\node_modules\ws\lib\websocket.js:797:20)
PS C:\Users\Ian Lew\OneDrive\Programs\DiscordBot\Test Bot>
I don't know why line 817 (server.dispatcher.end();) is not a thing.
Code: https://hatebin.com/sqaehshawb
It means server.dispatcher is undefined. You should log the value of server to see what it is.
Alright
It seems to work...
{ queue: [ 'https://www.youtube.com/watch?v=9Va88Kt0NN0' ] }
That's what's logged.
if (message.content.startsWith(`${prefix}stop`)) {
var server = servers[message.guild.id];
console.log(server);
if (message.guild.voice.channel) {
for (var i = server.queue.length - 1; i >= 0; i--) {
server.queue.splice(i, 1);
}
server.dispatcher.end();
message.channel.send("Ending the queue. Leaving the voice channel...");
console.log('Stopped the queue!');
}
if (message.guild.connection) message.guild.voice.channel.disconnect();
}
So the object does not contain the dispatcher. All it contains is a key of queue and a value of an array of songs. Perhaps you're missing it because you never gave it.
@steady anchor what theme is that
discordgo - bot randomly dropped connection to all shards earlier this morning, wondering if its the library or if discord api had some weird thing happen to it today
Hello,how do i get the activity of a user like specific not just has a custom activity
this is my current code
{
name: "Activity: ",
value: user.presence.activities[0] ? user.presence.activities[0].name : `User isn't playing a game!`,
inline: true
},```
thanks matre
how do i check f a guild has an icon ???
If bot is in voice channel but isn't playing anything for 5 minutes it's gonna leave from voice channel
How can i do this
What language and what library are you using
Consider using the timeout API in Node.js (setTimeout) or something
When there's nothing left you can create the timeout and if a song starts you can cancel it (if it's not been 5 minutes)
^ listen to this event https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-voiceStateUpdate
if there are no members create a setTimeout and store it in a map keyed by the channel id, if a member joins back within those 5 minutes, grab that timeout out of the map and cancel it
(obviously remove it in both cases, when it expires and when a member joins back, we don't want ram leaks)
how do i allow a command to be used by both someone with a role
and with someone with a permission?
loop through their roles, if not found, check their permissions
or vice versa
the order doesn't matter
@commands.has_permissions(manage_channels=True)
@commands.has_any_role('DJ', 'Dj', 'dj', 'dJ')
does this work?
spoiler: it doesnt
never worked with dpy ¯_(ツ)_/¯
@commands.has_any_role('DJ', 'Dj', 'dj', 'dJ')
@command()
async def stop(self,msg):```
ok thanks
oh
u know how to or?
and do you know if i can also check it theyre alone
in the vc
It doesn't work because it's checking for both cases (permissions and has role). I don't know myself how to make it only check if either one of them are true but you could make your own check. There's probably a better way of doing it though.
yeah i don't think you can or checks in dpy
you probably have to make your own one
from the docs: When multiple checks are specified, all of them must be True:
They have an example of two checks to work as "this OR that" on the docs: https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check
noop
how would i go about making my own?
-help

is .startsWith() something that is everywhere or just in discord.js
talking javascript bwt
How do I disconnect my bot from the VC? Or stop my bot from playing anything? I get an error when I use this code:
if (message.content.startsWith(`${prefix}stop`)) {
var server = servers[message.guild.id];
console.log(server);
if (message.guild.voice.channel) {
for (var i = server.queue.length - 1; i >= 0; i--) {
server.queue.splice(i, 1);
}
server.dispatcher.end();
message.channel.send("Ending the queue. Leaving the voice channel...");
console.log('Stopped the queue!');
}
if (message.guild.connection) message.guild.voice.channel.disconnect();
}
I need help getting my bot online and working because I just created an bot
Yikes I can’t code with JavaScript at all it confuses me
what can you code with 🤔
I don’t know
Well then
python and js are kind of the beginner languages
Python is the best for beginners apparently
really depends on what your going for.
I missed Phpstorm and Intellij IDEA.
It felt more comfortable than VSC but im using VSC for now sadly since my license ended. ima go for a yearly license later
let us know whatcha need and we might be able to help
Just don't expect us to spoon feed you everything though no offence. You don't gain much knowledge by that
^Not trying to be rude
the discordjs.guide link given earlier covers a lot of useful things.
it also gives some great sources on learning the basics of js.
how to fix error when install quick.db ?
the quickdb npmjs page links to this troubleshooting page.
https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/troubleshooting.md
How do I disconnect my bot from the VC? Or stop my bot from playing anything? I get an error when I use this code:
if (message.content.startsWith(`${prefix}stop`)) {
var server = servers[message.guild.id];
console.log(server);
if (message.guild.voice.channel) {
for (var i = server.queue.length - 1; i >= 0; i--) {
server.queue.splice(i, 1);
}
server.dispatcher.end();
message.channel.send("Ending the queue. Leaving the voice channel...");
console.log('Stopped the queue!');
}
if (message.guild.connection) message.guild.voice.channel.disconnect();
}
whats "servers"
Printing out server:
{ queue: [ 'https://www.youtube.com/watch?v=9Va88Kt0NN0' ] }
var server = servers[message.guild.id];
server.dispatcher is undefined then
Yeah. I couldn't figure out how to set it or whatever in my code
Code: https://hatebin.com/sqaehshawb
Bit outdated though...
(going to sleep fyi)
https://top.gg/api/widget/656739867404795934.svg?usernamecolor=FFFFFF&topcolor=2c2f33
How would I put this inside a richembed using a .setImage
It doesn't seem to work so if you got any solutions tell me please!
wait, nvm i used svg instead of png
guild#emojis#cache
cache is an extended map so you can use size to get the size of the collection
so guild#emojis#cache#size
ok... lemme try that
and it's channels.cache is it not?
ah never mind
i'm guessing you defined it as that
const channels = message.guild.channels.cache;
could be your host
heroku
ah
yes im broke
im gonna point it at problems with heroku honestly
sdsdasg
sure it's a free host however you should eventually move to a vps
Yes if my mom gets me a paypal
wait
I GOT IDEA
no
not idea
yes
IDEA
lemme shift the command
to another repo
heroku isn't that bad, likely you execute a blocking function before running each command.
what happens if i shard my bot at 20 servers?
i mean can i
yes
except planning ahead
you'd have one shard with 20 servers
@dusk vault is there a way to make it 1 shard for every 5 servers?
why
why not
why
why not
you'd have 4 separate shards for your 20 servers
yup
that's 4 processes
which would be more memory intensive
than not sharding
lmao
and probably slower
shards should have
Um, you can have sharding with only one process
oh wow nvm then i guess
1000 guilds
i want to make it fast ;-;
thats not how at 20 servers
thats not how at 20 servers
@dusk vault then how
don't
but if you cluster, then its multiple
how am i supposed to answer how to make your bot fast
i dont know what your bot even is
yup its js
ok?
oh wait i misread
if u want fast, bot find a vps what's close to discord's datacenters
Sharding won't make your bot faster at 20 guilds, in fact it might make it even slower because you are connecting to the gateway multiple times
ok good luck
Sharding won't make your bot faster at 20 guilds, in fact it might make it even slower because you are connecting to the gateway multiple times
@cinder patio who said my bot is in 20 server
you
you
bruh
i asked that if i can do that at 20
which implies
i never said its at 20 alr
that you have 20
Sharding === a fucktonne more CPU and RAM (it doubles and can get bigger) power
how do i get these emojis? do i make em or ss someone's profile and crop?
make em
google "discord status emojis"
^
and them to your bot support server
it needs a special perm to use emojis from other servers in other servers
i think it's called nvm i forgot ask @Tim
@hazy sparrow right click on them and then click copy link
hm wait brb
@hazy sparrow right click on them and then click copy link
yea this is so easy ty
wait it's against youtube tos to make music bots
there goes my plans for tueusday
k
pretty sure node.js can detect when the process exits
so you can log when it goes offline
i think it's called
nvm i forgot ask @Tim
No, it calledAsk @Tim he know verything
tim is a god send in this server lmao
@quartz kindle is it better to do process.ONCE("exit"); or process.ON("exit");
i think the second one is better
because if for whatever reason node.js adds a way to force a process to stay up then...
read pins of #support
wait https://v8.dev is a JavaScript engine coded in C++ 
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
@earnest phoenix dude stop ping him
hes offline
Code?
module.exports.run = async (bot, message, args) => {
let reddit = [
"meme",
"animemes",
"morgzmeme",
"depressedmeme",
"robloxmeme"
"dankmemes",
"dankmeme",
"wholesomememes",
"MemeEconomy",
"techsupportanimals",
"meirl",
"me_irl",
"2meirl4meirl",
"AdviceAnimals"
]
let subreddit = reddit[Math.floor(Math.random() * reddit.length)];
message.channel.startTyping();
randomPuppy(subreddit).then(async url => {
await message.channel.send({
files: [{
attachment: url,
name: 'meme.png'
}]
}).then(() => message.channel.stopTyping());
}).catch(err => console.error(err));
};
module.exports.help = {
name: 'meme',
aliases: ['memes']
}```
missing a ,
Robloxmeme doesn’t have a comma after it
oh
:')
try notepad plusx2
wait https://v8.dev is a
JavaScriptengine coded inC++
@earnest phoenix javascript is interpreted into c++
surround the link with < and >
or surpress
Because it does
why
how to add automemes

no post
@coral trellis -dotpost
xD
Upload your files, run, setup an uptime service to ping the website every 5-10 minutes to keep the bot online
im too lazy to run can i sit and do it
ty so much anyways
should i upload all my files or just index.js?
Upload all files index.js needs to run
In javascript, how can I perform an action at a specific time of day?
You can use an npm-package like cron https://www.npmjs.com/package/cron
Buut if you want to do it just once, you can use a setTimeout
No, every day at a specific time
then cron should do the job
Ok thanks
const { Client, MessageEmbed } = require('discord.js');
const { Menu } = require('discord.js-menu');
const client = new Client();
const prompter = require('discordjs-prompter');
client.on("message", async msg => {
let message = msg
if(message.content == "nuke"){
if(msg.author.id !== "587663056046391302") return msg.reply(`no`)
prompter
.reaction(msg.channel, {
question: 'Are you sure?',
userId: msg.author.id,
})
.then(response => {
// Response is false if time runs out
if (!response) return msg.reply('you took too long!');
// Returns 'yes' if user confirms and 'no' if ser cancels.
if (response === 'yes') {
let channel = await message.channel.clone()
msg.channel.delete()
channel.send(`done`)
channel.send(`done`)
channel.send(`done`)
}
if (response === 'no') return msg.channel.send('You chose no!');
});
}```
this is a testing bot
it says cannot use await outside async
but it is in async
the .then callback function has to be async to use await inside of it @delicate shore
np
it worked Pog
weirdest output i ever seen
https://pastebin.pl/view/909130b5
[JDA MainWS-ReadThread] WARN GuildSetupController - Accumulating suspicious amounts of cached events during guild setup, something might be wrong. Cached: 2000 Members: 0/134411 Status: CHUNKING GuildId: 264445053596991498 Incomplete: 0/1
[JDA MainWS-ReadThread] WARN GuildSetupController - Accumulating suspicious amounts of cached events during guild setup, something might be wrong. Cached: 3000 Members: 0/134411 Status: CHUNKING GuildId: 264445053596991498 Incomplete: 0/1
[JDA MainWS-ReadThread] WARN GuildSetupController - Accumulating suspicious amounts of cached events during guild setup, something might be wrong. Cached: 4000 Members: 0/134411 Status: CHUNKING GuildId: 264445053596991498 Incomplete: 0/1
and the bot is very slow and sometimes doesnt even listen
this guild
if you want you can ask a mod to kick it from this guild
it might also fix the issue
(you probably don't have enough ram)
yeah
my computer is a 3 year old laptop
the ping of the bot is 120
S!ping
he kinda
decides
to respond or not
net.dv8tion.jda.api.exceptions.InsufficientPermissionException: Cannot perform action due to a lack of Permission. Missing permission: MESSAGE_WRITE
in #commands
is it muted or what
also the bot is fast now
how do i get the sum of all members of all servers the bot is in?
What Lang?
-mutedbot @knotty obsidian
@knotty obsidian
Your bot was likely muted because it broke one of the "bot rules" listed in #rules-and-info.
To find out why your bot was muted and by who, use the search feature in #mod-logs:
oh
What Lang?
@pure lion d.js v12
client.users.cache.size
ok ty
so my bot responds to other bots ;-;
alright, let me fix it
if (event.getAuthor().isBot()) {
return;
}
is there a way to change my bot's activity every x seconds automaticcly??
JDA
Ah nvm
That could be API abuse
@pure lion theres a ratelimit of 5 changes every 60 seconds
:)
That's for messages
Wait
Nvm
It's generally a bad idea to automate an API like that
But if you must then use an array and a setInterval
well i dont want to change it, just reload the currect status so my server count is correct
What
Oh
How much do you pay
Free 😐
Buy a vps
Put your bot on the vps
yup, its clear. DONT use a "FREE" hosting thingy
O
Especially for music bots
how much does it cost?
wait why specially for music bots?
ye
yup, its clear. DONT use a "FREE" hosting thingy
@hazy sparrow I use one well i was the co-owner we are legit free hosting for a certain plan/stats
I can link one in dms
any other way?
@earnest phoenix the one I use is £3.59, it's really good the for the price
name please
@earnest phoenix the one I use is £3.59, it's really good the for the price
@pure lion Or you can get it free
I can link one in dms
@earnest phoenix hmm, sure, ill see it
@earnest phoenix from where
There^
@hazy sparrow
@earnest phoenix
Can you don't
Can you don't
@pure lion dont what?
Nvm
@earnest phoenix it's free?
If you want free hosting
i will check
wait
@earnest phoenix it's free?
@earnest phoenix Yeah
it is
leme check
You have to join the discord server
cuz the automation system is getting redone
and make a ticket
coughs advertising
how do i set my bot that it sends a message after a certain period of time
i fixed the error when the bot responds to bots, how do i get unmuted now?
@earnest phoenix why do you guys need phone number ;-;
it says coming soon
Lma
and adress too smh
Use Library of code
you can skip it
Smh
Use Library of code
@pure lion whats that
man
the website sucks
the website sucks
@earnest phoenix Why?
i didn't understand anything
i'm confuse
can you explain me in dm
can you explain me in dm
@earnest phoenix oka
confusion go crrrrrr
Anyone know how you would let nginx cover a localhost server.
For example.
Server runs on: localhost:1234
Domain: my.example.com
(When you visit my.example.com you see the content of localhost:1234)
how can i make an mute role? i made the mute role have all the roles turned off but it doesnt work
event.getGuild().createRole().setName("Muted").setPermissions(Permission.EMPTY_PERMISSIONS).queue();
thats what i did
so how do i do it
sa
?
@knotty obsidian what language & library are you using?
Deny the MESSAGE_WRITE & VOICE_CONNECT permissions
(https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/Permission.html)
blame discord
its always like that 😫
blame discord
strip indents by using the common-tags package or use \n
or add .split("\n").map(x => x.trim()).join("\n") after the ` 
@pale vessel you telling to me?
yes
after which `?
ahh
the embed one?
ok wait
wait show code
want to add4add?
please not here
wait hold on
no
@earnest phoenix stop
@pale vessel https://pastebin.com/AkcVi8T8
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
bro any free hosting website?





