#development
1 messages · Page 1022 of 1
err?
as thumnail
it says
embed.thumbnail.url: Not a well formed URL.
at RequestHandler.execute (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:27518) 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: 1)
(node:27518) [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.
<user>.displayAvatarURL()
@earnest phoenix ok
Can I have some help? It wants a semi-colon at the fullstop but when I put one there it gives me more error's
@earnest phoenix nope
not working
if(command === "whois"){
let member = msg.mentions.members.first() || msg.member,
user = member.user;
const joinDiscord = moment(user.createdAt).format('llll');
const joinServer = moment(user.joinedAt).format('llll');
let whois = new Discord.MessageEmbed()
.setAuthor(user.username + '#' + user.discriminator, user.displayAvatarURL)
.setDescription(`${user}`)
.setColor(`RANDOM`)
.setThumbnail(`${user.displayAvatarURL()}`)
.addField('Joined at:', `${moment.utc(user.joinedAt).format('dddd, MMMM Do YYYY, HH:mm:ss')}`, true)
.addField('Status:', user.presence.status, true)
.addField('Roles:', member.roles.cache.map(r => `${r}`).join(' | '), true)
.setFooter(`ID: ${user.id}`)
.setTimestamp();
msg.channel.send(whois);
console.log();
}
@still merlin ?why not a string
so what to do?
are u doing try catch? @delicate shore
no
then its strange
use setFIELDS
I tried a string just now and more errors
no error = strange case
@still merlin what exactly is that for? attachment?
I want to set the backround to a image
i can see that
but thats not what i asked
is that form a file or what?
you trying to send an attachment on the body?
not working
@still merlin usually you'd be pointing at an url when setting background img(a string)
do u guys use ngrok?
-bash: ./ngrok: Permission denied`` why am i gettin this ?```
@delicate shore any error

@delicate shore any error
@restive pebble nooe
strange
@restive pebble nvm
try{
//code}catch(e){console.log(e)}
[@delicate shore ]

no.way lol
oh
those roles gave me cancer
lol
who puts their roles as ----------whateverthefuck--------
@opal plank what about this
inline reee 
if (command === "news") {
try {
const response = await fetch(
`https://newsapi.org/v2/top-headlines?sources=reuters&pageSize=5&apiKey=87a0130e397a4e45a4fd707eb93c5922`
);
const json = await response.json();
const articleArr = json.articles;
let processArticle = article => {
const embed = new Discord.MessageEmbed()
.setColor("#FF4F00")
.setTitle(article.title)
.setURL(article.url)
.setAuthor(article.author)
.setDescription(article.description)
.setThumbnail(article.urlToImage)
.setTimestamp(article.publishedAt)
.setFooter("powered by NewsAPI.org");
return embed;
};
async function processArray(array) {
for (const article of array) {
const msg = await processArticle(article);
msg.channel.send(msg);
}
}
await processArray(articleArr);
} catch (e) {
msg.reply("Something failed along the way");
return console.error(e);
}
}```
this is not working
it says cannot read property send
it was working few days back
idk what happens
processArticle returns an embed, a MessageEmbed object - a class that represents an embed, not a message
yes
Is your message object called msg?
it's called embed
No, embed is a MessageEmbed, it just represents an embed, it's not a message containing the embed
do u use bot.on('message', message =>{
Yes, that's an embed
ok
not a message
const msg = await processArticle(article);
Nothing - that function is perfectly fine, after it you are doing msg.channel.send(msg) which actually means MessageEmbed.channel.send(theEmbed)
MessageEmbeds don't have a channel property
because they're just embeds
now you are sending the message object, replace the msg argument with msg69
And in the catch statement it should be just msg
let processArticle = article => {}```
whats this for?
It's a way to declare an anonymous function and use it
hmmm interesting
@spare mirage Didn't like 5 people tell you yesterday to learn basic js before asking questions?
@tulip ledge stfu
And people won't help you if you don't do as they ask
Im learning js and take breaks to work on a discord bot
These people are giving you parts of their free time and you are not even willing to do what they ask
I am having a small issue
if I console.log this module.exports.code.usage[0] i get
%P%fix [USER_ID]
but calling a function and replacing certain characters gives me this error
(node:16148) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'replace' of undefined
and logging the input the function gets shows this and i don't know where the undefined's source is
%P%fix [USER_ID]
undefined
Here is the code
// module.exports.code.usage[0] --> Works fine, shows string
let new = clean(module.exports.code.usage[0])
function clean(input) {
// input -> Shows string and undefined
input.replace(/%P%/g, client.prefix);
return input;
}
module.exports.code = {
title: "fix",
usage: ["%P%fix [USER_ID]"],
}
Kurasad you can't call the function if it's not in a module.exports
@tulip ledge !?!? I still do it though
In 3 hours people can prob do better then you ngl
that's where it originally was
7.
a. Don’t spoon-feed or attack beginners.
Everyone starts somewhere and asking questions is smart. Do not attack people for not knowing how to code. Point them to great learning sources and help them with problems.
However, you shouldn’t just give them finished code because then they only learn to copy more.
b. If you are a beginner, have a will to learn and do not expect to be spoon-fed.```
What unput are you giving?
a string
Yes but over a span of what I've seen at least a week we have told you to first learn the basics before asking questions
Dont attack beginners. I feel attcked
Im learning js and take breaks to work on a discord bot
Im just not the smartest alive. I guess
while not against the rules, most people will avoid anwsering you a question about a language that you dont even know about. I've said a bunch of times before, a bot is an intermediate level difficulty project, you cant just hop into it without knowing 2 things about it.
^^^
my usual example is:
you're trying to write an essay in russian without knowing russian
@visual sandal What string exactly
usage: ["%P%fix [USER_ID]"],
Index 0
-bash: ./ngrok: Permission denied on ubuntu? why
Oh I see
@opal plank Yes, ur right...
Still I find it weird when I say: "Im learning JS but it takes time" some people go mad on me
¯_(ツ)_/¯
in those instances i keep my sarcastic comments to myself to not lash onto them, but i do tell them to learn the language before asking those questions
Justii you keep asking the same questions and we're trying to help you but you clearly ask the same basic questions every single time
the same basic questions
@visual sandal Try changing let new to let <something> since new is a keyword and thta might be a problem
i just put new as an example, i know that is definitely wrong lol
the main problem when people come are:
- You dont know anything about the language, not even the most basics
- You refuse to do research instead of asking here first, this isnt Bing/Google
- You dont read the Docs which gives ample examples of what you're trying to do
- They ask for spoonfed code
the approach is. Read doc about it. Try it. If it doesnt work, try a couple more times. Still stuck? ask
- You dont know anything about the language, not even the most basics
I totally agree... I made this mistake :/
I see you're using regex can you try it with a string just to see if it might be your regex that is messed up?
@visual sandal
If so we need to change your regex
well, i log it even before the regex and there is an undefined
So input is undefined?
Or what do you mean?
Can you console.log(module.exports.code.usage[0])
I and sending it this %P%fix [USER_ID]
but it is receiving
%P%fix [USER_ID]
undefined
did you define client.prefix?
yea, but the issue isn't even the regex
ok
1 thing right of the bat is that it only uses 1 $ wich is weird
But this seems to work
Wait a sec
kk
You are replacing the string but arent overwriting it
Meaning input stays as input
As you can see here
Yes also
replace doesn't modify the original string
Anyone help me ??
Problem?
unlike shift, pop, and some other methods (for arrays for example)
I’m screenshare on my channel than someone join my screen share than my discord restart
Is there a method that directly modifies a string? 🤔
Idk dude doesn't seem like a development issue
Could be anything actually
No one can join my screen share 😕
Whan anyone tap to join my discord reopen automatically restart
ask Discord
But the thing is the replace isn't the issue it's the input the function is getting cause using my backup function gives me the same error
clean(input) {
let original = [`{PREFIX}`, `{BOT}`];
let replace = [process.env.PREFIX, client.user.username];
for (let i = 0; i < original.length; i++) {
while (input.includes(original[i])) {
let loc = input.indexOf(original[i]);
input = `${input.substring(0, loc)}${replace[i]}${input.substring(loc + original[i].length)}`;
}
}
return input;
},
https://dis.gd/contact @shadow flame
@summer torrent where
click the link I sent
lemme try
No find
@tulip ledge 🤔which one
Depends on your graphics card
Graphics card driver update already
@visual sandal What is your input
Once again
Since if you are sure it's your input causing it it means your input is undefined
if(!message.member.hasPermission("BAN_MEMBERS")) {
message.channel.send("You don't have permissions to use this command! :person_facepalming:")
} else {
let memberId = message.content.substring(message.content.indexOf(4))
let member = message.guild.members.cache.get(memberId);
if(member) {
member.ban()
} else {
message.reply("User not found! :person_facepalming:")
}
}
Can somebody help me why do i always get the message.reply("User not found! :person_facepalming:") even if i enter a correct userID ?
yea, consoling the input inside of the function shows the string appended with an undefined, and idk what the source of the undefined is
Try to log member
Can I make my bot add emojis to a server?
So when you are calling the function
@spare mirage Take a look at https://discord.js.org
@spare mirage yes
@visual sandal Where are you calling the function?
member is undefined
ahh I see thanks
@fresh hatch https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
Why don't you just look for the first mention and then get the id based of the member object?
if (!args.join(` `)) { return message.channel.send(client.src.clean(module.exports.code.usage[0])); };
And module.exports.code.usage[0] logs %P%fix [USERID]?
yep
Even in the same file where you're calling the function
should be
works
What is he wants to ban by ID
calling it in the same file still adds an undefined...
You can then get the argument wich is the id
And then look if the member exists based on the id
you can guildManager.ban
So @visual sandal module.exports.code.usage[0] is undefined
Is what you're saying
Right?
As you said that the input gives undefined
No, it is defined and logs as a string, but when in the function it adds undefined
that's what i get when i log inside the function
and outside the function shows this
ok
What are shards what's purpose of them and how to use them?
@surreal notch Shards is basically making multiple instances of your bot on the same CPU making your bot faster and use less memory although they might use more CPU
As an application grows large, developers may find it necessary to split their process up to run parallel to one another in order to maximize efficiency. In a much larger scale of things, the developer might notice their process slow down, amongst other problems.
Read more here https://discord.com/developers/docs/topics/gateway#sharding
xD
You only need to worry when you are around 1800 guilds and start sharding around 2000 guilds
Okk
@surreal notch

hmm ok
Your problem is the input
module.exports.code.usage[0] is probably not the way you can access it
Are you saving them to your client object?
I remember like 6 months ago i didn't have a command handler and i thought node . would run all my files without a command handler
Cuz you can try to filter the client.<what u saved it to> to find the one with the name "fix" and then access usage[0] from there
Or try console.log(module.exports.code) and see what it logs
module.exports.code.usage[0] is probably not the way you can access it
@tulip ledge sending it a normal string like "hi" has the same issue
I see now
I currently don't have my eval command running so this problem is taking me forever to even find the source
maybe its due to your module.exports is being defined after you are trying to clean it
got it, i was calling a function before calling the clean function and somehow nested both of em
img { border-radius: 50%; }
img being the thing you want to access
I don't know what it is
ok thankyou
But you can use inspect element to find it
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`)
client.user.setActivity("?help | In " + client.guilds.cache.size + " servers");
})
// Command Handler
(async function registerCommand(dir = 'commands') {
// Read the directory/file
let files = await fs.readdir(path.join(__dirname, dir));
console.log(files)
});
(async function registerCommand(dir = 'commands') {
^
TypeError: client.on(...) is not a function
Someone help me? I'm trying to make a command handler
(async function registerCommand(dir = 'commands') 
The first ( has to go
First of all
(async function registerCommand(dir = 'commands') {
// Read the directory/file
let files = await fs.readdir(path.join(__dirname, dir));
console.log(files)
});
should be like
async function registerCommand(dir = 'commands') {
// Read the directory/file
let files = await fs.readdir(path.join(__dirname, dir));
console.log(files)
};
the ) after 'commands' has to go to.
why are you wrapping them in ()?
RELEVANT LINKS:
NodeJS: http://nodejs.org/
Visual Studio Code: https://code.visualstudio.com/
Discord.JS: https://discord.js.org/
MY RESOURCES:
Learn JavaScript: https://www.youtube.com/watch?v=G_miVJbLraA&list=PL_cUvD4qzbkzrpH8det0pvoT_Oxu1JV34
Programming Discord...
@fresh hatch no
And () are wrappers for parameters
ah my bad, i thought for a second it was a callback.
but now it doesn't log the files
youtube videos are:
shit
prob outdated
not the way you code
use this @fresh hatch https://discordjs.guide/command-handling/
Well your tutorial maker clearly doesn't know how to code
ok @opal plank
you have to execute that function, my dear.
Documentations are WAY BETTER then tutorials
Documentation and tutorials can both be helpful.
Sry but i have another questions it is possible to change this arrow up icon or to change the color
Tutorials are often outdated. Up to date documentation are the bet.
Tutorials are showing how the tutorial maker does it, documentions shows how to use stuff allowing you to adapt it to your own style of coding wich is way better
^^
tutorial / stackoverflow = copy + paste
docs = actually learning
If I were to read the documentation and did not understand it (such as a language or all of the docs), I could do a bit more searching and see if an article or someone else is able to explain the last juice I need to understand it.
from the documentetion
don't put const
Oh I see syntax error
is there any way of using reactions across shards?
Since client is an already defined object you can't make a new object client.commands
fuck my life, i gotta rewrite 4 bots now -.-
for what
for my bot extensions
that ive done what the documentation says and there's a syntax error
no you havent
you did const client.commands
And it clearly sais client.commands
client.commands, without const, as we said
don't put const
client.commands ....
not const
Since you did it wrong
Where is your commands file?
If you want to read the files inside folders inside your command folder you're gonna need a more advanced command handler
commando should work for that if thats your go-to
so, whats the error?
You have been given a few fixes.
Should do them rather than just pasting your code repeatedly
should i add cache
createRole? that's old
You where told why @fresh hatch
thats v11?
@opal plank bro fix mine pls its v12
we don't spoonfeed mate
@pale vessel i did and i didnt understand a shit
read docs
no
Is reading docs really that hard?
can you not ping everyone lol
docs can help you
I dont know what the new method is actually.
I could find out same as you, by looking at the docs
doc lists all properties and available methods, it's worth the read
it's manager#create
@solemn latch Docs will always work if you read everything
@pale vessel done
:O
thanks to boeing
i dmed u
i'm losing brain cells
🤔
looking for some help w/ sorting by date, why won't this put the "newest" one at the top?
ie. it's not sorting right
isn't this a week old of an issue
its a furry
does anyone know how to make a video embed ? on discord.py
Post the link to the video. It gets made into an embed
As long as you have the perm
I'm not sure if you can build one.
I think discord prefers it if they build it
instead of embed.set_image(url= what do i use?
He wants it to be a video embed
Yeah thought so
hmmm i wish tho
ðŸ˜
hmm then maybe is there a way to stop getting vids from reddit e.g filter them out
u use python ?
yeh
i think the reddit api returns if the post is a video
you have completely broken me
Can somebody help me why doesn't the command run? I followed https://discordjs.guide/command-handling
uhm, how do I use Set().has() to get this?
My current code is this
var commands = new Set();
const commandFiles = fs.readdirSync(`./commands`).filter(file => file.endsWith('.js'));
for (let file of commandFiles) {
let command = require(`./commands/${file}`);
commands.add({cmd: command, name: command.name});
}
console.log(commands)
console.log(commands.has({ name: `hello` }))
The reason the command handler is like that, is because what I am working on doesn't have the ability to use collections, so a Set was the only other option I knew that wouldn't be too advanced.
commands.set
You should use Map not Set
@fresh hatch did you do the fixes you where told before?
@fresh hatch does it throw any error?
if no its not executing lol
Set is basically an array, but all the entries are unique, while Map stores key-value pairs
lmao
rip
is_video is a API value. it returns a Boolean @weary ridge
with this you can filter out videos
i get an error if i remove ./ from ./commands
x.data.children[0].data.is_video xpath if you need it
You already did remove it
throw err;
^
Error: Cannot find module 'commands/ban.js'
Where you get the command files
bruh moment
k thx @lusty quest
all the commands in bot.js
why do you have every cmd in a file lol i have mine all in one file anyways gtg
xd
__dirname may not be the same as process.cwd()
Its easier to keep track with a command handler like that
imagining having to scroll 10 years to get to that one command that doesn't work lmao
i hate js coz u gotta add(){} every time bloody annoying and confusing lol
Reloading individual commands is easier to
lol
. means cwd in fs readdir but . means __dirname in require
{} is easier to keep track of
is setting require ok?
cmd.run(require("./commands/lol.js"))
i never did tho
and many peoples do just wondering

many peoples: exactly
oh welp i find it easier without {} so i use python way better atleast ever since i switched to it errors were easier to handle lol
Python has better error checking anyway
@boreal rampart
how can i find a channel category by id? 
i wanna go back to js coz you get more of a flexibility to do stuff, just wish you didn't need {} also i just started learning html and that is the most easiest thing i have ever done.
you can code js if you can speak english
tryna make a jebait command but this doesn't seem to work, but no errors or anything it just stops runningpy elif cmd[0] == 'jebait': user=message.author voice_channel=user.voice.channel if voice_channel != None: vc = await voice_channel.connect() vc.play(discord.FFmpegPCMAudio("jebaited.mp3"), after=lambda: vc.disconnect()) await say('Jebaited!')
you literally just write what you want and add some ) and }'s
lol tru
@fresh hatch
?
it shuts down at vc.play
can you give me your code in dms?
ooooooooooooooooooooooof
bruh moment

my codes complex
just the command handler
the complex the better tho lol
that is also the alaises part
whenever i see someone using the discord.js guide command handeler he has an error
Its because they copy paste and don't check what things do
messagechannel 
Yeah some breaking changes
it possibly could be message.channel
bruh and python be like ctx.send
ReferenceError: MessageChannel is not defined
lol
How to define includes
im retarded lol
;/
array has property includes
ReferenceError: MessageChannel is not defined
@weary ridge v11?
message.channel lol
who has bot in over 100 servers?
Mines in 12, of my own servers
I do, but why does it matter
Me
have u filled authorisation form
yes
Mines in 12, of my own servers
@solemn latch i can relate
k need ur help
on what
the website is a little bit buggy sometimes
My bot is in 2 server xd
bruh never mind
das a reasonable amount of servers if your bot isnt that big
thats completely fine wym
and my bot isn't even published
i reached 100 guilds while only 1 of them is my own server
it's waiting for approval
cool
cool
Mines in one public server thats not mine
Actually 3 now
Got a few of my testers putting it in their servers
the first puplic server my bot was in got 10k users
Oof
@pale elk
yes but most of them added them for 1 reason
it can spam memes into a chat
(there is a 3s delay between the messages)

https://discordapp.com/channels/264445053596991498/265156286406983680/729001180566519888
how would I access the songs array?
forEach should work right?
yeah
But it doesnt in my eval cmd :/
there's probably a faster method
@plucky harness what specifically do you need help with
(node:11404) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
i've filled in 2-3 now
wtf is this
Means your bot couldn't do somethong
because it didn't have perms to
Like it says
what intents should i fill @sick cloud
@solemn latch IT HAS ADMIN PERM
The intents you need
i forgot to return lmao
no bot should have admin perms @cobalt spruce
@solemn latch uhh
There is 0 reason to ever give a bot admin
soo i dont give any perm
Give it the perms it needs
i tryied to do all the perms
No more
@plucky harness what does your bot do
@sick cloud and u?
you'd need neither intent then
@plucky harness OMG GIVE LINk
@cobalt spruce?
what does ur bot do
give 8 lol
youtube stats
8 is enough lol
etc
roblox jojo time
wrong channel use #memes-and-media
@sick cloud is not shit
Yikes the sudden toxicity
how would you recommend guild based leveling database structure?
a single table with members then xp per guild in rows
yeah, create a new table for each guild.

You can put them all in one table
And have user ID and guild ID both be primary keys
And index both guild id and user id
If you do all of those. When you query the database, it only checks rows with the same guild ID, effectively making it like they are their own tables
Yeah I just didn't know what's more efficient tbh
A massive single table or lots of small ones
Databases are good at lots of rows
When databases are tested, they are tested in millions of rows typically
Ok cool thank you
If you index properly, im pretty sure your best bet is just one giant table

did you want to implement global levels?
if yes making one DB for everything could be easyer
(have one field for local level and one for global level. Local level only runs per guild while global adds each guild ontop)
Or I could just have the guild Id for global be 0
omg it is so hard to literally play a hardcoded song into a voice channel
hardcoded?
i have a .mp3 file
hmm
theres just so many layers of weird shit to do
Can someone help me setup my webhook for DBL?
where is your issue?
it won't do anything
bot.on('guildMemberAdd', guildMember => {
const role = guild.roles.cache.find(role => role.name === 'test');
const member = message.mentions.members.first();
member.roles.add(role);
});
```why is this not working?
Do you get an error
brruh
Because... it's not defined.
you are passing guildMember, not guild
member.guild
guild is when you have ecnts such as guildCreate or guildDelete
If you do want the guild the member came from, you can access the .guild property on a GuildMember instance.
makes sense
what is rong?? i think it all right
arrow functions are weird
You get used to them
me?
Dude, why do you even ask "me?"
discord.py: I have an on_command_error to listen for errors and send them to the respective channel. Is there a way that I can make a function that isn't a command, that also passes its errors through on_command_error?
Why did one ask another question right now, so I asked "me?"
Well, my message makes no sense in your error's context
Btw, the issue ain't in the code you've shown
@lyric mountain help man
roles.remove lol
if (message.content.startsWith(`${prefix}unmute`)){
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply('Sorry, you do not have permission!');
var mutedrole = message.guild.roles.cache.find("name", "Muted");
var unmutedmember = message.mentions.members.first();
if (!unmutedmember) return message.reply("Please mention a valid member of this server!")
unmutedmember.removeRole(mutedrole)
.catch(error => message.reply(`Sorry ${message.author} I couldn't mute because of : ${error}`));
message.reply(`${unmutedmember.user} has been unmuted by ${message.author}!`);
}
roles.remove lol
@restive pebble
PS C:\Users\Abdo_Mido\Desktop\islam2> node .
Logged in as Ahx#4022!
(node:15108) UnhandledPromiseRejectionWarning: TypeError: fn.bind is not a function
at Map.find (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\@discordjs\collection\dist\index.js:158:21)
at Client.<anonymous> (C:\Users\Abdo_Mido\Desktop\islam2\Bot.js:397:54)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\Abdo_Mido\Desktop\islam2\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
(node:15108) 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:15108) [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.```
uh sorry
const GuildModel = require("./models/guild.js")
let dPrefix = GuildModel.findOne({ id: message.guild.id });
const prefissocustom = GuildModel.findOne({
id: message.guild.id,
prefix: String
})
let prefixes = [`p?` , `P?`, `@obsidian crane `, prefissocustom
]
let prefix = false;
for (const thisPrefix of prefixes) {
if (message.content.startsWith(thisPrefix)) prefix = thisPrefix
}
if (!message.content.startsWith(prefix)) return;
let messageArray = message.content.split(" ")`;```
ERROR:
(node:5980) UnhandledPromiseRejectionWarning: TypeError: GuildModel.findOne is not a function
(node:5980) 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 handl
ed with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhand
led-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id:
1)
(node:5980) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, prom
ise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Can someone help me?
here's the right one
.find has some errors
3 min= 180000ms ?
.find(anything=>anything.name===rolename) @cobalt spruce
how to write 3 mins in disord.js
nice
lol
const GuildModel = require("./models/guild.js")
let dPrefix = GuildModel.findOne({ id: message.guild.id });
const prefissocustom = GuildModel.findOne({
id: message.guild.id,
prefix: String
})
let prefixes = [`p?` , `P?`, `@obsidian crane `, prefissocustom
]
let prefix = false;
for (const thisPrefix of prefixes) {
if (message.content.startsWith(thisPrefix)) prefix = thisPrefix
}
if (!message.content.startsWith(prefix)) return;
let messageArray = message.content.split(" ")`;```
ERROR:
(node:5980) UnhandledPromiseRejectionWarning: TypeError: GuildModel.findOne is not a function
(node:5980) 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 handl
ed with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhand
led-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id:
1)
(node:5980) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, prom
ise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Can someone help me?
Btw I use MongoDB as a database
idk why he is coding in 50% v12 and other v11
what
this:
const mongoose = require("mongoose")
exports.run = async(message) => {
let prefixes = [`p?` , `P?`, `@obsidian crane `]
let prefix = false;
for (const thisPrefix of prefixes) {
if (message.content.startsWith(thisPrefix)) prefix = thisPrefix
}
const Guild = mongoose.Schema({
id: String,
prefix: {
default: prefix,
type: String
}
})
module.exports = mongoose.model("Guild", Guild)
}```
?
how r u exporting the the file?
exports.run = async(message) => {
let prefixes = [p? , P?, @obsidian crane ]
let prefix = false;
for (const thisPrefix of prefixes) {
if (message.content.startsWith(thisPrefix)) prefix = thisPrefix
}
I don't think I need so
u have exports.run wheres that
.run
Is there a way to like see wich guild is the biggest one where your bot is in?
uh kk
array.sort
why do u need that?
- its just overcomplicating everything if u were to add it
- its a model, nothing else.
- everything is just gonna be undefined (because u have the module.exports in the brackets)
k
remove everything else
kk
how to get bot uptime in v12?
process has an option
Hello! I have an issue with my production version. In my machine the bot works just nice.
Production env: OVH VPS, ubuntu 18.x. Using sharding manager.
Bot is running just fine, managed by PM2 with the pm2 start index.js --watch --name bot command. I pull my lastest changes from github, pm2 detects changes in a file so it restarts the bot. Now I have 2 instances running! Why is that? (just happens sometimes)
LMAO
Also, I sometimes get this error too (only in production env), maybe it is related?
at process.target.send (internal/child_process.js:679:16)
at Client.<anonymous> (/home/ubuntu/ZSurviveBot/node_modules/discord.js/src/sharding/ShardClientUtil.js:37:17)```
hacker boi is comin for you
require("moment-duration-format");
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");```
Using this but showing 0 secs
everytime
Are you sure the format is correct? Try letting your bot run for a minute and retry
Ok
If something could take a look to my problem I'd really appreciate it!
@tight plinth bot is active more than 2-3 mins
Apparently your formatting don't work
client.uptime?
No
i didnt realize client.uptime exists
Nope
I dunno how to use moment
me
ask me
require("moment-duration-format");
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");```
Showing 0 secs
for 5 mins

i just made a function that does it
wot
they are pretty simple
imagine using a function for uptime
big phen sar
lol
¯\_(ツ)_/¯

Imagine importing a package for it
I used to use a function for that. But then switche to libs
^

When you can do it locally
packages aren't remote. once they are installed, they're local too 👀
Just make a util class with some methods
I just use the dateformat package
||pros has entred the chat||
i mean, its really simple stuff.
https://stackoverflow.com/questions/8211744/convert-time-interval-given-in-seconds-into-more-human-readable-form
someone does mention using moment down below.
but maybe its because I really liked working with time when i started programming
how do i code the bot to change the servers name, pfp, etc..
is that actually a useful feature to server owners?
Changing the name and pfp takes an owner only a few seconds anyway
im just trying to mess around with bots tbh
its one click to get to those menus
^ Big agree with woo, but if you really do want to make it, what library are you using.
discord py
You're probably looking for the .edit() method (is it called a method in Python?) https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.edit
yes
i think
ty lite
waiit
how does the function work
await edit(*, reason=None, **fields).name?
Hey,
I have a question:
How do i get ALL messages from a specific channel and make a Txt file that contains the whole chat. And send the txt then.
Discord.js v^11.5.1
spam the get messages endpoint until you reach the beginning of the channel
api aboose
also, discordjs v11 only will work for a few more months
till october
i have a idea. is it possible to log all messages in the txt and if the channel closes then send the txt and delete it from the bot thingy
well saving them in a text file unencrypted is against ToS and will get you banned if they ever find out
it is
still sounds like api abuse
@solemn latch i mean if it getas a msg from the channel
i have a idea. is it possible to log all messages in the txt and if the channel closes then send the txt and delete it from the bot thingy
@sterile minnow
it doesn't matter how you send it, the problem is getting the messages in the first place
you seem to be ignoring the fact you'll probably be banned if you do that
and breach of privacy
@solemn latch i will do it like ticket tool
send it in a log channel
are you making tickets
yes
so just store messages you get from the event lol??
getting all messages in a channel can take minutes or even hours to complete, if you count on the fact you won't get api banned (which you probably will be)
Oki. ty
so your best bet is to use the event
how do i use edit()
read the docs
i think the docs page you where linked had an example
how yto delete folder + content with rmdir? i forgot how to do that
i dont know python.
but however you use a method, is how you need to use edit
Just in discord.js/src/client/util/Constants.js
/**
* HTTP options
* @typedef {Object} HTTPOptions
* @property {number} [version=7] API version to use
* @property {string} [api='https://discord.com/api'] Base url of the API
* @property {string} [cdn='https://cdn.discord.com'] Base url of the CDN
* @property {string} [invite='https://discord.gg'] Base url of invites
*/
http: {
version: 7,
host: 'https://discord.com',
cdn: 'https://cdn.discord.com',
},
};```
In Line 71 thingy lol
the domain isnt whats the problem
you also need to make v11 work with intents @sterile minnow
it's the switch to intents and stateless design
then i will upgrade when i need lol
it takes like half an hour to learn the changes
I know
its just that i did the code decades ago
have to learn it again
every other bot from me is in 12
which is why doing it sooner is better
and with intents now being a thing, you might not remember each one you need to make your bot function
the longer you wait, generally speaking, the more changes and things you might not know you need to change come up.
sooner than later is better if possible in this case.
🤔
🤔
googling about methods in python.
looks like they are pretty simple
if the guild you want to change is called guild
guild.edit()
class Pet(object):
def my_method(self):
print("I am a Cat")
cat = Pet()
cat.my_method()
yes
Keep getting this error with this code?
post the full error pls
@finite bough That is full error.
lol
client is not defined
Ahh, wait.
guild's value depend on what event u are listening to
uh
using common sense its most probably message event
@client.event
so message.guild
guild.edit(name: parm)
@solemn latch in Python, kwargs are name=value
name: object = value is type annotation that name is supposed to be an instance of object
and thats just cool thats the value is 90
You mean default values?
Mmm, no clue why it's not detecting it
Here
@earnest phoenix did u define the client in ur main file?
Yeah, works completely fine until added the new ready.js code
client should be defined very early on in your program
who cna help me
try exporting client from index.js to ready.js
mhm
define things before using them @blazing ravine
can u help me :?
he helped you
i dont know how xd
define things before using them @blazing ravine
try exporting client from index.js to ready.js
@finite bough how
im tryed to make after give undefined error return and send another messaage but didnt work
my bot same thing in a way
let var= /* object */ 1;
console.log(var);```
this is working, but if you do like this
```js
console.log(var);
let var = 1;```
error comes out





