#development
1 messages · Page 1216 of 1
??
what
yes
emojis are stored in servers/guilds
if your bot isnt there, it doesnt have access to it
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
put the bot on the same server the emoji you want is in
ok
Code language?
@dapper vapor
Code language?
@ancient jay py
it works pog
https://tryitands.ee
@nimble kiln wait is that a bill warts vid?
how can i get the upvotes and # of replies on a reddit post?
no idea
using praw
lol
For some reason, my bot doesn't send any gif, how do I fix it?
ask it nicely to work
mmm that never works threten it with a shovel
can my bot be rate limited for deleting messages?
it can be ratelimited for anything
it can be ratelimited for anything
@earnest phoenix whats the limit?
it isn't baked in
like for messages deleted?
ok
well how much is normal?
like how much can i do safely
yea ok
follow the ratelimits returned in the headers
?
if you're using a library, chances are it already handles it for you
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
huh?
also whats the message author pfp?
like if i were to get the message authors icon url?
wut us ut?
i tried {ctx.author.icon_url}
Don't abuse the API, and you won't get rate limited
i tried
{ctx.author.icon_url}
@drifting wedge its avatar_url
isn't icon_url for guilds
he said
also whats the message author pfp?
like if i were to get the message authors icon url?
But yeh its for guilds, there are also kwargs on discord.Embed methods
sorry i mean avatar
oof
fs.creatfilestream is always throwing no file/directory found if its not in the same directory at that command
any way to fix this?
Its creating file if its the same version too
not if it isnt
i have a property called random color
embed = discord.Embed(
colour = discord.Colour.rcolor()
)
does this work
i did rcolor = random_color
no attribute
py btw
how do i convert a nested array to a normal array
@small prairie there is no filestream
there is readstream and writestream
@errant perch you can use array.flat() in node v12+
rip i meant write
var fileName=${__dirname}/recordings/${Date.now()}.pcm
let writeStream = require('fs').createWriteStream(fileName)
this is what im using
This should work right? @quartz kindle
yes it should work, as long as the directory is correct
__dirname refers to the directory of the current file
Yea so the only problems can be in recordings/${Date.now()}.pcm part
how is your folder structure?
or just console.log(${__dirname}/recordings/${Date.now()}.pcm)
to make sure the full path is correct
[Error: ENOENT: no such file or directory, open 'root/marlowe/recordings/1599262322574.pcm']
Wait what
Oh
bope
nvm
still doesnt work
make sure the "recordings" folder exists
it does
if you're hosting in a vps, make sure it exists in the vps as well
what does console.log show?
console.log for?
${__dirname}/recordings/${Date.now()}.pcm
a sec
how do i convert a array thats like [{ }] to just {}
array[0]
it returns as undefined
Im im dumb
Anyways thanks for trying to help me @quartz kindle
i just forgot a /
;-;
lmao np both
2 for 1 lmao
dinger
i swear it feels like i could solve world hunger but cant solve some of the smallest problems
im trying to make my first bot and the pom.xml file being weird
what am i doing wrong
hover over the red text and tell us what it says
it says depandancy not found
Hey Tim, can you take a loook at this? #development message
@earnest phoenix do u want me to try it or where u talking to someone else
was talking to vo1d
as for your issue
you probably didn't add the maven repo JDA is in
hey guys
i have a question
if i want the user to tell me a welcome channel how do i get the id of the channel?
in discordpy
you already asked this and i sent you a doc link covering it
there's literally an example on the page
thanks
actually read what it says on the page, not just the colorful code blocks
??
you can't get the badge anymore anyways
you can just use message.channel_mentions
I sent before @split hazel Before 19 August
dpy has a command handler that's built for parsing positional arguments, it's good practice to use that instead
doesn't matter if you submitted the bot before the date
dev badges cannot be obtained anymore
you should ask here about verification related questions discord.gg/discord-developers
we're not affiliated with discord
okey thanks
Hola
Okay so the discord.js's VoiceReciever class or whatever
How to play the opus or PCM on these?
Anyone experienced with recieving audio on d.js?
you need to first send some audio to receive
VoiceReciever? isn't that for receiving?
Yea i have like 5 megabits of stuff
i was able to recieve and store
but I dont understand what format it stored in
Is opus like Raw or different?
encoding used by discord
Okay
but like i said you can probably check out the format with ffprobe
Um never used that
there's a first for everything
Download FFmpeg builds for Windows or macOS, available as LGPL or GPL.
I am trying to make a command that creates a canvas attachement and if you react to get one page ahead/backwards, it should edit the embed and create an other embed with a canvas as an attachement. The thing is, when I go forward, the old canvas attachement is still there. My idea, when I go forward(with the reaction) it should delete all the last attachments, Does this look good?
forwards.on('collect', (r, u) => {
let messages_ = message.channel.messages.fetch({ limit: 10 }).then( message =>{
let findImage = message.attachments.find(attachment => attachment.filename.endsWith('png') || attachment.filename.endsWith('jpg') || attachment.filename.endsWith('gif'));
if(message.attachments.size > 0){
if (findImage !== null) {
message.delete();
}
}
})
.....
}
see https://ffmpeg.org/download.html for all platforms
sad all say invalid data format
you cannot edit message attachments @midnight blaze
I know
I have made an embed within a canvas
it edits the embed, then the canvas is still there
How do i handle/end it if i have done the "Manually" option?
ctrl+c should work @small prairie
Ah so just killing the bot lmao
I think you clearly got that I knew that you can not edit canvas..
noi ffprobe said all my files contains invalid data
i suppose they are corrupted?
@midnight blaze check if message.attachments has a length bigger than 0, if it does, delete it and send a new one, otherwise edit it
And i have set the https://legendary-king.is-inside.me/Zp1SdGNx.jpg to option to manul
But i dont understand how it should be handled
Is there a "endStream" function or something?
destroy the stream
function for that?
i just destroyed the bot everytime i had to end ;-;
since im testing rn
what its still saying invalid data
stream = connection.receiver.createStream()
stream.pipe(writeStream)
once you want it to end: stream.destroy()
How can i use the Opus data?
if(message.attachments.size > 0){
message.delete();
}else{
msg.edit(embed2)}
Embed2 => is the embed with the canvas.
If I go forward, the old canvas(attachement) is still there and it wont be deleted.
Should I fetch the messages?
@small prairie try downloading it to your pc and opening the file with vlc or something that supports opus
VLC played nothing and audacity just registered noise
try setting the receiver to pcm mode
That didnt even open with VLC
Oh btw Audacity kept telling me i have to import these files as RAW files
yea how can i use that opus?
huh?
vlc should support playing opus streams
you can also just set the mode to pcm when receiving audio
opus will automatically be decoded to pcm
I dont really know much about audio stuff
So if i every want that back as a file which can be played through normal MP players what should be better?
opus is going to be lighter for storage
Yea i observed that
alot of difference
this is what i just got from VPS
Wait is this code even correct?
if(!msg.member.roles.cache.has("737346838063087629"))
{
msg.reply("You must have Trending Artist to use this category ( Level 10 )")
}
else
{
if(!msg.member.voice)
{
msg.reply("You must be in a voice channel to start recording")
return
}
var voiceChannel = await msg.member.voice.channel.join()
var reciever = voiceChannel.receiver
var fileName=`/root/marlowe/recordings/${msg.author.id}-${msg.guild.id}-${Date.now()}.opus`
fs.writeFile(fileName,"",err=>console.log(err))
let us = reciever.createStream(msg.author, {mode: 'opus', end: 'manual'})
let ws = require('fs').createWriteStream(fileName)
us.on("data", (chunk) => {
console.log(chunk)
ws.write(chunk)
})
setTimeout(()=>{
ws.destroy()
us.destroy()
},10*1000)
}
Rip i thought that if i do that i'll record audio even when i aint speaking but i just realized it wont ;-;
changing to pipe
Done
So its pretty basic normal i guess it should work right?
extension shouldn't matter in the slightest
it's just an instruction to the os on how it should behave with the file
Rip it isnt working
setTimeout(()=>{
ws.destroy()
us.destroy()
},10*1000)
the file was less then 1 second long
how
is it always 30kb
i remember that a discord limitation for bots is that they have to send audio to receive first
not sure if that's still in place
If I go to page two, the embed now will be edited, the canvas doesnt change tho, it stays the same, and I dont see how. I literally change the canvas before the edit.
i remember that a discord limitation for bots is that they have to send audio to receive first
@earnest phoenix That makes sense
i have to use my music feature every time i have to use that
@quartz kindle sry for ping, but do you have any idea, what the cause could be?
are you trying to change the image on every page
yep
i told you that you can't edit attachments
no you didn't
I deleted it
editing attachments is not possible
I create an attachement
delete it, when it gets to page two
create a new attachement
hmm 🤔 damn
you're overengineering this
just send the images in a private discord, keep a reference to the urls in your code and put them in the image url of the embed
you can update them every few hours
(to keep the stats you have at the bottom up to date)
Error with PCM https://legendary-king.is-inside.me/bcADkR6s.jpg
Oof
whats wrong with this ;-;
can you send the file over?
thanks for that nice idea O:
ffprobe returns invalid data too
Yea
did you do the sending audio first thingy
Yes
that's extremely weird
if i dont there are 0 bytes
Its recieving but not encoding?
Should i reinstall packages
i'll see what hxd returns
Whats that?
a hex editor
is there any node module to encode it to Mp4 which discord natively supports?
it might be because you're writing directly from discord so the file header is missing:
audacity just defaults it
Ah
Nah
even audicaty cant read
i do import as raw
then it knows its RAW so
it does everything on its own
But why isnt Opus working?
this is much heavier for future
probably has to be decoded with specific settings
is there any node module to encode it to Mp3 which discord natively supports?
from djs src: ```js
new prism.opus.Decoder({ channels: 2, rate: 48000, frameSize: 960 });
what do you mean with the last part
which discord natively supports
I mean you can directly play from discord
mp3's and vids you can directlyt play without installing
Just download is enoughf or them :/
from djs src: ```js
new prism.opus.Decoder({ channels: 2, rate: 48000, frameSize: 960 });
@earnest phoenix Oh damn thats some important things
can anyone point me in the direction for setting up a web interface for my discord bot
like a settings dashboard
If its that simple i can keep it as PCM and just double decode it to MP3 later
ffmpeg just errors out
Lmao
can anyone point me in the direction for setting up a web interface for my discord bot
@charred geyser it's much more complicated than you think
its very very complicated ;-;
rip
bruh
https://github.com/kamranahmedse/developer-roadmap over half of what's stated here (frontend + backend) is required in order to make a secure dashboard
Discord seems to be using this https://www.npmjs.com/package/prism-media
whats the rate and channels for MP3
maybe if i decode for that it directly makes mp3 compatibility?
there's no specific one
Yea theres like this huge range or something
These are what audacity gives if i convert PCM to Mp3 https://legendary-king.is-inside.me/nmHWwU8H.jpg
how do i make my bot leave a vc after 2 mins if music isnt being played or if its alone?
usig py
https://github.com/discordjs/discord.js/issues/4780 this is more than likely related @small prairie
seems that voice receiving in djs is a bit fucked
In any library it is
discord doesn't provide much documentation about that himself
from what I've heard
how to count user's nickname lenght
nick: Must be 32 or fewer in length.
what's a good way to make a status webpage for a bot, where it displays the uptime of the bot, like discord does here https://discordstatus.com/
how to count user's nickname lenght
@earnest phoenix what library
discord.js
nvm
lol
nickname.length? 
yeah
on python its len(member.display_name) but idk js
hmmm
what's a good way to make a status webpage for a bot, where it displays the uptime of the bot, like discord does here https://discordstatus.com/
@opaque seal it's not what discord made, they use statuspage
im doing a afk command
@opaque seal it's not what discord made, they use statuspage
what's that
when they into afk its gonna change nickname to [AFK] name
you can also see it appear on cloudflare's status site
Oh thats a cool idea
Uhm, can I use that for my bot too?
Might add that to my bot, aint too hard
sure
sure
@earnest phoenix read that issue
Exact same thing as me
k
what is it
Welcome command thing or triggered auto mod
I’ll test it on my private bot that’s somehow better then my public
what do you want?
Than
a welcome message?
Ok
Well I’ll get to work once I finish my play list
Thank
You
:0 can I add my private bot to this server 
is there a possibility to ignore the first fetched message?
message.channel.messages.fetch({ limit: 2 }).then(msg => { msg.forEach(m => { (m.attachments)?m.delete():console.log(1) }); });
I am trying to ignore the first message. It should jump to the next one
:0 can I add my private bot to this server
@lavish tinsel you have to wait
Like a month +
@lavish tinsel you have to wait
@steep shale oh
Because I just saw this
@lavish tinsel That's my bot! :D
I have been here for a month I think
Wow nice
You added it to the website?
Or this server
Because I’m confused
I mean you have to wait a month +, once you added the bot
@steep shale OH you mean like when the bot is registered on the website I have to wait a month to invite it here?
Then list it?
Bots here are only the approved ones from this server
How do I check if a user leaves the VC
Back is this general chat?
Where is the general chat please
in which library
discord js
I don’t know what yoh mean
Sorry, I have to take a little rest
Ok
Ok my playlist is done time to get work
the channel in the new voice state will be null if they left a channel
good bye
Ok
@opaque seal it's not what discord made, they use statuspage
@earnest phoenix wait isn't that automatic, doesn't statuspage try to ping a website to see if it is online?
from discord.ext.commands import cooldown, BucketType
...
@cooldown(amount_of_uses_to_trigger_the_cooldown, seconds_to_wait, BucketType.user/guild/channel)```
@drifting wedge
ty
So example if I wanted a 2 second cooldown, after 1 use for a user only would be ```py
from discord.ext.commands import cooldown, BucketType
...
@cooldown(1, 2.0, BucketType.user)```
@earnest phoenix are you here? 🤔
I think I managed to do it 👀
do you want to see it?
it looks sketchy tho
@earnest phoenix wait isn't that automatic, doesn't statuspage try to ping a website to see if it is online?
@opaque seal manually updated, that's why the status page is so slow on real time updates
also, sure davon
testing 1
@opaque seal manually updated, that's why the status page is so slow on real time updates
@earnest phoenix that's kinda useles, I thought the whole purpouse of a status page was to automatically check the status of an application every x minutes
do events decorators have ()?
nah
wut abt for cogs?
Hello
@steep shale
Yeah
Yeah
but not normal events?
from discord.ext.commands import Cog
@Cog.listener()```
wut abouyt commands.cog.listener?
Remove the commands from the import
from discord.ext import commands
@commands.Cog.listener()```
Need what?
from discord.ext import commands
yeah you do need that
o ok
Or if you want it to be shorter without the @orchid spindlends... just do the first option
@commands...*
Mans really named himself Comma
lol
and thats why you always escape possible mentions
code = ABC
if (!code == /[A-Za-z]{4}/i) {
message.channel.send('hmm... That code seems fishy')
return
} else {
message.channel.send('success')
}
//returns success
Why this code returns success even though the code is 1 letter short?
What language even is that
guys
ok well im done with my welcome message thing @steep shale
I am using python
ok
I want my bot message to be deleted after 3 seconds
my command is not working
@sweet kestrel show the command code
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "stats" is not found
like this is the rror
@cooldown(1, 0.5, BucketType.guild)
async def stats(ctx):
serverCount = len(commands.guilds)
memberCount = len(commands.users)
embed = discord.Embed(
colour = discord.Colour.blue()
)
embed.set_author(name='Arch | Stats', icon_url=f"{commands.user.avatar_url}")
embed.add_field(name="Total Servers:", value=serverCount)
embed.add_field(name="Total Users:", value=memberCount)
embed.set_thumbnail(url=f"https://imgur.com/kmtYlLV.jpg")
embed.set_footer(text=f"{ctx.guild.name}", icon_url=f"{ctx.guild.icon_url}")
embed.timestamp = datetime.datetime.utcnow()
await ctx.send(embed=embed)```
await message.channel.send('bruh')
await message.delete()
await client.delete_message()
await asyncio.sleep(4)```
this is the cod
this error shows
up
@steep shale
bruh
?
await message.channel.send('bruh', delete_after=4)
And message.content.delete doesnt work?
So do what I said
I actually havent tried message.content.delete
await message.channel.send('bruh', delete_after=4)
ok thankyou @steep shale let me try that
and i need to get the id of a channel that they specify
how to do that on discordpy
@slender thistle
-atmods
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
deleting it makes it worse
oop
sorry
and i need to get the id of a channel that they specify
how to do that on discordpy
pls help m e
how
and then the copy the channel id
wut is sytanx?
no like how to get the channel.uid
?
lol, you need to do right click on the channel
@sweet kestrel he means code
no like from a bot
if im not in the server i cant do that
in discord py
What are you trying to do?
i do lol
basically i want to make a bbot that welcomes a user
so i need to get the channel id so i can send the message to the specific channel
I did that
Use on_member_join
@steep shale ik that
channel = bot.get_channel(the_id)
Or probably channel = await bot.get_channel(the_id)
turn on developer mode
yeah
#starboard would return <#ID> but I’m not sure how it works with py
Turn on developer mode
you might wanna try the py server
bruh
idk
Use a database
no
yes
he needs to GET THE ID
Thats what I did
use a database
what database is he using
with djs I could just say trim() it but idk how py works
json

what
what r u trying to do?
that's some retarded logic
json is annoying
im trying to make a bot that welcomes a user
json is not a database and it never will be one
thats dumb as hell
what library?
json is easiest to use
@random blaze dumb asf
idrc
you can make yourself a json db, but you need to add a lot of things, so it wont get corrupted. MongoDb does that for you already
stole this
help
listen to on_member_join to check when a member has joined the server
but yea
mongo doesn't store in json
yes
can we answer my ques tion
I completely stole that
i did
not abotu json vs SQL
you can make yourself a json db, but you need to add a lot of things, so it wont get corrupted. MongoDb does that for you already
@thick gull mongodb is trash
@digital ibex u didn't
its not

@steep shale help lmao
i need to get the channel id from the channel that the user specifies
can we answer my ques tion
@random blaze i just asked what database you’re using
imo py is trash too
how do i make a f string and do member.mention?
f"{member.mention}"
uh
huh?
jspn'
wait what?
idk what language your using
which one
i need to get the channel id from the channel that the user specifies
@random blaze SOMEONE HELP ME
python
Json isnt good for that
I am using python
oh ok
Use a database
do json file or database
If you want people to set a specific channel with a command, use a database
thats very broad, externqlly. its different logics mashed up together
lol
@digital ibex wdym
what th
like
the user gives me a channel, i need to get the id of the channel
idk how to explain it
If you want people to set a specific channel with a command, use a database
its like, how do i code in a programming language
theres many answers and loads of parts to it
I don’t know if py returns it as <#ID> or whatever
if that makes more sense lol

um, why wouldnt it?
i have another question
ctx.member
um, why wouldnt it?
@digital ibex because I’m not trying to feed false info but help the poor soul while you rip him apart for using json
i didnt say anything about using a json database
yea Idk how python works I’m just tryna help the guy and give him a general area to start
all i said was i find using json as a db is annoying, which i wasn’t talking to him
idk if it was you im too to scrol up
giveaway command or leveling command thing
he asked how to get the id of the channel
@thick gull whicu is why he needs a database
@steep shale 😦
no
Cause he wants people from multiple servers to set a channel
If its one server then its without
you don’t get an ID from a database if you don’t know how to get said ID to save
@sweet kestrel show the function
he needs to get the ID first
it doesn’t pop into existence
Yeah but what you dont understand is that he wants people from multiple servers to get a channel, he would need a database for that so he can get the channel from that specific guild
@thick gull
@sweet kestrel show your async def
Which is why he needs a DATABASE
Oh my god
he needs the ID
Bruh
you can’t use a DB if you don’t have the ID
then tell him that
He doesnt want to understand
I don’t know shit about dpy
He needs a db
wait, what do i do?
Then help him
I made my own customized welcome/goodbye system using a database
cause i use both
You need a database
yep
He doesnt want to understand
definitly
That’s really not that hard the mans asking how to get the ID from this: #announcements > 285458046006591499
Mysql isnt the best
@sweet kestrel
?
Send your command complete
bo im done with you bruh
@sweet kestrel show the async def again
+this
Its message.author.mention
Np
yeah
Sure
you guys are nice 🙂
how does this work😄
what is "this"
nothing nvm
CAN SOMEONE HELP ME
the user gives me a channel, i need to get the id of the channel
You too?
what library?
Do you want it so multiple people can do that?
@modest smelt code and lib
i don't know how many times i have to tell you
this is like the third time
use the dpy converters
rgba 0 0 0 0
...'
🧠
rgb with an alpha channel
oh
;lol
does anyone have any knowledge at all about creating a web dashboard for a bot?
you create a backend and update your database
i mean, in slightly more detail
like
uh
idk
i have a mogodb database
rn it just stores info about a server it joins
and records its prefix and shit
but
how do i fix (node:2264) UnhandledPromiseRejectionWarning: Error: FFmpeg/avconv not found!
idk where to even start making a dashboard
then just html coding from there
the same way you connect it from a bot
i would recommend .ejs to use html and js together
if you wanna make a whole thing like that of the mongoose stuff make a new file and then just import it into the ejs one
that doesn't seem horribly complicated
just html coding is the hard part really
code = ABC
if (!code == /[A-Za-z]{4}/i) {
message.channel.send('hmm... That code seems fishy')
return
} else {
message.channel.send('success')
}
//returns success
Why this code returns success even though code is 1 letter short?
!code == /[A-Za-z]{4}/i this isn't doing what you think it's doing
!code = convert code to a boolean and negate it
so code must be a string of letters at least 4 characters long
ok, i understand
Not 'at least'
then you need to use regex.test(str), which returns true if the specified regex matches str anywhere
Huh
/[A-Za-z]{4}/i.test('ABCD');```
note that that will return true if code contains a sequence of 4 letters anywhere at all
add ^ and $ to assert the start and ending position in the string
/^[A-Za-z]{4}$/i
if (test) console.log("success")```
Is this correct?
try it and see
why am i getting the error (node:13944) UnhandledPromiseRejectionWarning: Error: FFmpeg/avconv not found!
Can lavalink do YouTube streams?
try it and see
is there naybot left for verify today
Im new and this are scrim
@astral yoke https://ffmpeg.org/download.html
i ficed it
Ecks Dee
@queen violet why is toktok broken
i looked at the api, and you can bypass private video filters
My bot gives ping in negative
flip the subtracts
your logging xd
and the message has to be cached
send a message and then do it on that message
once it’s on
ok
why would you join a single thing
args.join(‘ ‘) would be the entire thing
unless you mean args 1 and 2
I want that text is all after args 0 @thick gull
How?
args.slice(1); = get a copy of args from index 1 to the end
My bot gives ping in negative number
And got this... @sonic lodge
you're trying to substring a message, which is a message object
ah
the error does not seem to be complaining about that though
no

it's an array
Does anyone know about JDA 4 Sharding?
Can't really find anything about it anywhere, i'm new to sharding as well
so its a bit confusing
@ me if you know how to fix it.
:/
how to log errors in your command handler, or do i need to make in every command a catch?
How to verify a bot?
Ok
then you get a dm from discord asking you to provide id and answer a bunch of questions
@delicate shore flip the subtraction
@thick gull
I do everything correctly
It just sometimes give in negative
snowflakes aren't generated by the same machine
if one is generated on one machine, and the second on another machine, it is entirely possible for the second timestamp to be before the first
You are saying me ?
yes
Oh
don't worry about it, it just means your bot is living in the future
genius
No one:
My command handler:
// index.js
const commands = require("./commands.js");
bot.on("message",async (message) => {
// some switch statements
case "some-command":
commands.some-command(message);
break;
});
// commands.js
exports.some-command = async (message) => {
message.channel.send("smth");
}
No
i may me retarded af or some but my uptime for my botinfo command, it only labels the hours, minutes, and seconds except for the days>
this is my code
function duration(ms) {
const sec = Math.floor((ms / 1000) % 60).toString()
const min = Math.floor((ms / (1000 * 60)) % 60).toString()
const hrs = Math.floor((ms / (1000 * 60 * 60)) % 24).toString()
const days = Math.floor((ms / (1000 * 60 * 60 * 24)) % 60).toString()
return `${days.padStart(2, '0')}d, ${hrs.padStart(2, '0')}h, ${min.padStart(2, '0')}m, ${sec.padStart(2, '0')}s `
};
`**❋ Uptime:** ${duration(client.uptime)}`,
it looks fineish to me but.
i dunno
kinda want my days to show
any suggestions?
i might just be really dumb and i might have just fixed it
idk
Hi im kinda stuck using mongodb nodejs
I want to have a function that checks if the Server document exists, and if it does it sets settings = to the JSON of that doc, otherwise it uses the Defaults document and sets that equalt to settings. And i want "settings.prefix, welcome, etc." to be able to be called outside the callback function
i dont currently work on using welcome messages and such but i do for prefixes. if u need someone else with more experience then you'd have to wait a lil while
lol
@Not Erwin
hey guys
could someone help me with these errors:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channel' of undefined
at check_not_in_DM (c:\Users\bilal\Desktop\fitlering\bot.js:79:16)
at Client.<anonymous> (c:\Users\bilal\Desktop\fitlering\bot.js:97:7)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (c:\Users\bilal\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (c:\Users\bilal\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (c:\Users\bilal\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (c:\Users\bilal\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (c:\Users\bilal\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (c:\Users\bilal\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
<node_internals>/internal/process/warning.js:32
(node:3032) 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: 7)
<node_internals>/internal/process/warning.js:32
Process exited with code 1```
Whatever you're calling channel on is undefined
Showing a snippet of the code that's causing the error would help
okay
hold on
class NotInDMError extends Error {
constructor() {
super('I can\'t execute that command inside DMs!');
}
}
function check_not_in_DM(message)
{
if (message.channel.type === 'dm') {
throw new NotInDMError();
}
}```
if (msg.startsWith(prefix + 'WEATHER')) {
check_not_in_DM();
return message.reply('Not implemented yet.');
}
else
{
check_not_in_DM();
let [skytext] = msg.slice(prefix.length).split(" ");
console.log('Seaching locations with:', skytext);
let locations_found = await get_location_by_skytext(skytext);
console.log({locations_found});
if (locations_found.length === 0)
{
return message.channel.send('No location found.');
}```
}
catch(e)
{
if (e instanceof NotInDMError)
{
return message.reply(e.message);
}
else
{
throw e;
}
}
});```
this is everything
that has something with dm in it./
@eternal osprey you have the function defined as check_not_in_DM(message)
but you're using it as check_not_in_DM()
you dont give it any message to use
if (!message.member.permissions.has("BAN_MEMBERS")) {
^^
SyntaxError: Unexpected token 'if'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at C:\Users\vds\Desktop\Pink Girl V12\handlers\command.js:19:24
at Array.forEach (<anonymous>)
at module.exports (C:\Users\vds\Desktop\Pink Girl V12\handlers\command.js:11
:32)
at C:\Users\vds\Desktop\Pink Girl V12\server.js:22:35
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\vds\Desktop\Pink Girl V12\server.js:19:13)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)```
help
hmmm @quartz kindle so should i define message?
(node:464) 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_internals>/internal/process/warning.js:32
(node:464) [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.
<node_internals>/internal/process/warning.js:32
(node:464) 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:464) [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.
uhhm something isn't good
you should pass the message to the function
i have
lets see
but when running my bot again
i get this error again
should i give you my whole code?
yes
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.
i am using weather-js package
check_not_in_DM(message);```
no
hmmm
not line 102
