#development
1 messages ยท Page 896 of 1
I'm ready to put my head through the wall trying to figure this out
And I have my friend screaming "just learn js, just learn js"
@earnest phoenix errr dude, you DO know that you can't program a bot with only JSON, right?
You'll not even be able to send a POST request in first place
I'd say learn js, but there's also java which could be easier depending on your style
I got this
This is for my commands
This is just the commands and what their output is
The bot part is already done
@lyric mountain
Sure but, json is not a programming language, you can't actually run it
Json is a data structure
It works just fine tbh
Happy cake day
ty
This is just the commands and what their output is
The bot part is already done
But HOW have you tested it?
it's discord bot maker lol
What
Omg
The hell is Discord bot maker
Discord Bot Maker uses JSON type modules lol
I only forked the bot
Pumpkin what program/app are you using to run/make your bot.
I had a client of mine ask me for help, sent me a DBM Bot and it looked exactly like that lol
TIL that dbm became even stinkier
There's alternatives of Discord Bot Maker, could be one of those ๐คทโโ๏ธ
@sudden geyser he just forked afaik
Idk what's being used to run it, why don't you ask adorable jade? She's the one hosting it
Jade? Like, THAT jade?
could someone help me https://pastebin.com/BNwPnwtd thats my code and that command only works on some servers not all
Unfortunately very few of us will be able to help u, dbm is a no man's land for most of us
@queen needle does it have to do with it not working on servers that don't have an icon?
@earnest phoenix maybe ill check
That happens to my bot, but only the commands command doesn't work on servers without an icon
Ok, my bad
ill check for errors give me a minute
@queen needle is there any pattern for servers that don't work?
Like, something in common between them
also what version of discord.js are you using
11.5.3
okay makes sense
no it doesnt work on a server with 4 people and 2 channels and also on one with 20 peoples and 6 channels
and how?
Any error in the output?
im checking rn
and how?
@queen needle because discord will change most of its structure in the upcoming updates, and v11 is obsolete by now
Also v12 is by far more optimized
so my bot will die soon
You could try to implement v12
Is it a of work? Probably, but it's a one time thing
Until v13
all my commands that use the old embed system
All you do for that is change RichEmbed to MessageEmbed tho
stinky embed
Does anyone here know about using Discord.Net
D.js basically threw it off the balcony
time to redo my pi with Nodejs
https://ghostbin.co/paste/64yjb TypeError: message.guild.members.filter is not a function
Thanks for the answer though, clears up a lot
It's not a function probably
yeah but how would i make it one
filter = function(){}
If you're into C# you could take a look at java's JDA
Since java is almost like C#
a lot of collections are now managers
It's described in this part of the changes in 12 update: https://discordjs.guide/additional-info/changes-in-v12.html#managers-cache
But there are some people out there that use discord.net
Java is like c#, but java
C# is like Java, but windows
Funny thing is that C# was meant to be called Java++
But Microsoft couldn't buy it
But .net core
hi
Somehow I just cant work with c++
let a = client.getRESTUser(userID);
let av = a.avatarURL;
``` all i ahve is the userID, why can't i get the users avatar url with that?
its having trouble reading hexColor
using eris
Yeah, after msoft failed to get Java++ they went tantrum and made a raw vm compiler
ok, thank u
https://ghostbin.co/paste/3tgvj cannot read property of hexColor
if you can't read the property it means it's undefined/null. did you try debugging it?
roles.size may be your issue.
You want to check if you find the variable first before you use the it
.find().variable is a guaranteed error if find is not found
when we use await user.remove_roles(<role name>) how can we specify a role to remove?
hi, js let a = client.getRESTUser('475371795185139712').then((e) => e.avatar).then((e) => e).then((e) => console.log(e)).then((e) => console.log(e)) let av = `https://cdn.discordapp.com/avatars/475371795185139712/${a}.jpg`; why is it logging the users avatar but in the actual thing it says [object promise] ? i'm using eris
i'm trying to get the users avatar url btw
Ah
but it responds with object promise
What is that url in the end?
wdym?
You gotta return the image url from inside the last then block
You're just console.logging it
Sure but, the avatar url returned is an entire url
Not just the part before .jpg
So av should be av = e
but how can i access e then?
Just manipulate it from inside the block
Idk if you can extract it to outside of the promise
u can't, pretty sure
@lyric mountain do u mean something like this? ```js
https/ /cdn.discordapp.com/avatars/${userID}/${client.getRESTUser(userID).then((e) => e.avatar)}.jpg
Errr no
e is a complete url
If you want to send it in a channel just do a channel.sendMessage(e)
oh?
Where I can find the webhook password?
but e isn't accessible outsde of that .then thign
is there noone here that even uses a debugger?
for real, it helps you alot when checking for variables
ah nah, the question under
or maby both
@digital ibex send it from inside the promise
so
ok, i'll try thta
@lyric mountain ```js
author: {
name: | ${message.channel.guild.name},
icon_url: https://cdn.discordapp.com/avatars/${userID}/${client .getRESTUser(userID) .then((e) => e.avatar) .then((e) => e)}
},
${client.getRESTUser(userID).then((e) => e.avatar).then((e) => e)}
You still need to resolve the promise. Chaining it won't actually get the value.
If you're doing it inline you need await
with async of course.
it has been resolved tho, it logs the avatar
confused. In the code block you sent above?
same code but not exactly there
oh, wait nvm. i'm so dumb ๐
figured it out btw
if (!message.member.hasPermission("MANAGE_GUILD") || message.author.id != "606279329844035594")
return message.reply(
"you don't have required permision to use this command"
);```
how can i make it so that unless they have manage guild permissioin or they have that id
so if you have manage guild permision or thats their id they can use the command
make it && instead of ||
so that if one of the condition is true, it won't exit the command
oh yeah thank you
TypeError: message.guild.channels.first is not a function
Do I need to add "cache" in that?
or replace cache with guild...
I feel like im missing something there..
hi
can anyone help me make a welcome and leave command for discord.js
I tried ```js
client.on('guildMemberAdd', member => {
client.on('message', (
receivedMessage) => {
let logChannel = receivedMessage.mentions.channels.first()
logChannel.send("Hey "+member.user+", welcome to T E A M G A M E R Z :tada::hugging: ! Be sure to subscribe to me! https://www.youtube.com/channel/UCJBQemgOjflI4ie7XCGs-cA?view_as=subscriber")
})
})```
what im new
Trying to make a join command
cause receicedMessage.channel.send wont work
๐คฆโโ๏ธ
lol
you can just expect stuff to work without even knowing how it works
thebeast that'll cause a memory leak.
I ain't taking this case
ug ok ๐ฆ Ive been through 2 servers and no one helped
It's not an issue. It just means you don't have the default port glitch has used.
aka 3000.
like if you had an express server.
That usually means, you made an edit, and its saving the changes...
Its not an issue though
It there was an issue with your code, it would show this:
its just like these warns when you install discord.js
just ignore it
it has no impact on your code whatsoever
Yeah
Roman that doesn't have to do with edits I believe.
Unless you don't have a watch file and you're instead having your app restart every time you type (horrible btw)
Hey, when I type both avatar commands for my bot, the avatar picture doesn't show up.
12.2.0
Here's the code
module.exports.run = async (bot, message, arg) => {
var fs = require("fs");
fs.readFile("./e/cmds.json", "utf8", function(err, contents) {
var c = JSON.parse(contents);
if (c.other === "0") {
message.channel.send();
} else {
cc();
}
});
function cc() {
// let request = await msg.channel.send("``Generating...``");
let taggedUser = message.mentions.users.first() || message.author;
let embed = new Discord.MessageEmbed()
.setColor("BLUE")
.setImage(taggedUser.displayAvatarURL)
.setTitle(`${taggedUser.tag}'s Avatar!`);
message.channel.send(embed);
}
};
const user = message.mentions.users.first() || message.author;
message.channel.send(
new Discord.RichEmbed()
.setColor(0x333333)
.setAuthor(`${user.username}'s avatar`)
.setImage(user.avatarURL)```
thats my avatar code
I thought the RichEmbed changed to MessageEmbed??
im using a older verison
oh
but try my code
@clear wraith displayAvatarURL is a method, not a property..
Can I use command handler codes and normal codes in the same bot?
@surreal notch 1% of discord bots are command handling
@surreal notch you can use different projects but not in the same one
a people can help me look that
The bot don't listening me why ?
v12
@earnest phoenix does it.. do nothing?
yes nothing on my logs
replace speaking with speaking.has(1 << 0)
where
the if statement
ok
you should be logging the error event
along with failed
also did you install @discord.js/opus?
@surreal notch well we can't do anything just by seeing error
yes
Then?
Idk the error
userinfo.js | :x: -> missing a help.name, or help.name is not a string.
This is error
- github forkers
- it litterally tells you what is missing read the error
But i can't understand@marble juniper
in module.exports
do you have a name property
which is named after the command file
exports.conf = {
enabled: true,
guildOnly: false,
aliases: ["smolyeet"],
permLevel: 0
};
exports.help = {
name: 'warn',
description: 'Issues a warning to the mentioned user.',
usage: 'warn [mention] [reason]'
};```
Ok lemme try
do you have that in your userinfo.js
and no I didn't mean that
I meant it like
do you also have a exports.help in userinfo
with the name being userinfo
ah forget it im outta here
How do you make an embed in a async function? I tried and it errors so I'm wondering if it's the way I made the embed, I know there's different ways to make embeds.
Let me see if I have a picture...
Though I was doing this really late yesterday so I can't tell if I'm being stupid or whatnot. ๐
${message.guild.owner.user}
is that still the same in djs v12
try it and see
let embed = new Discord.MessageEmbed()
.setTitle("KICK NOTI")
.addField("KICKED In", message.guild.name)
.setColor("#bc0000")
.addField("Moderator", message.author.tag)
.addField("Reason", `${bReason ? bReason : "None."}`)
.setImage(message.guild.iconURL({ format: "png", dynamic: true, size: 2048 }))
//.setDescription(`[PNG](${message.guild.iconURL({ format: "png", dynamic: true, size: 2048 })}) **|** [JPG](${message.guild.iconURL({ format: "jpg", dynamic: true, size: 2048 })}) **|** [JPEG](${message.guild.iconURL({ format: "jpeg", dynamic: true, size: 2048 })}) **|** [WEBP](${message.guild.iconURL({ format: "webp", dynamic: true, size: 2048 })})`)
.addField("Your feeling",`Oh, did you just get kicked? Are you very spicy? You want to take revenge on the people who banned you? so add corona-chan bot to your server so you can revenge those who banned you if they are on your server`)
.addField("Add me to help you",`[Invite Bot](https://bit.ly/39bnfzy)|[Support Server](https://discord.gg/BNTAapF)|[Donate/Buy Premium](https://www.patreon.com/coronachan)|[Add this bot if you want to be a youtuber :/](https://top.gg/bot/681376963356524558)`)
try{bUser.send(embed)}catch(error){message.channel.send("Unable to send message to user.")}
message.channel.send(":ok: **That member has been kicked do not worry.**")
let incidentchannel = message.guild.channels.cache.find(c => c.name === "corona-chan-log")
if (!incidentchannel){
message.channel.send(banEmbed1)
} else if (incidentchannel){
incidentchannel.send(banEmbed)
}
bUser.kick(bReason)
how can bot PM people before kick them out
move the part where you message them above the part where you kick them
oh
uh
@pale vessel it is but the bot cant get this servers owner because its like 30k members
yes. you need to use members#fetch
so something like owner = await guild.members.fetch(owner id)
is it a good idea to add an invite link to your bot when you are getting kicked by that bot though 
is it a good idea to add an invite link to your bot when you are getting kicked by that bot though
@turbid bough hehe
more promotion i guess
maybe message the user then add a 2 second rest then kick them
idk
ive done it before but i forgot how
hmm
@pale vessel (node:4) UnhandledPromiseRejectionWarning: ReferenceError: guild is not defined
yet it works when i use guild in every other thing
I have a function that I want to run when all my shards occur. How can I do that? I looked at the sources but it is not clear enough. And the examples are inadequate. (discordjs)
how do i show avatar with username
Why does my bot say N/A for servers and is this something i can fix?
@earnest phoenix :/
You need to post your server count yourself
Oh ok. I didnt see that, ill taker a close look
client.user.setStatus("idle");
});```
You can refer to official libraries on https://top.gg/api/docs or post the server count yourself through HTTP requests
@surreal notch discord.js v?
@pale light do u knw what to do
client.user.setStatus('idle')
.then(console.log)
.catch(console.error);
```would you try @surreal notch
not working
error
nope not working
could you tell me how to add no. members and server my bot is watching in status??
@quartz hill @pale light
which
@surreal notch ```js
client.user.setActivity(client.users.size + ' members', { type: "STREAMING", url: 'https://twitch.tv/' + client.user.username})
@surreal notch sory would you try "WATCHING"
ok
@pale light
@pale light sorry but pls dm me the sol. i have to go somewhere
You want client.users.cache.size if you are on v12
@cinder patio and for no. of servers what to do?
client.guilds.cache.size
ok
true yes
which library..?
discord.js v11.5.1
**- Server Owner:** ${await message.guild.ownerID}
is there a way to make that turn into a mention
**- Server Owner:** ${await message.guild.owner}
there's no point of awaiting there adam
and guild.owner could be undefined if the member isn't cached
yeah but that doesnt work because it cant find the owner
it can only find their id because of the member count
you should fetch the member then
or user
await client.users.fetch(message.guild.ownerID)
it doesnt do it like @earnest phoenix it does it like @earnest phoenix
@cerulean pebble No point setting stuff like the colour a ton of times it just clutters up your code.
You could create the embed that would be sent at the top with the colour then you could just add the required stuff to it before you send it
hello i need join dm message for my server please help me
You recreate the embed for every possible choice you could just do js let Embed = new Discord.MessageEmbed() .setColor("34565") then add to it with Embed.addField etc. it would mean you only have to create the embed once and you wouldn't have to define the same colour multiple times
:/ i need bot send DM
@earnest phoenix If it's not displaying the username in your client, then it's probably because your client doesn't have the member cached
before kick a uder lol
To the author or mentioned person
idk how to cache it
Not an issue
To the author or mentioned person
@short siren :/ you do not understand what i want
message.author.send("Hi") will send to author I believe :/
author returns a user object I think https://discord.js.org/#/docs/main/stable/class/User and from that their is a send function.
@hasty sparrow it works on my server because theres not many members but it cant find it through like 90k members here
Like I said, it's not an issue
I have a function that I want to run when all my shards occur. How can I do that? I looked at the sources but it is not clear enough. And the examples are inadequate. (discordjs)
There might be a better way but on shardReady you could see if there are any unavaliable guilds if there is then all shards aren't ready http://prntscr.com/s7aqm1
Or ShardClientUtil#count see if the expected number of shards exist
if you're using the sharding manager
you can listen to shard ready events on each shard, and increase a counter
and if counter is equal to total number of shards, run the function
๐ฎ
that would run it in the shard manager, idk if thats what you want
How do I learn the number of shard that should be total.
I'm pretty inexperienced with Shard.
Most libraries will/can set the amount of required shards for you automatically
me?
No
ok
Yes it automatically adjusts. So I don't know exactly how many numbers there are. Is there a way to learn this?
@earnest phoenix d.js v11 or v12?
v11
yes but
.leave() doesn't return a Promise
You can, just send the message after leaving the channel
ok
d.js v12.2 bugged or something?
Could you be more precise?
weird bug inside the node-modules file
/rbd/pnpm-volume/2cf580ce-3aab-403a-a265-599d1b986c83/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/Client.js:41
} catch {
^
SyntaxError: Unexpected token {
Node version?
@quartz hill manager.totalShards
thx
and what i have this ?
Read the first line of the error message
how can i change this
discord.js v11.5.1 how do i use .setOwner() ?
Don't use the property like it is a function
Can you tell me how I can do it
Read the documentation
I came here for understanding sharing, I even did some research
which version of discordjs are you using?
I?
v11
is that an unban command?
yes @quartz kindle
yes
then it will never work
hmm
you're trying to get the target from message.guild
but if the target is banned, it doesnt exist in message.guild
if you want to unban someone, you have to use their ID directly
but you use their ID to get them from guild.members
but they dont exist in guild.members
ok
you can do this
// check if ID is valid
let user = await client.users.fetch(args[0]).catch(() => false)
if(!user) return message.channel.send("invalid user")
// unban user
await message.guild.unban(user)
me wondering why my function wont work https://img.thaun.dev/oo1g1.png
imagine being that dumb
"it must be something on the discord side" i thought
look @quartz kindle
@earnest phoenix sorry, bot.fetchUser() in v11
if(!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send('Yuo do not have permission')
let bannedMember = await bot.fetchUser(args[0])
if(!bannedMember) return message.channel.send("Please use id to unban")
let reason = args.slice(1).join(" ")
if(!reason) reason = "no reason"
if(!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send('Yuo do not have permission')
message.delete()
try {
message.guild.unban(bannedMember, {reason: reason})
message.channel.send(`${bannedMember.tag} has been unban`)
} catch(e) {
console.log(e.message)
}
}
now why all of my username AvatarURL etc is undefined ?
You mean username?
Because the user is undefined/doesn't exist
oh ok
You can't get properties of a guild member who isn't cached as he is banned
and i can't get hes id
How would you even fetch the user without the id?
@jovial nexus Try the voiceStateUpdate event
i have this ```js
client.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
if(oldUserChannel === undefined && newUserChannel !== undefined) {
console.log("hi")
} else if(newUserChannel === undefined){
console.log("bye")
}
})```but it only logs bye
d.js v11 or v12?
v12
What should js user.presence.game.name be in v12?
I was wondering if having a reaction collector active forever for each guild my bot is in, would require too much power from my bot. Is it possible?
maybe
Wtf last day my vote system dbl work and today does not work
@earnest phoenix displayAvatarURL
how to check if role is deletable?
my bot replies to other bots how to fix it
if(message.author.bot) return
@earnest phoenix should i paste it top of codes or before every cmd?
In top of before every code
no,
Hello i have question
Do i need to isntall dbl on heroku
like heroku run : "npm install dbl"
if(message.author.bot) return; // do nothing
// if not responding to a bot, do bot stuff
})```
just like it?
into index.js paste this :
if(message.author.bot) return;
})```
yes ๐
Ok
like heroku run : "npm install dbl"
@earnest phoenix you can't really install "dbl", but you can installdblapi.js, which is the library for posting to the site.
@earnest phoenix npm install dblapi.js
Ye but do i need to install it ??
on heroku
what do you need it for
if u want use it, yes
i want to make that on the top.gg page show that my bot is onlint
How i can do it
check the docs :
thx
ahm one more question
i named the DIscord.Client() is bot
so do i need to change here const dbl = new DBL(botconfig.dbl_token, client);
const dbl = new DBL(botconfig.dbl_token, client);
change client to bot
client.user.setActivity(client.users.cache.size + ' members | u?help', { type: "WATCHING", url: 'https://twitch.tv/' + client.user.username})
const activities_list = [
"with the u?help command.",
"with the developers console",
"with some code",
"with JavaScript"
]; // creates an arraylist containing phrases you want your bot to switch through.
client.on('ready', () => {
setInterval(() => {
const index = Math.floor(Math.random() * (activities_list.length - 1) + 1); // generates a random number between 1 and the length of the activities array list (in this case 5).
client.user.setActivity(activities_list[index]); // sets bot's activities to one of the phrases in the arraylist.
}, 10000); // Runs this every 10 seconds.
});
});```
i am trying this but it is not working
its not changing in 10 sec
because they're not in the same scope
Means?
you shouldn't even have two separate ready events.
do you know what javascript scopes are?
nope
but how to solve that error
You could loop over it and edit the value at the index
@surreal notch you are creating a listener after ready has already been emitted, and it is only emitted once
tldr you dont need the second client.on("ready
hey, it's not really development but does anyone know how to use chmod ? (on a vps)
pls dm if
Depends what do you need it for
Are you trying to make a file executable
Or own it
message.guild.members.forEach is not a function help ?
@surreal notch most collections are now managers in v12. You need to look in the members cache.
oops wrong mention.
I meant @earnest phoenix
@surreal notch do not use multiple .on("message")
they do not affect each other and only waste cpu
I think I've spent 3 days refactoring mostly to put off the math of game balancing
I'm proud of my refresh button though
it pulls data from a iconURL to find the info it needs on mongodb
then builds embed with that data
๐๐ผ
I do it all for the thumbs
Anyone occasionally get a failed CMD prompt on testing their bot?
Like, the cmd prompt loads but bot never initializes
or it takes forever
@maiden mauve players.findOne. that looks like mongoose. u use mongodb? โค๏ธ
yeah all hail the mongod
After a 10 min video and some basic examples its braindead simple
I love it
the only thing that tripped me up was that I was still learning async vs sync coding
that's also when I fell in love with console logging objects
DURR WHY DOES MY VARIABLE NOT WORK? Oh, it's a unresolved promise
lmao
been there
yea i also love mongo db ๐
i recently wrote a custom module thing to umm, basically cache results for a short period of time
no idea if mongoose already does that
did it anyway
why not
cant hurt ๐
stat balancing in an rpg is truly an art that requires test subjects
You just can't see how things go until you see people grind away
but then they all run away when you tell them your deleting their stats
how to keep discord bot 24/7 online
host it on a web server
host it on a server online that offers near 24/7 uptime
which
i use digital ocean cause its super easyt o get going
but im moving to contabo cause its super cheap and offers tons
I found Heroku to be easy to learn, a lot of people diss it though
fine for a small bot imo
im gonna try them at least
heroku is ok until you need to add things then they want buckets of cash
but i need free one
gl
I'm like 80% of the monthly bandwidth just having a credit card on file
i think there is actually a free service
but its not gonna be good
forget the name, alot of folks use it for bots
honestly if its a small project try Heroku
if your using too much bandwidth youll figure out fast
nothing free will let you drain their resources
dude wants free tho ๐
I've had my bot on heroku for 6 months without paying
Hn
which should i use for free
you gotta find the pros and cons everyone thinks a little different
fundane general question or code?
general question
HE MAKES JOKE
I don't know if I can answer a question that hasn't been asked
but ill try
undefined
sorry
just a general question on how to work with [object Promise] with javascript
I'm gonna call my cable company and complain
@hybrid musk it's perfectly acceptable etiquette here to just ask your question
i did
not only acceptable, its the preferred one
i'm confused on how '[object promise]' works
well a promise is an object
i didn't ask to ask
okay
you have to wait for the promise to resolve in order for the variable to work
const thepromize = new Promise((resolve, reject) => {
if (/* athing */ true){
resolve('data');
} else {
reject('reason');
}
});
that is an example on how to make a promize
you call it like a reular function
The promise object itself is very confusing at first because there isn't any context
it will only return a value whenever the promise calls 'resolve' internally
else it will reject, throw error, and provide reason
Think of a promise as "I'm waiting for the internet and code to process"
okay
It's a high level function to make everything work well
are promises a low, medium or hard bit of javascript?
i'd say medium/hard
if your going to code discord, its beginner level
not newbie friendly
it's essential
well yea
for a discord bot its kinda a requirement, because you need to await a data being returned by promises
yeah the concept is well beyond basic coding
for general javascript, its not something you get on lesson 1
but you can wiggle your way around it
var a = 10 // a is 10, it is immediately available, you can use it whenever you want
var b = new Promise(r => r(10)) // b is a promise, it has the same value as a, but its not yet available
a + a // this will return 20, because a is available
b + b // this will not work because b is not available
var c = await b // this will put the code on hold until b becomes available and the give its value to c
c + c // this will return 20, because we waited for it to become available
b.then(c => {
c + c // this will work because we waited for b to become available and then gave its value to c
// however, this splits the code into two different flows, b is now available in here, but not outside here
// what happens in here happens in a completely difference space, completely separate from the flow of befoe
// this does not put the code outside on hold, the outer flow will continue executing at the same time. only this inner code is on hold
})
b + b // this will not work, because b is still not available here
// this is still the old linear flow where b was not yet available
heck
lol tim
you have to read about "async vs sync" and the structure of a promise
Tim's example there likely has some great info
no doubt, but also likely not newbie friendly ๐
holy crap tim that is beautiful
i guess its not exactly hard to understand once you look past the fact its a wall of text
XD
To be honest learning promises was the biggest obstacle to free-writing my bot
I wish someone had a brain dead power point to walk me through it
i mean code shouldnt be given without an explaination. Even if its a lot to read, if it helps you understant the process of the code then its good and high quality
Where can I add setStatus in the code?
execute: async (client) => {client.user.setActivity(`Current Shards: ${client.shard.count} Shard(s)` , {type:'WATCHING'});
setInterval(() => {client.user.setActivity(`Current Shards: ${client.shard.count} Shard(s)` , {type: 'WATCHING'});
}, 20000) // every 20000 milliseconds
console.log(`Ready on client ${client.user.tag} and loaded ${client.commands.size} commands with ${client.guilds.size} servers & ${client.users.size} users.`)
}
}```
@hybrid musk it will help you a lot to console.log(variableName) starting out
your cmd prompt will tell you what the object is
its kind of confusing ๐
if it says it's a promise instead of a value
that's because you haven't awaited the promise to get the value
Tim's example is a great way to play around with variables
oh
function wait(ms) {
return new Promise(r => setTimeout(r, ms));
}
thats a simple function, that returns a promise
i use it to 'wait' a number of ms
might be useful in understanding how a promise works
ok
With all this basic explanation, understand that something like "message.channel.send" is a promise. You can't get the message variable until it resolves
simply do
await wait(1000);
``` to wait for 1000 ms before the code processes any further
(providing that you call 'await' inside an async function)
most things have an async function setup for processing commands, assuming that is the case, within some arbitrary command you could do
async function ThatExecutesCommand(){
await wait(1000);
// do things//
await wait(1000);
// do other things
}
another example of a promise is getting something from a database on the internet
you can't just say variable = database.getvariable
because the code has to stop and wait for it
yea, its like, regular functions return data immediately when you ask. a promise has to go and fetch the data first, so you gotta 'await' it ๐
not true i guess, you only have to await if you need the data
if you dont, you can let the promise go off and do its thing, it promised it would after all!
๐
hi, to do with the issue i had yesterday er
embed.author.icon_url: Could not interpret "{}" as string. why am i getting this error when the icon_url is a stirng?
because icon_url needs to be a string
it is, er, https://cdn.discordapp.com/avatars/${userID}/${e.avatar} is the icon_url
show code
thats what i have as the icon_url but it says thats not a string for some reason
let av = client
.getRESTUser(userID)
.then((e) => `https://cdn.discordapp.com/avatars/${userID}/${e.avatar}`)
.catch((e) => console.log(e));
console.log(typeof av);
i just added typeof av
returns object oof
realistically for that you wanna use async/await
ok, so like this?
let av = client
.getRESTUser(userID)
.then(async (e) => await `https://cdn.discordapp.com/avatars/${userID}/${e.avatar}`)
.catch((e) => console.log(e));
console.log(typeof av);```
wrong?
prolly tbh
const _av = await client.getRESTUser(userID)
const av = `https://cdn.discordapp.com/avatars/${userID}/${_av.avatar}`
can anyone help me with my bot
Luke i paid someone to make a bot for me and now he gave me a folder that has files
thank u
and i dont know literally anything atm
how can i proceed further making my bot online etc
What language is it in
.js
A VPS or virtual private server is a virtualized server instance run in the cloud. It acts like a normal server, allowing you to remotely login and manage it just like a physical server or computer. If you're looking for a way to keep your bot online 24/7, a VPS is a great option.
Having trouble choosing a VPS provider or don't know where to start? Click here for a list of common and affordable VPS providers.
do you want to run the bot in your pc or do you have a server?
and as for setup Im sure someone here will be able to help
not hosting server but a discord server ^ lol
i meant hosting
no i dont have that.
you can run it in your pc if you want, but then you need to leave your pc turned on 24/7
the bot will only be online as long as the program is running
nah i dont want that
i can prefer paying cash for hosting
those badges are good
@frozen valve wait for approval
@frozen valve you have to use https://top.gg/api/docs to post the server count to the api, feel free to ask in #topgg-api though
aight, okay
oh and wait for approval
and what are auctions for
then you need to take a look at the various hosting providers available
-auctions @earnest phoenix
i already have it in a good hosting
@earnest phoenix
What are auctions? What is #bids for? Click here to find out
basic hosting starting at $3 per month will be good enough for your bot to handle a few thousand servers
hi again, embed.author.icon_url: Not a well formed URL. why am i getting this?
message.author.avatarURL returns:
https://cdn.discordapp.com/avatars/475371795185139712/eeecda88abc719d9c31b7dc1d5d2a6c2.jpg?size=128
and the url of the message returns:
https://cdn.discordapp.com/avatars/475371795185139712/eeecda88abc719d9c31b7dc1d5d2a6c2.jpg?size=128
message.channel.send(embed).then(async (msg) => {
msg.channel.awaitMessages(m => m.author.id == message.author.id, { max: 1, time: 30000}).then(collected => {
if(collected.first().content.toLowerCase() == result){
message.reply("Bonne rรฉponse bien jouer !, tu ร sans doute le niveau : " + mental + " en calcul mental")
}else if(collected.first().content.toLowerCase() !== result){
message.reply("mauvaise rรฉponse, tu n'a peut รชtre pas le niveau : " + mental + " en calcul mental")
}
}).catch((error) => {
console.log(error)
message.reply("Tu ร dรฉpasser le temps imparti (Le temps imparti et de 30 secondes)")
})
})```when a user other than the one who made the order writes his execute the catch
they're both exactly the same but why am i getting that error?
someone can help me ?
@digital ibex may I see the code?
oh, nvm. i fixed it, mb. it was because it had "" around the link
ah
I can't seem how to make it show the presence of the bot. I tried it but it doesn't do anything
execute: async (client) => {client.user.setActivity(`Current Shards: ${client.shard.count} Shard(s)` , {type:'WATCHING'});
setInterval(() => {client.user.setActivity(`Current Shards: ${client.shard.count} Shard(s)` , {type: 'WATCHING'});
}, 20000) // every 20000 milliseconds
console.log(`Ready on client ${client.user.tag} and loaded ${client.commands.size} commands with ${client.guilds.size} servers & ${client.users.size} users.`)
}
}```
little question with discord.js
how I do for my bot send a message without mention
send method
yes
how
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=members
https://discord.js.org/#/docs/main/stable/class/GuildMemberManager?scrollTo=ban
i nee a way to ban someone if he is NOT in the server
ok and
oh
Hi, i want to put to a serverinfo how many bots/humans are in the server, what i need to do? I know that for all users ( humans + bots ) is message.guild.memberCount (in discord.js 11.5.1)
sendmethod
@earnest phoenix wait what?
@earnest phoenix reference error: channel is not defined
?
Hi, i want to code to a serverinfo command how many bots/humans are in the server, what i need to do? I know that for all users ( humans + bots ) is message.guild.memberCount (in discord.js 11.5.1)
@earnest phoenix https://discord.js.org/#/docs/main/11.5.1/class/Guild?scrollTo=members , use the filter method on the collection to filter out what you need to then simply call the .size property
granted, the count won't be accurate if all members in the guild are not cached
why channel.send dont work :/
@lofty lagoon messages are sent to channels, so channel.send() is correct, but you need to specify which channel to send to, or to get the channel from somewhere. when you do message.reply() the code basically does the .send() to the same channel the message came from, which you can get with message.channel
message.reply sends to the same channel and adds a mention. if you dont want the mention, use send, but with send, you need to get the channel first
using message.channel
how do I blacklist my bot from a server?
so like no one can invite it to just that guild
message.replysends to the same channel and adds a mention. if you dont want the mention, use send, but with send, you need to get the channel first
@quartz kindle ok gonna try
@royal portal when the bot is invited, check if the server id matches one of the ids you dont want
if it does, make it leave the guild
@quartz kindle it's say message is not defined
@lofty lagoon show your code and the error
why are you doing that
why did you do
const user = message.mentions.users.first();
message.guild.members.ban(user);
but then you did
const member = message.mentions.members.first();
member.kick();
I was indeed talking to you
im probably being stupid, just tired, but why does that last input return undefined?
https://everyone.pls-finger.me/vfvZ3Q.png
...
because arrays are zero-indexed
@snow urchin [1,2,3] has length of 3 but indexes 0 1 and 2
ah yes, stupid me
client.on('message', msg => {
if (msg.content === '@hexed drum') {
message.channel.send('hey my prefix is a. try "a.help"');
}
});
and then ban that member
@lofty lagoon if you use msg then use msg
oh
your message obj is the first param of the event callback
I am just stupid
bruh
oh boi
I told you
fetch the user
and then ban them
there's the docs
every dev must know how to read the docs
how do you give the distance between the posts in embed bro?
what do you mean
Think they might mean like the .addBlankField() method ๐ค
ok
@cedar nova addBlankField will provide spacing in between the Fields them self or whatever you want it to really... If you put it before setDescription then it should add a space there.
Not sure if that's exactly what you're looking for ๐ค just what I gathered from how you worded the question
http://alex.is-bad.com/8PKSn5b.png what happens if iconURL is an invalid URL?
can someone tell me what a 'snowflake' is
that's an id, a large number that's representing things like channels, messages and users
they are unique
HTTPError [AbortError]: The user aborted a request.
Is there any fix for this? I couldn't find one
the docs has 'string' listed as a type
and?
which means something like this would work theoretically?
var arr = ['1234567890123']
if (arr.includes(message.guild.id)) {
// something
}```
yes
ok
why not
Hi, why everytime i ran a command it ran twice?
reset token
@earnest phoenix sir restart your pc
I don't think i need to do this, the bot is hosted on glitch
hm
lmao
are you sure that the code isnt executing the command twice by mistake? maybe a copied line on accident? ๐
@earnest phoenix typr in console refresh
@sonic lodge a snowflake is just a fancy name for a number that is too big that js can't store it so it needs to be stored as a string
this is what using dynamically typed langs does to people, if you were to use a statically typed lang you'd instantly know why a snowflake is a string
anyone got some code which makes the 'commands' box opaque?
HTTPError [AbortError]: The user aborted a request.
Is there any fix for this? I couldn't find one. Not here and not on the internet.
Anyone?
@drifting dome are you using markdown or html/css
I tried this:
.longdescription .content {
min-height: 50px;
box-shadow: 4px 4px 0 0 #424f80, inset 4px 4px 0 0 rgba(204, 214, 248, 0.8), inset -4px -4px 0 0 #a5b3e6;
position: relative;
padding: 20px;
background: white;
opacity: 0.1;
font: 600 16px "Karla", sans-serif;
text-align: left !important;
flex-direction: column;
flex-wrap: nowrap;
}```
but to no avail
also this is for my bot description
it's html, css and markdown
wait do you mean transparent? because opaque means the background (the white) is fully visible and you used opacity: 0.1; which is nearly transparent
yeah that was just to try seeing if it worked; it didn't
yes I'm trying to make it invisible
I'm trying to figure out how to modify it
idk how
yeah the white box thingy you get by default
sen bu iลin osnucunu dรผลรผnmedinmi laaa
where, in body or head? @valid frigate
it should be in a style tag
in that css rule you posted
<style>css</style>
ok that css rule doesn't work, I copied it from google inspect on the element
I'll try making it transparent tho
nope, still visible
I'd send the whole thing but I think it's longer than 2k characters ๐คท
actually background works too
makes editing the page and seeing how it looks much better
margin: 0;
padding: 0;
background: #579FE9;
background-color: #579FE9;
opacity: 5;
width: 100%;
height: 100%;
overflow: hidden;
}```
that doesn't work apparently
it doesn't need to be, even though it's recommended to
because validators hate them if it's outside head
but it should still work
yes but not wiruses
ok here's the most of my code
oop
ok
the webpage, mostly yoinked from codepen, will give credit dw
bot.on('message', async (message) => {
let channel = bot.channels.get("692820090831503412");
let chance = Math.round(Math.random() * 1000);
let amount = Math.round(Math.random() * 200);
let embed = new RichEmbed()
.setColor(0xabc123)
.setAuthor("Reward Spawned", bot.user.displayAvatarURL)
.setDescription("A lootbox spawned with " + amount + " tokens inside.");
if (chance > 900) {
channel.send(embed).then(function (msg) {
message.react("๐");
const filter = (reaction, user) => {
return ['๐'].includes(reaction.emoji.name) && !message.author.bot && user.id === message.author.id;
};
msg.awaitReactions(filter, { max: 1, time: 200000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '๐') {
msg.delete();
eco.addMoney(message.author.id, amount);
message.reply("You grabbed the " + amount + " tokens.");
}
})
})
}
});
I cant seem to make this work so that anyone can react and not just the message author
What discord.js version?
11.5.1
wait. couldn't I make an entire website and pate it into that?
@blazing portal 11.5.1
Your filter is checking that the reaction is from the message author
Yeah. Mr Delivery Man beat me to it
How would i make it from everyone tho
Yeah. Mr Delivery Man beat me to it
Sorry lol
just remove the user.id === message.author.id?
remove the && user.id === message.author.id
Yeah
Ight
did you understand what you coded wtf
99^ sure the bubbles classes are supposed to be the lowest
What about now for the eco.addMoney(message.author.id, amount); what would i put to replace the message author id
i didn't double-body did I?
you did, probably
@true ravine What about now for the eco.addMoney(message.author.id, amount); what would i put to replace the message author id
@blazing portal What about now for the eco.addMoney(message.author.id, amount); what would i put to replace the message author id
