#development
1 messages · Page 829 of 1
I guess
const _guilds = await guildModel.findOne({ guildId: message.guild.id });``` this is my code for getting data
Which I doubt is your intended behaviour
you'd want to do something like the code above^^
which in your example looks like it should be findOne({ID: guild.id})
If that gives you a result, it means it's in your collection of bans
So you'd leave that guild, you also don't have to grab the guild object a second time
because you already have it
simply guild.leave()
Hey.
How could i do to send a message as webhook?
message.channel.createWebhook('Say')
.then(async (webhook) => {
webhook.send({
username: message.author.username,
avatarURL: message.author.displayAvatarURL,
content: args.join(' ')
})
await webhook.delete();
You're awaiting the deletion but not the send
Which means it's very likely to get deleted before sending
Ok.
I'm getting an error saying message can't be empty though.
(node:502) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
at item.request.gen.end (/app/data/DiscordBot/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/app/data/DiscordBot/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
Yes.
I could type anthing in the discord chat
pm!say look at these nice args
would still give me the error.
oh
(node:7516) UnhandledPromiseRejectionWarning: TypeError: serverQueue.connection.player.end is not a function```
connection = connection.dispatcher.streams.ffmpeg
where did you define it?
@mystic violet console.log connection and see what u get
you gotta tell me
He started with “I know your token”
I asked him what it was
And he just rambled lmao
Then near the end I used my command that sends a fake token
And he thought it was real lmao
lol
I would love to annoy him
Does running mongodb in a container void the data when restarting container?
how would i find all userids in a specific guild in the client.on('ready', () { event
i assume running the client.guilds.get(guild_id).fetchMembers() ?
yes
fetchmembers is a promise
you can await it or use .then()
do you need to go through ALL members in the guild?
data.dispatcher = await data.connection.playStream(ytdl(data.queue[0].url, { filter: 'audioandvideo'})); Should I change the filter because when bot joins and plays the music the musics lags and stuff
then yeah do that
Idk if it's because of the filter
well, video is useless for discord
Tim, .then(guild => { guild.users }) ?
fetchMembers returns a collection of members
not just that though; xD
its a collection of the entire server
and emoji
so emoji, users, roles, channels etc
ah true. fetchMember returns a member, fetchMembers returns the guild itself
so it would be .then(guild => guild.members.forEach(member => ))
i found it ty
also standard coding convention is to write currentdata like currentData
known as camel case
@tight plinth no
ik
hi please help me Stopped bot error code js /home/dc/node_modules/opusscript/build/opusscript_native_wasm.js:8 var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow){throw toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Mo abort(TypeError: Cannot read property 'welcome' of undefined). Build with -s ASSERTIONS=1 for more info.
has to do with opusscript? no idea lol
I knew that too
It's almost like a new language.
that is formatted so horribly.
Keep getting errors from this code in lavalink js const url = args.join(" ") if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) { const playlist = await youtube.getPlaylist(url); const videos = await playlist.getVideos(); msg.channel.send("Processing...").then(async m => { const embed = new RichEmbed() .setTitle("Playlist Added") .setDescription(`${playlist.title} has been added to the queue`) m.edit(embed) for (const video of Object.values(videos)) { const song = await getSongs(`ytsearch: ${video.id}`); // eslint-disable-line no-await-in-loop await handleVideo(msg, msg.member.voiceChannel, song[0], playlist); // eslint-disable-line no-await-in-loop } }).catch(e => console.log(e)) }
Lavalink music is online
(node:9474) UnhandledPromiseRejectionWarning: #<Object>
(node:9474) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:9474) [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 need help. I dont get an error but the command wont work.
https://pastebin.com/DugEJBxP
so its a leveling system but i want it so that i can turn the command on and off by typing -toggle leveling. But it wont work, it literally does nothing. this is the original leveling command that i put into the toggle >>>> https://pastebin.com/70BvR5Sz
So i wanted this script(https://pastebin.com/70BvR5Sz) to be able to turn on and off with a command
Does anyone have an idea of what could be causing this error, it happens at random, it sometimes takes hour to occur and sometimes happens only minutes after boot.
6|index | MessageError: Failed to process message during connection, calling disconnect: Unknown type received: 67 [UnknownType]
6|index | at Object.makeError (/home/timo/ChipProject/Chip/node_modules/veza/dist/lib/Structures/MessageError.js:33:16)
6|index | at ServerSocket._onData (/home/timo/ChipProject/Chip/node_modules/veza/dist/lib/ServerSocket.js:93:62)
6|index | at Socket.emit (events.js:311:20)
6|index | at addChunk (_stream_readable.js:294:12)
6|index | at readableAddChunk (_stream_readable.js:275:11)
6|index | at Socket.Readable.push (_stream_readable.js:209:10)
6|index | at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
6|index | kind: 'UnknownType'
6|index | }
That error is what crashes the process
Whatever it is
maybe open an issue in their github? i cant find anything online either
Prolly has something to do with an exposed port
Hm
it got a message without id and without being connected
Setup a firewall now, might solve stuff /shrug
im trying to set up a welcome channel for each server but the variable keeps getting reset afterwards
when i printed welcomeChannel[message.guild.id] after in a seperate command it printed undefined anyone know how to fix this
You must use a database to have a proper settings command.
nvm i figured it out lol
i had to make it a const
i used let which caused it to reset

you will need to use a database or some storage system, otherwise your bot will forget everything every time it restarts
(node:15552) UnhandledPromiseRejectionWarning: http status: 502
(node:15552) 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:15552) [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.```
any idea why? im using yt-search
and ytdl-core
where do you host your bots? thinking of gcp free tier or digitalocean or linode
do is a little expensive also you can check the pins to see a list of vps prices
nice thanks
If you have a stable internet at home then you could also host it on a spare computer or something like a raspberry pi
hmm that's an option as well
I'm thinking of setting up a website and some other stuff as well, so that's why I'm considering a vps
I've never managed servers though so I have a bit of learning to do
https://discordapp.com/channels/264445053596991498/265156286406983680/690350402377744555 how are these caused and how can you prevent it?
Aight any regex masters here?
Any reason why this wouldnt match será?
'sera'.match(/\b(\w*sera*\w)\b|\b(\w*será*\w)\b/g); // one match
'será'.match(/\b(\w*sera*\w)\b|\b(\w*será*\w)\b/g); // no matches
while this works?
'work'.match(/\b(\w*work*\w)\b|\b(\w*wórk*\w)\b/g); // matches
'wórk'.match(/\b(\w*work*\w)\b|\b(\w*wórk*\w)\b/g); // also matches
And how would i make será match?
You know you could use it like
string.match(/\b\w*(work|wórk)*\w\b/g);
Saves rep in typing.
do it that way
maybe having that weird char near the * breaks it
I don't really know
pretty sure those were examples
Yeah but just change work with sera
you could even:
string.match(/\b(\w*w(?:o|ó)rk*\w)\b/g);```
Although pretty sure \b isn't even needed.
doesnt work with será tho
i need \b as it defines a word bondary
else it would match working
im using 101
and the regex works for any character except accentuated
thats the question i guess
how do i make it work with á
prolly some funkyness on the group i created
ended up doing it like this /((sera)|(será))(?!\w)/g

How do i make an on and off command for this script
https://pastebin.com/ALC63mjb Its a leveling system
@calm shore so you want to make it so that users or server admins can enable or disable it?
Should be pretty simple set it up in a JSON (smaller bot) or a database (more reliable) as a guild setting that's off by default. Create a command to set it as enabled or disabled in the database and then set up something to check if it's enabled ieif (levelSystem.enabled === true) etc.
never recommend json databases
just go for the normal database
use a db, and store a boolean in it
then when you get a message check for that server
if the value in the db is true then you can add xp
if not then just ignore it
never recommend json databases
Some people prefer it due to the fact that it's sometimes easier to set up or 🤷🏻♂️ but yes I would strongly Recommend a proper Database.
better-sqlite3 and mongo DB are both fairly simple to set up
yes
if (levelSystem.enabled === true)
why === true?
still gets the work done
that's totally redundant
yes that's redundant
mostly performance issues
like speed?
will server size help with that?
I mean if you host with VPS
and get more expensive options
anyone here know why i've recently started getting:
Error: Something took too long to do.
its happened for the past week, takes multiple restarts for it to actually login, but now it just wont login at all
(discord.js)
weather command
const Discord = module.require("discord.js")
const weather = require("weather-js")
module.exports.run = async (bot, message, args) => {
weather.find({search: args.join(" "), degreeType: "C"}, function(err, result) {
if(err) message.channel.send(err)
//If the place entered is invalid
if(result.length === 0) {
message.channel.send("**please enter a valid location**")
return;
}
//Variables
var current = result[0].current //Variable for the current part of the JSON Output
var location = result[0].location //This is a variable for the location part of the JSON Output
//Sends weather log in embed
let embed = new Discord.RichEmbed()
.setDescription(`**${current.skytext}**`) //How the sky looks like
.setAuthor(`Weather for ${current.observationpoint}`) //Shows the current location of the weater
.setThumbnail(current.imageUrl) //Sets thumbnail of the embed
.setColor(0x00AE86) //Sets the color of the embed
.addField("Timezone", `UTC${location.timezone}`, true) //Shows the timezone
.addField("Degree Type", location.degreetype, true) //Shows the degrees in Celcius
.addField("Temperature", `${current.temperature}`, true)
.addField("Feels like", `${current.feelslike} Degrees`, true)
.addField("Winds", current.winddisplay, true)
.addField("Humidity", ` ${current.humidity}%`, true)
.addField("Day", `${current.day}`, true)
.addField("Date", `${current.date}`, true)
//Display when it's called
message.channel.sendEmbed(embed)
});
message.delete();
}
module.exports.help = {
name: "weather"
}
not working for me
const Discord = module.require("discord.js")
const weather = require("weather-js"). the package weather-js not working
anyone here know why i've recently started getting:
Error: Something took too long to do.
@pale glen Same here. Usually I have to restart my VPS or turn off the server for some time and re-run it for it to work. It's kind of annoying 😭
will server size help with that?
@pallid vector I'm not sure but I've seen some bigger bots "clear their cache" whenever the ram goes over a certain point. My bot's currently growing as well, so I'm looking into ways on improving this too. My main problem right now though is figuring out sharding
this shit is getting obnoxious it just took me like 3-4 hours of nonstop restarts and updates to npm / node
ahh hmm I see
oh??
that makes sense
how many servers is your bot in shakyra?
1700
What do you need for sharding? or what to do
I'm scared now LOL
there's no pattern
I have 0 clue, besides putting autoshardedbot
you can get lucky and it will login successfully
LMAO
after a few mins
or you can get fucked over and it won't login for hours
that shit started happening recently
yeah it's strange
discord's API issues, people are saying it could be because of the Go Live increase
for sharding I'm honestly not sure how to go about it, maybe just use ShardManager for Discordjs 11.5
im using discord.py
problem I keep running into is my bot responds multiple times when I issue 1 command
and I need to figure out stuff with cross-shard emoji reactions
gotta look into sharding for sure
it's a must basically
once you hit like 1k-2.5k servers
how would I work on sharding though?
this may be a wierd question but
is it possible to use a custom domain for express in node.js
https://lightside-js.glitch.me/
@lofty moat is that ad
Project not found
he posted an invite link
for the glitch project here which caused many people to be able to edit his project so it got deleted
I thonk
Lol
https://discordapp.com/channels/264445053596991498/265156286406983680/690350402377744555 how are these caused and how can you prevent it?
Uh idk
I used to have them in v11 when I destroyed the client, but I don't know what magic I did for it to throw a socket hang up.
Where does the stacktrace originate?
@grizzled raven
random is not defined
Yes
so define it
just add let random;
@summer torrent irrelevant but yes
what is the best method for creating array in the loop?
empty array and .push() ?
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'setActivity' of null
can someone help me
thats the error it pops up with
https://cdn.discordapp.com/attachments/582325992412938246/690548869997658142/unknown.png
discord.js 12
@next mica what did you define client as?
Im trying to upload a local file with bot but i dont know whats wrong with this code.
Like !upload D:/test.mp3
const client = new discord.Client();
im new to java script and that what it said to define it as in the tutorial i watched
where is this in your code? is it before you login?
@next mica 1. put that code in your ready event
2. arr++ is not a thing
@next mica remove await
Im trying to upload a local file with bot but i dont know whats wrong with this code.
Like !upload D:/test.mp3
@restive light show code
@summer torrent do you know what youre talking about bro
so remove arr plus
put that code in your ready event
remov await
@summer torrent
put in readt event
also that
oh boy there is so much wrong with that code north
you need to change it to js if(msg.content.startsWith('<prefix>upload')
I dont use prefix
also that command can be abused in so many ways
you need to
anyone can upload any file from your computer
I will add limitor to the bot if i solve uploading problem
you still need to change a lot
yeah that code is completely broken
learn some basic javascript first before jumping into bot development
with the thigns yall told me to do (node:14392) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied name is not a string.
thats the new error
@next mica show code and what line you are getting it on
not telling me a line
how can i get all aduiltlog types
example
learn
if(msg.content.startsWith('upload')) {
let fs = require('fs')
let myString = msg.content.split(' ').slice(1).join(' ')
if(!fs.existsSync(`${myString}`)) return msg.channel.send('File doesn\'t exist')
msg.channel.send(new Discord.Attachment(`${myString}`))
}```
that would work better but still shouldnt be a command
``` if(!fs.existsSync(${myString})) return msg.channel.send(File doesn't exist)
shhh
hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
oh so you want audit log types?
yes
what do you mean
logs command
like const entry = await channel.guild.fetchAuditLogs({ type: 'CHANNEL_CREATE' }).then(audit => audit.entries.first());?
if (
guilds.get(channel.guild.id).log.status == "off" || !guilds.get(channel.guild.id)) return;
channel.guild.fetchAuditLogs().then(logs => {
var userID = logs.entries.first().executor.id;
const embed = new Discord.MessageEmbed()
.setColor(emcolor)
.setAuthor(channel.guild.name, channel.guild.iconURL())
.setThumbnail(logs.entries.first().executor.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }))
.setTitle("> **Channel Created**")
.addField("**• Channel Name**", channel.name)
.addField("**• Channel ID**", channel.id)
.addField("**• Created By**", `<@${userID}>`);
logC(channel.guild).send(embed);
});
});```
i know
i want all types
?
yes
i still dont understand how to index the array
offf
soooo
only one would be passed through
so you would be just finding the latest channel creation log
Listen
i want all types of log like
roleCreate
roleDelete
channelCreate
channelDelete
and more
add listeners for those
oke
keep in mind you'll only receive those events if your bot has perms to see audit logs
creates 10 instances of guildCreate
why b0t n0t working
docs exist for one reason
how can i get reason in ban log
fetchBans()
that doesn't give you the reason does it
it does
ya iam in 12.2
ok good read docs
can a mod make a pinned message that tells users to read the docs first and then ask if they still can't fix the problem?
(not like people read them)
Would be pointless
I think the problem is that many people don't know how to use the docs
yet they call themselves as a "developer"
yeah
im sorry wut
"doesn't work"
lol
hey guys, is there any way to get the time that the message was received by the bot? using the message.createdTimestamp is the time that it was sent on the user's side so it has more delay
other than passing thorough a timestamp through the command handler
in js? just use Date.now() in your message received event
but I need it available in a different file
so?
it's a js function lmao
not what I mean
if I use date.now, I need to use it after I define the data, which takes a while because its from mongo
and then it would be unrealistic
no?
what do you mean?
use it after you define the data
well that would defeat the purpose, I want to track how much time it takes
thanks for your help though
oh i read your thing wrong
its all good
i said the same thing oof
tbh, I didnt explain what I wanted enough
Hi everyone!
I am having some trouble trying to mass delete roles within a server.
My code is:
message.guild.roles.cache.forEach(role => {
if(role && role.managed === false && role.id !== message.guild.id) role.delete({timeout: 1000})
})```
This deletes 1 role and when you are going to delete the next it gives an error (Unknown role). Seeing the logs I see that the ID of the role you tried to delete never existed on the server, but there is also no evidence that it existed on the map (That is, when evaluating message.guild.roles.cache the ID of the supposed role does not appear you want to delete).
Any idea how to fix it?
@crimson vapor you can try calculating the time difference before and after the data is defined
I just tried that
its about 150ms
and the delay for the command is 1ms
I need to use a different DB
@twin kestrel try using if(role && role.managed === false && role.id !== message.guild.id && role.deleted == false) role.delete({timeout: 1000})
Same error
if(role && role.managed == false && role.id !== message.guild.id && role.deleted == false) role.delete({timeout: 1000})```maybe this?
await?
what DB do you use?
if(role && role.managed == false && role.id !== message.guild.id && role.deleted == false) role.delete({timeout: 1000})```maybe this?
Same error
The thing is that in the v11 version of discord.js this does not happen to me with the code, instead in v12 yes
the error is just "Unknown Error"?
Unknown role
first, without getting data
second, with getting data
I dont know why the client ping is so high
The @everyone role
alright
oh
that wouldnt work would it?
try
if(role && role.managed == false && role !== message.guild.roles.everyone && role.deleted == false) role.delete({timeout: 1000})```
that might not work for v12 im not sure
it wont
Another error
DiscordAPIError: Invalid Role
no
message.guild.defaultRole
Unknown role
same
message.guild.defaultRole
this doesn't work?
or role.id !== message.guild.defaultRole.id
removed in 11
lol
Heelllo. Who usesu MongoDB here?
I do
Language?
discord.js
How fast is it?
like delay?
unlesss you have a huge data amount, its barely noticable
I just did a test
Ok.
Ok.
what DB do you use atm?
array.forEach is considerably slower than for loops
because doing array.forEach() is roughly the same (but not as bad) as doing ```js
for(item of array) {
(function(){
// do something with item
})(item)
}
is there a way to make it where only one person can run a command and it go through but if other people try to use the command it says you cant do this.
Hey does anyone know of a library, or a way, that I can create a readable stream from a spotify song? There are several libraries in python and stuff but its been a while and I no longer feel comfortable in python
All of the Node.js libraries are outdated (like Node 4.x) or just don't work
s!help
What DBs do you guys use or suggest?
@next mica check if the ID of the message author matches the id of the person you want to allow
ie: if(message.author.id !== "ID") return
@crimson vapor for a small project, sqlite is probably the best option, if you like relational databases
change the id xd
Okay, do you know anything about latency because I am trying to lower the time it takes a command to execute and as of now getting data takes about 150ms
and how do i make it if they are no that id it say you cant run this command
where do i put it in ther
i said it
that spams the chat
it shouldn't
it did
i'm stupid
you need to put it inside the command
inside.
outside would react to all messages
did u check ownerId for every MESSAGE?
yes
if yes, ur stoopid
learn js plz
yes true
that right flaz
if (message.content === 'command'){
if (message.author.id !== 'ur ID') {
//code
}
//command
}```
would be shtm like this
client.on('message' , function(message){
if(message.author.id !== "160161965325418496")
return message.reply("you can't do this shit");
if(message.content === '[p]wack'){
message.channel.send( message.author.username + ' used WACK it was super effective');
}
});
thats what i have
no
iq below 100
(put the code in the message function)
these type of people would understand only when you spoonfeed them
yeah
that's fine ig
just need to tell him to use the same concept for other related things
ye
what do i need to move
oh god
client.on('message', async message => {
if (message.content === 'command name') { //FIRST check for the command name
if (message.author.id !== 'id') { //SECOND check for user ID
return message.reply('u cant do that')
}
return message.reply('some text')
}
});```
lol yes
You might also want to use return inside the if(author !== id) to stop it saying the reply.
invert the message.reply & the message.channel.send
client.on('message', async message => {
if (message.content === 'command name') { if (message.author.id !== 'id') {
message.reply('text');
return;
}
message.reply('some text');
}
});```
Yikes, Discord indents.
still says both of the lumap
]
nope
it means not equal to
learn js first and then create a bot
ok so remove !
like cry would say
and add another =
learn js first and then create a bot
@pale vessel everyone should dot hat
well he didn't
ok
oof
I mean
everyone should learn the basics of any language before starting any project
guys pls ask new people if they know the thing they r doing before helping them
we should force white names to pass a js/py exam before takling in this chat
wow
yes
it will help them more than just providing the answer
I know it sounds rude, propogo
but if you only knew the things that we've encountered here
tbh i learned by reading docs
lots of abominations
i never asked anyone
oh i thought you ment real life white names
We've gone through some shit here at DBL watches #development
That's why docs exist
LMFAOOOOOOOOOOOOOOOOOO
I first learned the first month of bot coding without knowing the existencence of this server lol
same
i check 50 docs, 50 errors before asking anything
Lumap is undefined
the person who is now usign it they get both messages
the people who are not valid only get the you cna not use this
not every
return message.channel.send```
not every ^
not every, but most of them
what you don't need return on the same line
it returns Promise<void> iirc
oh wait you can nvm lmao
:monkaw:
js memes goes to off topic
xD
nah
aight
or try to define message.author.isGay
actually
ok it works now thank yall so much
finally
no
if [something] detects a too big number it can do like 6.448634163+e17
which is a scenario u dont want to happend
(is my english good?)
channel.id.........
same thing
channel.id cant be 18+ digits...
maybe one day they will
how i can delete an file in javascript?
var fs = require('fs');
var filePath = 'C:/path/to/file';
fs.unlinkSync(filePath);```@earnest phoenix
ok thx
I literally type how to delete files js in duckduckgo and found this lol
not even sure it works
@earnest phoenix using console?
i will try @tight plinth
@finite bough no
@tight plinth ```js
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, unlink '../profs.json'```
file not found
wait
file exists?
yes
hm
ok i fix it @tight plinth

first white name that fixed it by themselves
@copper cradle it's a signal that the world is ending
hm
The version of discord.js I've been using is 11.4.2, but the problem persisted even on 11.5.1
what problem?
The error is likely your host, but if you go to your console on your host and run curl -I https://discordapp.com/api/v6/gateway, what's the status code?
Original: https://canary.discordapp.com/channels/264445053596991498/412006692125933568/690618708393066526
@lyric mountain, see #topgg-api, I've mistakenly described it there
@sudden geyser, it returns code 200, as it should
As I've said, the bot is back right now, but the problem persisted for almost an hour, it seems (I didn't catch it immediately)
But yeah, I don't think it's the host, because I tried to run it locally as well.
Hmm, very interesting. My google-fu failed me, I didn't find this thread. Guess I should've searched for recent ones, but I didn't figure that it was a recent issue.
Thanks!
bruh
@finite bough do you have an async
nah
how can i @crimson vapor
wdym
Im have a v12 Yeet since the original Yeet is on v11
So in testing v12 on the Yeet v12
delete a }) and change the main function let res = await prefixes.findOne({ serverID: message.guild.id }, (err, res) => { });
or just copy paste this
async (err, res)
ok
yeah that is easier
is it possible to make it so that when someone does a command that does not exist it sends a unknow command message?
@earnest phoenix this isn't good..
yes
if you use a command handler, if(!command) return //what you want to do
otherwise, no
its also frowned upon because it just causes spam if 2 bots have the same prefix
oh alright then let's just throw it in the garbage
Anyone know of a way to cache the mongoDB storage so I don't have to get it from mongo every time?
Anyone know of a way to cache the mongoDB storage so I don't have to get it from mongo every time?
@crimson vapor sqlite?
yeah I looked into it and I dont know if I will move
???
so instead of answering the question you suggest something completely different
thats 200 iq right there
anyways
big brain
you can cache everything with collection().find()
but you might run into troubles when updating the database
and caching your entire database may not be a good idea while were at it
~~text~~
wdym
I was trying to joke
it wouldnt be a good idea to cache the entire thing
so if I did it wouldnt work
so thats why the does it anyway is strikethrough
It's been taking way more than two weeks for them to decline/approve my discord bot. What is happening?
@crimson vapor whats the problem in getting to from mongo tho
I want to lower latency
@rose warren they probably have a lot of stuff to deal with and cant check it sooner
well
maybe store it in a json file
Oh. Okay.
json's get corrupted
was last sunday really 2 weeks ago
mongo uses indexes to execute queries faster
use them if you're not doing so already
If you're hosting it on the same machine and using optimized queries, the latency should be very minimal
Maybe you can post more about what exactly you're doing
There may not be a need for it to be cached at all
well, I do not host it on my machine, and although it is pretty speedy, I would like to lower the time it takes to get the data
no
Would it be possible for you to change that
tbh, I do not know how
Because that would be very beneficial
How would I do that?
If you want to install mongodb you can use this https://docs.mongodb.com/manual/installation/
If you're using one of the more common operating systems/distro's it should be pretty simple
thank you for showing me this
yeah atlas
higher for atlas right
yes
thats what I thought because you said that earlier and it just makes so much more sense
because you know, data has to go from their server to yours
yeah
It might take a while setting it up the first time, but once you got it, you're good
Any issues you run into, you'll probably find an answer for on google
I never thought of hosting it myself, I didnt even know I could
hey how would i make this have the ability to filter multiple people to use the command
to have mutiple id's work
https://cdn.discordapp.com/attachments/468249189332287498/690663970150940672/unknown.png
@next mica make an array
var allow = ["id1","id2","id3","id4"];
if(allow.includes(message.author.id)){
return message.channel.send("Bran4Real....");
}
message.reply("Blablabla");```
@next mica
If u want u can store all in a json file or sqlite, mongodb etc...


how would i do that dany
they literally wrote the code for you
What u want to use?
so i have watched this vid: https://m.youtube.com/watch?v=BPvg9bndP1U but i am stuck at 8:55, git init command in cmd wont work.. now, i have installed git, but it still dont work. what to do?
How to host your discord bot for free using heroku. This tutorial shows you how to host your python bot for free using heroku services. We simply need to setup a few things to heroku, upload our code and turn the bot on!
Text-Based Tutorial: http://techwithtim.net/tutorials/...
dont use YT tutorials
can you help me then?
the json file thing
I do not hate YT tutorials I just think they should be watched to learn, and not to follow
Okay, but anyway, i want to upload my bot written in python to Heroku.
@next mica use fs
@crimson vapor you know?
I use ubuntu for git commands so I dont know
ok thanks
me?
you
ok so now how do i use this fs
lol it worked now
it was just bad tutorial
dude forgot to say the bot has to be in the map where python is located
...
@earnest phoenix how do i do the fs thign now
hey guys
how do I wait for all my shards to load?
before letting users enter commands
I want to wait for all shards to go up before people can run commands because I need to get an emoji from a specific guild in my shards
wait until all shards emit the ready event
@mossy vine i got stuck somewhere else now, when i did: heroku git:remote -a pythondiscordbottest i got:
» Error: You do not have access to the app pythondiscordbottest.
»
» Error ID: forbidden
Look at your brackets and what you are trying to do
You're spamming the bottom message every time the bot gets any message.....
why are you comparing an array to a string
That too....
i dont know
Please learn the basics of your language first
learn the language so you can understand what you are doing wrong
spoonfeeding is Bad with a capital B

so, u installed git but it won't work when u run git init
what do u get in the console
@next mica some advise, you can go to VSC settings and enable the format on save function and it will format your code for you
try {
member.sendMessage(text);
} catch (error) {
message.channel.send(`⚠️ **Message cannot be sent to the user!**`);
return;
}
message.channel.send(`📩 **Message Send!**`);
Discord.js version 11.4.2
It doesnt work well
you cant catch promises like that unless you await them
also, use message.author.send instead
or user.send
if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send(":octagonal_sign: **Your Missing `MANAGE_GUILD` permission to run the command!**");
const member = message.mentions.members.first() || message.guild.members.get(args[0]);
if(!member) return message.channel.send(":no_entry_sign: **Mention the user you what the message to be sent to!**");
let text = args.slice(1).join(" ");
if(!text) return message.channel.send(":no_entry_sign: **Send a text to be sent to a user!**");
try {
member.sendMessage(text);
} catch (error) {
message.channel.send(`⚠️ **Message cannot be sent to the user!**`);
return;
}
message.channel.send(`📩 **Message Send!**`);
try {
await member.sendMessage(text);
} catch (error) {
message.channel.send(`⚠️ **Message cannot be sent to the user!**`);
return;
}
Like this?
Works 🙂
Thank you!
try {
await member.user.send()
} catch(error) {
await message.channel.send()
}``` would be better
Thanks!
ok so
promises
can you await somrthing but also catch it?
like await promise().catch()
why would you want to?
You can.
The return value will be whatever the return value you got from the .catch method.
In v12, how can I get the person containing the role x ID to do something? when updating I didn't see any of that
What do you mean by "do something?"
That I return and send a message
so like message.guild.roles.cache.find(r => r.id == 'id')
and then do something with all of the members
cache.get(id)
bloody .cache is gonna annoy me
Im gonna leave my bot in v11 for that reason, besides not really deving it too much now, i dont wanna have to go through and add .cache everywhere haha
honestly, it wasnt too bad changing all the commands
really annoying
but only took a few hours
yall are aware that a lot of editors allow you to replace text based on regex, right?
which means you could've been smart and done hours of work within 30 seconds automatically
well, I was rewriting a few things when I updated to 12 so it kinda fit in well
what do you guys use to monitor your vps remotely
whenever I close the bot, it always gives this message
probably something to do with the TopGG cog, but not sure what
Hey my music bot is not playing music after generating a new key
hewwwo
so
i just recently moved ansura to a vps
and i ran my startup script without sudo
cuz i didnt like putting my password in every time i restarted it
and for some rreaon
pip doesnt seem to be installing the stuff
thats the startup script
i always used to do sudo pip3 install -r requirements.txt
running with sudo- same problem
this always used to work when i ran ansura on my laptop
(@ me)

bit manipulation iirc
and << >>?
yes I think
const double = (n) => n * 2;
const increment = (n) => n + 1;
// without pipeline operator
double(increment(double(double(5)))); // 42
// with pipeline operator
5 |> double |> double |> increment |> double; // 42
I prefer this pipeline operator tho
How do I fix Internal Error 500 on a node based website running CentOS with CPanel and WHM?
I think I made this loop command wrong
let fetched = ops.active.get(message.guild.id);
if(!fetched)
return message.channel.send("There isn't any music playing in this guild!");
if(!message.member.voiceChannel)
return message.channel.send("You are not in a voice channel");
fetched.dispatcher.loop();
message.channel.send(`Successfully loop the track **${fetched.queue[0].songTitle}**`);
}
exports.help = {
name: "loop",
aliases: ["repeat"]
}```
It says in the console that fetched.dispatcher.loop is not a function. How do I loop?
ownerID: ownerID,
active: active
}```
i mean what’s active
i mean like what’s inside that map?
This active thing creates a queue system
I dont even know if dispatcher is a thing in the map
ik
what are its properties?
Dispatcher is in my play command
wait did you a followed a tutorial from youtube for this?
because it seems quite famillar
Yes I did. I'm an amateur at coding. It's very similar to Plexi Development's code
thats what i thought XD
i used to follow his tutorials too
Me too lmao... We all start from somewhere...
So, how do I fix my error?
I figured that out. What should I replace it with?
maybe add it to queue one after another?
that might loop it
@wintry sonnet are you using discord.js?
Yes
Hmm
im not that experienced in playing with voiceConnection, I only used it to make voice levelling
Whatever that is :p
plexi development’s videos are mostly outdated btw
i suggest you go through the documentation instead of following a tutorial
that way you can learn more and in a more “updated” way
Well, I did ask TrueXPixels for him to update the series, but he said it will take a while
ok i think i know a way to loop
simply push the current song into the queue when the song ended
@earnest phoenix well as you tell him to find it through discord.js documents page...
It will be impossible for him to find it or may take way too long... Because the code in discord.js documents might be different than his code and would be difficult to figure out...
i used the documentation anyways
I think he should follow an updated tutorial on YouTube or something tho...
updated tutorials are good for starters
Yup
but if you need to make a more complex command, you might need to use the documentation
But now updated tutorials are going missing... When i started to make a bot i followed tutorials which were old and some of the codes were renamed or moved to a new category... So it confused me...
Updated tutorials aren't such a thing anymore... Rip
the docs should be enough to be used as a tutorial
as long as you know how to use it
Ik but like making a music bot or something like that which discord.js documents doesn't show how to actually do it... So... Anyways...
the documentation does show it
but its seperated
you just need to piece them together like a puzzle game
But if you Know how to do it... I mean it doesn't help for the very beginners...
thats true
And that's what I'm trying to explain...

I have my own domain so
stackflow maybe
but yeah
gitbook is okay too
hosting the website itself is not a problem
I have everything I need
well im off Imma be working on making the guide today
Hey anyone can help me why after generating new youtube api key also my music bot is not working
Do I really need to answer that
You made a new key but did you also update the key you are using in your music bot to the new key?
@earnest phoenix
how to do that
Oh god
I didn't get any option like that
no im out of here
I can't take this anymore
just Update your code with the new key
is that hard
not if you explain me
do that
search for your key where you are using it
and replace the old key with the new one
Yeah I did that
is this one of those github-forked bot
nope
where you don't know anything about the bot

