#development
1 messages ยท Page 1371 of 1
you can get the first mentioned member (it's not in any particular order) by using message.mentions.members.first()
bot.on('message', msg => {
if (msg.content.substring(1, 5) === "/kick") {
msg.mentions.members[1].Kick()
}
});```
?
oh
first
yeah
you should read docs, dont make up your own property names: https://discord.js.org/#/docs/main/stable/class/GuildMember
there is no method called Kick()
bot.on('message', msg => {
if (msg.content.substring(1, 5) === "/kick") {
msg.mentions.members[1].Kick()
}
});``` if I had this, and i said "/kick @earnest phoenix @pale vessel" would it kick me and you or just me
since the mentions are not in any particular order, it's kind of random
but only one of them
but if I used .First it will just kick me right?
wait so there isnt a .kick() method?
user.send(message)
you have to check whether message.mentions.members.first() exists first before trying to kick them
user.send() or member.send()
both works
how would i check if theres a ping in the message tho?
would i have to iterate thru all members
check length of message.mentions
eh?
oh
i think you should learn js basics first to be honest
thats literally the thing that you used
@pale vessel yes but
otherwise it would hard to grasp these things
I would recommend checking the docs on lots of this too, then asking about anything you are confused about. Docs can honestly help more than us, and where it doesnt we can fill in the blanks
i would get an error if i did js bot.on('message', msg => { if (msg.content.substring(1, 5) === "/kick") { msg.mentions.members.First.Kick() } }); and i said /kick hi
so how would i check that that is a valid mention
msg.mentions.members.first().kick()

@waxen tinsel wdym check length
only thing i can think of is iterate through all members
If there are no mentions, then its going to error when you try to get something that doesnt exist
and check if the iteration value = the string
Hello world! Xddd
If there are no mentions, then its going to error when you try to get something that doesnt exist
@waxen tinsel thats exactly my point
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
const member = msg.mentions.members.first()
member.kick()
}
});```
Here
there has to be a way to check length of a list or whatever in js. Thats how I would do it in python, at least.
my point is
just going to leave this to you extreme
am i wrong @pale vessel ?
btw does anyone know how a gaming "Attacks" should work? like the damage dealth etc
currently the damage is constant every round
from what ive heard Lua and js are pretty simular so i dont think i need to learn js basics
@earnest phoenix then check if there are any mentions first
you can use .length for arrays, but since mentions.members is a collection/map, you can use mentions.members.size
Then do it if(!member) return message.channel.send("Mention Someone!")
@earnest phoenix call .find() not .get()
?
null
null
null
One message removed from a suspended account.
I think it connects before handshakre
One message removed from a suspended account.
Pretty sure it does
do bot.on() methods run in a new thread or the same thread
@earnest phoenix call .find() not .get()
@blissful coral .find(c => c.name === 'the channel name') ?
One message removed from a suspended account.
One message removed from a suspended account.
so sad
does js have coroutines
@earnest phoenix yes
Okay
.get is id*
im going to run the kick thing in a new thread so if it errors it doesnt break the entire bot
anyone got an answer for me on this?: #development message think it got lost in chat.
Good evening I try to integrate this button in the description of my bot on top.gg but it does not display
<script type="text/javascript" src="https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js" data-name="bmc-button" data-slug="sayrix" data-color="#FF5F5F" data-emoji="" data-font="Poppins" data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#ffffff" data-coffee-color="#FFDD00"></script>```
you can't use javascript
@pale vessel i found out a way to do what i was saying
message.guild.member(user)
theres a function that does this
uh, no
it was on the api
I put the code on an html file and the button works but on top.gg it doesn't work
well, it only works for ids and user objects
I put the code on an html file and the button works but on top.gg it doesn't work
@earnest phoenix you can't use the script tag in the description
ah okay
no js code basically
yes, only works for promises though
you need to use try {} catch(e) {} if it's not a promise
its not though ;-;
is it defined now lol
ok I tried to convert the code to html but it's supposed to have a button with an orange background but there's only the text and the coffee icon
I think this is the code
.bmc-btn svg {
height: 32px !important;
margin-bottom: 0px !important;
box-shadow: none !important;
border: none !important;
vertical-align: middle !important;
transform: scale(0.9);
}
.bmc-btn {
min-width: 210px;
color: #ffffff;
background-color: #FF5F5F !important;
height: 60px;
border-radius: 12px;
font-size: 24px;
font-weight: Bold;
border: none;
padding: 0px 24px;
line-height: 27px;
text-decoration: none !important;
display: inline-flex !important;
align-items: center;
font-family: 'Poppins', sans-serif !important;
-webkit-box-sizing: border-box !important;
box-sizing: border-box !important;
}
.bmc-btn:hover, .bmc-btn:active, .bmc-btn:focus {
text-decoration: none !important;
cursor: pointer;
}
.bmc-btn-text {
margin-left: 8px;
display: inline;
line-height: 0;
}```
if the button does anything more than redirecting you to their site, it wont work.
Hi
I haven't used discord.js v12 since I am currently learning java, but ever since they've added .cache
I cant really do message.guild.members.cache.size as that returns the members that have been cached.
How do I truly fetch all members in the server?
I got ```js
proccess.on('unhandeldRejection', (err, reason, promise) =>{
console.log(reason)
})
ah, let me enable that
Cant seem to enable it lol
is the bot in over 100 servers?
You need to get whitelisted
ยฏ_(ใ)_/ยฏ
I got ```js
proccess.on('unhandeldRejection', (err, reason, promise) =>{
console.log(reason)
})
process is spelt wrong ._.
ye i know
i typed it out here
like quick
how i got in my code
i mean you can try something like client.channels.cache.get("channelID").send(reason)
well its on the entire process
so you cant really
msg.delete() for this method
It has to be in a client event
to get a channe
l
talking to me?
no
how would you know which channel it occured in
to apollo
Idk
thats the problem
was about to say you can use a webhook but uh
ooh yes
thats what i can do
best way would be to make a map of errors or whatever
and then dm the error maybe?
i dunno
theres no client
hm
const sendWebhook = (id, token, message) => {
if (allowed) axios.default(`https://discord.com/api/webhooks/${id}/${token}`, {
data: {
content: message
},
method: 'POST'
})
.then(res => {})
.catch(e => {
console.log(e.response.data.retry_after)
});
}```
the client.on('error') function suckz
I find it useless, so
why do you even want to send the unhandledpromiserejection to the channel
So the person who executed a command
seems like too much for the avg user to handle
knows that theres a problem
just handle the errors in the command
??
try catch block or just handle the promises
ye
maybe
console.log is always another thing
webhook is your best bet though if you think you're going to experience a fuck ton of errors you are lazy to receive in your terminal
why would you use a webhook if you are working on a discord bot
send a message using the bot
yay ratelimit
theres a ratelimit for webhooks too
ye
and its per channel
no it doesnt?
It does
just somewhere client is defined
otherwise it returns undefined
what
add this in ur main file
but not in a client on function
console.log(client.users.cache.size)
it will say undefined
yeah well the client isnt ready yet
ye but if it is?
if
console.log your on ready
that will work
Really, it should work
yea lmao
I need bot infrastructure for glitch can you help me
Do you mind sending us the whole code?
glitch 
@solar helm You want a video?
yes
Heya! It's been a while since I've last uploaded.
This is an updated and more in depth tutorial on how to create a 24/7 Discord Bot using Glitch and UptimeRobot!
If you want the code, click this link:
https://projectalpha.cc/support
Discord Developer Portal (Create/Manage yo...
Dont mind who made it
It helps.
lmao
thx
Big Announcement,
Glitch no longer supports 24/7 Discord Bots as they have released a paid subscription to keep your project online 24/7.
This method does work however, but its lasting time will last for an indefinite time.
Sorry to break out the news..
weee wooo, thats why I bought a vps
yes
lmao glitch
havent heard that in a while
arent those things like way more expensive if you pay than a vps
honestly, I thought it died as a discord bot host, but surprisingly it still works lol
i know heroku is overpriced as hell
im pretty sure heroku just emails you 50 times per day saying it will expire
but really it doesnt
i mean like the paid plan
oh yeah
@earnest phoenix Where can I find the link of the infrastructure in the video?
@proper bolt pog
@solar helm its an 8 minute video, do me a favor and give me watch time scroll to the end of the video and copy it from there.
send me your provider ._.
i forget how much i pay for aws
aws pricing isnt bad iirc
holdup $1/mo for 7gb of ram is hella cheap
what the hell do you use
I couldn't understand where is the link? @earnest phoenix
ight imma commit something brb
Why does my bot always turn off
@proper bolt galaxygate, which is overpriced af, but I plan to move to something cheaper.
I turn it on using node .
but it turns off random
@earnest phoenix are you using pm2?
what does that mean
where are you hosting it in the first place
on my computer
well, if you close the terminal or turn off your pc
the bot will go offline
so
how do i fix that
aslo
i never closed the terminal
do errors shut off the bot?
yes
dockerize it or use pm2
some errors do.
dockerize it
pm2 is easier
what does that mean
and whats pm2
pm2 is a package that keeps your bot running
is it free
yes
pm2 start [main.js] --name=[name of the application]
and then
pm2 log [name of the application]
so i would do
you should really research pm2 on your own. theres a lot of little useful features you may want
C:/me/OneDrive/Documents/DoritoBot> pm2 log index.js?
after i downloaded pm2
read what I said above
pm2 start [main.js] --name=[name of the application]
pm2 log [name of the application]
wdym by name of application
name it whatever you want
i suggest a short abbrev.
by name of application do u mean this
no
your bots name
C:/me/OneDrive/Documents/DoritoBot>pm2 start index.js
or anything
can i just do this
pm2 start index.js --name=sparkus
pm2 log sparkus
something like that.
can you give me an example
that doesnt make sense
just did
C:/me/OneDrive/Documents/DoritoBot>
using my directory
okay
wait
cd to your bots folder
iti s
it is*
then run pm2 start index.js --name=DoritoBot
pm2 log DoritoBot
simple as that
all imma give you
ok got it
oh and pm2 save
uhh
C:/me/OneDrive/Documents/DoritoBot> pm2 start index.js --name=DoritoBot
C:/me/OneDrive/Documents/DoritoBot> pm2 save
so like that
?
yes
ok thx
bot.on('ready', () => {
console.log("${bot.User.Tag} logged in successfully");
});```
also why does my bot literally say "${bot.User.Tag}"
what
also bot.user.tag
not User
oh
console.log(``${bot.User.Tag} logged in successfully``);
so like that
no
remove ` from each side
console.log(${bot.User.Tag} logged in successfully);
oops
mhm
thats right
also it should be bot.user.tag
console.log(`${bot.User.Tag} logged in successfully`);
non caps
wait
bot.user.tag like I said above
do u mean ` or '
@earnest phoenix thats correct.
if (member) {
member.kick();
msg.channel.send(`> ${user.Tag} has been kicked.`);
user.send(`You have been kicked from the server. `);
msg.delete();```
why does it error saying
cannot send message to this user
do you know how code works
You're kicking the user first
bruh
DM the user first then kick
someone earlier told me
member, vs user
member is person in the server
user is anyone
that isn't related
you're bot can't message you're user because they don't share any guilds
do you know how code works
@earnest phoenix yes ive been scripting lua for over 2 years
- you're kicking the member first
- if the member's dms are closed then it wont work and it throws errors
You need to send the DM FIRST then kick
lua is completely unrelated to js
^
that wasnt his question
he asked if i knew how code worked
were talking about js
because you're coding in it.
ok
when you say standalone "code" i assumed you meant coding logic
self explanatory if you put some logic into it.
If this passes the argument, then it executes this..
Else we run this
what
are you learning js right now @earnest phoenix ?
yes
#development message
Read this and try again btw.
@proper bolt yes but i know c# so i have some understanding of js
im not completely new to the concept
when you say standalone "code" i assumed you meant coding logic
code that can stand alone
do u not know what standalone means
i dont literally mean stands with noone else
wait is js synchronous or asynchronous
i can look that up actually
๐ค
js is a lot of both
is it a front end or backend language? both.
is it multi threaded or single threaded? both.
is it async or sync? both.
Anyone know css here?
Like actually know css
k
so
border-radius: 10%;
float: left;
I am using float left
does anyone actually know css ;p
Because I am gonna put text to the right of it
css is so mishmashy
ay, botreviewers got their roles 
Only when using float tho
First wave did

Yeah float right fuck's it up aswell
Damnit
I want to create a webhook url with heroku, but when I press the button test I receive this error..
I need to put this in a start files ? pls (my bot is host on heroku with discord.js)
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL, { webhookPort: process.env.PORT, webhookAuth: process.env.PASSWORD});
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
"name": "bot",
"version": "1.0.0",
"description": "",
"main": "bot.js",
"dependencies": {
"dblapi.js": "^2.4.1",
"discord.js": "^11.6.4",
"file-system": "^2.2.2",
"ms": "^2.1.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}```
You need a start field in the scripts field.
For example: json { "start": "node ." }
so that !?
{
"start": "node bot.js"
}```
Try it and see
mb mb sorry
@craggy pine if you're still looking into customizing the review stars, its possible without js, but its a bit complicated, you need about 5 lines of css, one for each rating
I figured it out โค๏ธ
Kinda seend ur message earlier in the other channel @quartz kindle
๐
how can i make it so
any string Uppercase or lowercase characters gets accepted
HellO will work
hello will work
hElLo will work
etc...
how can i make it so
You ask Picard
oh
To accept any case, just put everything as lowercase.
what language?
not sure if string.lower() exists in js
ok
@umbral zealot (figured it out, sorry for ping)
cuz message is an object
oh
message.content is the actual string with the contents of it
yup
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
var SplitMessage = msg.content.split(" ");
const user = SplitMessage[1];
const reason = SplitMessage[2];
if (user) {
const member = msg.guild.member(user);
if (member) {
user.send(`You have been kicked from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${member.tag} has been kicked.`);
member.kick();
msg.delete();
} else {
msg.channel.send("> User is not a valid member of this channel!");
}
} else {
msg.channel.send("> User must exist");
}```
im doing something wrong here but i dont know what
it doesnt error
it just doesnt work right
like
am i using string.split right for one?
thats what it says
and i said the message once
why does it say undefined has been kicked
how should i be doing it
uhhh
what
but how will it know
what member im tryng to get
const member = msg.guild#Members.cache.get(user)
so like this
what does that mean
@earnest phoenix
@earnest phoenix ur script doesnt work
everything is green
wait
no i think ur misunderstanding
const member = msg.guild.member(user);
this is literally the example the api uses
im asking why it says Undefined
because the member is not cached
it still kicks them?
yes
yes
Only user have tag property, not member
also it doesnt send the reason
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
var SplitMessage = msg.content.split(" ");
const user = SplitMessage[1];
const reason = SplitMessage[2];
if (user) {
const member = msg.guild.member(user);
if (member) {
user.send(`You have been kicked from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.tag} has been kicked.`);
member.kick();
msg.delete();
} else {
msg.channel.send("> User is not a valid member of this channel!");
}
} else {
msg.channel.send("> User must exist");
}```
still kicks them
still says > undefined has been kicked
still doesnt give them a kick message
not even the user.send() one
and no errors
im gonna start randomly posting this here so people get a bit more awareness that this tool exists.
https://code.visualstudio.com/docs/editor/debugging
80% of the problems here is people not knowing that VSC gives them a debugger to find that stuff out
is there compiler debugger
then open and link and read whats in
it says nothing
which compiler?
thats why im confused
rustc
how can i have my cogs inside a folder instead of just being files inside my bot folder?
huh?
you dont need an error to debug
what im doing is that old saying
give a man a fish and he'll eat for a day
teach the man how to fish and they'll never starve
or something along those lines
i'd much rather teach you how to debug code
i know how to debug jesus
its just that
making changes to a bot
then having to republish it
takes like 5 minutes
id rather just ask
wdym republish the bot?
what do you want to do
i have to kick it from my server
waht
why?
no you don;t?
then re-require the cache
i dont know what that means
set the command in a different folder and then re-require
oh you want live editing
delete the cache
if you don't want to do this you can just restart the bot
you don't have to kick it
how do u restart the bot
what do you use?
vs
js
do you know how to close a javascript command line program
no i keep every tab i have open from the day i made my pc
if you figure out how to, that's how you can turn off your bot
do you know how to close a javascript command line program
@strong tundra
vs doesnt work like that
its not a console
is this visual studio
or visual studio code
vs 2017
you don't compile javascript???
js isn't compiled
why are you using vs for js
lol
Visual Studio 2017 is literally the name of the application
there's a stop button on the top
@earnest phoenix this, reload on the go
wait lemme get vs pulled up
vs 2017 is old you shouldn't be using in the first place and visual studio was made for .net
i dont know how to use new visual studio
ok?
learn?
so i dont use it
why
id rather use an old one which makes more sense
as long as it works
....
there's a stop button right here https://emma.is-ne.at/zEgM9r.png
im using c++ but it should be same for whatever
you're not making any sense whatsoever
what in the literal fuck are you doing lol
i know
this dude is asking why i use an ide to script
we're trying to help
visual studio isn't made for javascript and doesn't have proper javascript support
yes it does
update your code, and delete and re-require the cache so you dont have to restart the bot
js is run on NODE
it has formatting support
it does
though i wouldn't use it for javascript
that code runs on NODE my dude
no yeah vs works fine for javascript, it's just that no one uses it
VSC
webstorm
visual studio is NOT the same as Visual Studio Code
ok lemme ask a question
oh
ah ok you're using vs
i use vs for every language
lua
c#
js
py
ive never had a problem with it
also you shouldn't be complaining that shit on older software doesn't work... it's older software
update to vs2019
you can click the stop button and it should stop
i have vs 2019
or use VSC like everyone
it doesnt make sense
lua is compiled
yes
compiled languages are supported on vs
javascript is supported on vs as well,
no yeah vs works fine for javascript, it's just that no one uses it
i use javascript owo
interpreted languages have trash support in vs
ok there
can u help me with my problem now
can you take a screenshot of your whole screen
oh wait this is vsc duh
click that to generate a new profile
ah ok
lo l
lol
genuinely can't tell if this is trolling or just being awfully dull
is your bot currently running
i see the error
How can i check if a member has a role with administrator permissions?
I tried
guild.members.cache.get(executor.id).roles.cache.filter(u => {
u.permissions.has(['ADMINISTRATOR', 'BAN_MEMBERS', 'KICK_MEMBERS'])
})
But returning an empty collection
@opal plank that button doesnt even appear for me
cuz its VSC
thtas
which was the screenshot you psoted
because u said to use vsc
no, THATS VS
no it isnt
the one i linked is VSC
hold upp..... what is the error
:l tbh i edit my stuff in microsotf wordpad like a bep
YO
G
VSC SUPPORTS THE THING
click that
welcome to 2020
anyhow, clieck that button
hmm turn const user=splitMessage[1] into const user=splitMessage[1].split('').filter(a=>{!isNaN(parseInt(a))})
i see you clearly figured it out
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
var SplitMessage = msg.content.split(" ");
const user = SplitMessage[1];
const reason = SplitMessage[2];
if (user) {
const member = msg.guild.member(user);
if (member) {
user.send(`You have been kicked from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.tag} has been kicked.`);
member.kick();
msg.delete();
} else {
msg.channel.send("> User is not a valid member of this channel!");
}
} else {
msg.channel.send("> User must exist");
}
} else if (msg.content.startsWith("/ban")) {
var SplitMessage = msg.content.split(" ");
const user = SplitMessage[1];
const reason = SplitMessage[2];
if (user) {
const member = msg.guild.member(user);
if (member) {
user.send(`You have been banned from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.tag} has been banned.`);
member.ban()
msg.delete();
} else {
msg.channel.send("> User is not a valid member of this channel!");
}
} else {
msg.channel.send("> User must exist");
}
} else if (msg.content.toLowerCase() === "!twodoritos") {
msg.channel.send("");
console.log("Yo");
}
});```
why does it say everything twice
cuz u have 2 bots running
why does it say everything twice
@earnest phoenix ohhhhh yea
i do?
how do u know
someone came to me with that error before
if you clicked that button it should've started a debugging session
and they realised they had multiple sessions running
it did this with vs too
then you got one bot running on vs, one on vsc
why does it say everything twice
@earnest phoenix if this is ur only error, the problem isn't with the code
most likely
huh?
How can i check if a member has a role with administrator permissions?
I tried
guild.members.cache.get(executor.id).roles.cache.filter(u => {
u.permissions.has(['ADMINISTRATOR', 'BAN_MEMBERS', 'KICK_MEMBERS'])
})
But returning an empty collection
<GuildMember>.hasPermission(...)
no i want to check roles permissions
The brackets are probably there just so the line isn't too long.
remove the brackets
Yeah, and you aren't returning in the body, which is defaulting to undefined, which is falsely. Hence, empty collection.
Either remove the brackets or add a return statement in there.
Imo it would look long. Like, look at this: js guild.members.cache.get(executor.id).roles.cache.filter((role) => role.permissions.has(['ADMINISTRATOR', 'BAN_MEMBERS', 'KICK_MEMBERS']))
Then again whitespace helps so no braces is fine.
the brackets r a mental helper to me
ah yeah working thx
Hey, i'm getting this error when starting my bot (the privilege intent are enabled) :
(node:39376) UnhandledPromiseRejectionWarning: Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted.
Has anyone an idea ?
https://cdn.discordapp.com/attachments/754622342746996806/774780563248381972/image0.png
quite intuitive
@hasty lotus show your intents in your code
where am i supposed to find it ? (it's not my bot but one of a friend im only hosting it)
in the main file
where you initialize your client
probably
bot.js
index.js
main.js
it will have new Discord.Client({ stuff here })
const client = new Client({ws:{intents:["GUILD_PRESENCES", "GUILDS", "GUILD_MEMBERS", "GUILD_MESSAGES" ,"GUILD_BANS", "GUILD_EMOJIS" ,"GUILD_INTEGRATIONS", "GUILD_INVITES", "GUILD_MESSAGE_REACTIONS", "GUILD_PRESENCES"]}});
is that it
?
GUILD_PRESENCES?
that requires the presence intent to be turned on
ok
turn this on
const channel = member.guild.channels.cache.find(channel => channel.name === `welcome`);
if (!channel) return;
const { guild } = member
const { name, memberCount, owner } = guild
const joinembed = new Discord.MessageEmbed()
.setColor('GREEN')
.setTitle(`Welcome to "${name}"`)
.setThumbnail(member.user.displayAvatarURL())
.addFields(
{
name: 'New user!',
value: member,
},
{
name: 'Member count:',
value: memberCount,
}
)
.setFooter('Time Joined', member.guild.iconURL())
.setTimestamp()
channel.send(joinembed);
});
anyone knows
why this does not work?
it used to do
What doesn't work about it?
is there a good way to get a files own name?
image the scenario
a folder with 10 .js files
each with different contents inside
is there a way to get the file name of the file from within it self?
isn't there __filename?
__filename represents the current file's absolute path. It's a variable.
I'm not sure about this, but you could then use the path module to resolve the file name from the absolute path.
or i could split and grab last
if it returns a string , split('/')
then just do length - 1
You could, but that doesn't support every platform. Windows uses backslashes, while other Unix-based systems use forward slashes.
Unless you don't care about that
but
What about in development?
its just better to ahve it the way i got rn with a simple string
this is just for science tbh
did they updade member.guild.channels.cache.find(channel => channel.name === ``welcome``) syntaxis?
because it does not seem to work
i was just wondering, why the heck even bother with the name when the file itself has that already
2020-11-08T00:01:14.195780+00:00 app[worker.1]: (node:4) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit```
though its much better to have a simple string rather than add more logic to it
How can I get two mentions in one message? (discord.js)
@earnest phoenix | @earnest phoenix
message.mentions.members.first()
performance wise
you wanna get only first and second?
or n amount?
do you wanna send multiple mentions, or when the message is recieved?
i didnt get much of that question tbh
get 2 mentions in on message, as in , reciveing a message or sending on?
for example I used test @aproxthethat#1000 | @xtest. I want to takeboth.
just 2?
yeah
you could simply do
channels.name does not exist now?
let a = [...members]
a[0] and a[1]
thats probably the shortest way you could do it
channel*
const channel = member.guild.channels.cache.find(channel => channel.name === `welcome`);
if (!channel) return;
message.channel.send('asdasdadsasd')```
idk why this is not working
im getting mad at it
@earnest phoenix ```js
let a = [...message.mentions.members.values()];
let mentions = a.slice(0,1);
@earnest phoenix thats the shortest i can think of
actually, no
yes
truers
let mentions = [...message.mentions.members.values()].slice(0,1);```
there, 300iq one liner
Or just members.first(2)
Yours or mine
didnt even know first took params
use that then
it probably does exaclty what i did though
not quite
ah, its using arrays too
but not in the same way
im destructuring
damn thats some complicated stuff they doing
i'd still use what i did though
I was the one who added that feature ๐
Back in the day. That's not my code anymore but I introduced the feature.
well.... mine is probably on par with that
return [...this.values()].slice(0,amount);
this is what i'd use
for lastjs return [...this.values()].slice(this.size - amount, this.size);
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
var SplitMessage = msg.content.split(" ");
const user = SplitMessage[1];
const reason = SplitMessage[2];
console.log(user)
const member = msg.guild.member(user);
console.log(member)
user.send(`You have been kicked from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.tag} has been kicked.`);
member.kick();
msg.delete();```
I was the one who added that feature ๐
good
because it's nullable
actuallSplitMessage[1] is going to be a string.
Not a GuildMember or User instance.
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
const user = msg.mentions.members.first()
if (user) {
const member = msg.guild.member(user);
if (member) {
user.send(`You have been kicked from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.tag} has been kicked.`);
member.kick();
msg.delete();
};
};```
i know i can do this, but then i cant have a reason
wait actually
yes i can
bot.on('message', msg => {
if (msg.content.startsWith("/kick")) {
const user = msg.mentions.members.first()
const reason = SplitMessage[2];
if (user) {
const member = msg.guild.member(user);
if (member) {
user.send(`You have been kicked from ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.tag} has been kicked.`);
member.kick();
msg.delete();
};
};```
this should work
Yes, like that.
if i wanted a reason
@weary socket use inspect element
@rustic nova what?
I dont understand Hope
Cant find how they ve done that
If you don't understand what i mean with "inspect element", then you are not ready to do that yet and should come back to it once you have experience
No I kno what you mean with that....I just cant find what you mean in that code
huh vald ur still here hiii
If you don't understand what i mean with "inspect element", then you are not ready to do that yet and should come back to it once you have experience
agreed.. inspect element was the reason i learned what i learned
anywho.... umm got an error UnhandledPromisRejectionWarning: FetchError: request to https://discordapp.com/api/v7/channels/***/messages failed, reason: getaddrinfo ENOTFOUND discordapp.com discord.com:443
Did your internet die
Try with another site (e.g. Google) and try again with Discord
i did... it's strange i tell u
i have a feeling i know what caused it, but as to how it would cause that, wack
position: relative;
overflow: hidden;
padding-top: calc(7rem + 72px);
padding-bottom: 7rem;
background: linear-gradient(0deg,#ff6a00,#ee0979);
background-repeat: no-repeat;
background-position: 50%;
background-attachment: scroll;
background-size: cover;
}```
Can i put this Code in the description and get a background?
basically, when bot receives message, it makes a global var m5g = the messages msg
but theoretically, if message is recieved at the same time, what on earth happens to var m5g?
i guess my bot's getting famous for it to recieve 2 msgs in under the time it takes to return a response
but if i fix that hole in my code and it still happens... i call bug
its pretty common to get two messages at the same time
discord lags for a moment and two messages are received at the same time.
i mean.. i send the msg string into an object that just returns(the obj's keys r functions)
for 2 msgs to pass that quick.. oof
but, as u said, y didn't this happen sooner?
hmm prob just my internet that dipped for a bit..
still was a strange event
header.masthead {
position: relative;
overflow: hidden;
padding-top: calc(7rem + 72px);
padding-bottom: 7rem;
background-color: linear-gradient(0deg,#ff6a00,#ee0979);
background-repeat: no-repeat;
background-position: 50%;
background-attachment: scroll;
background-size: cover;
}
</style>```
Would that work for my Background?
global variables cause a lot of weird things
which is why they are not reccomended
๐คทโโ๏ธ I always just play with css till it does what I want
async fetch(type: "ticket" | "message" | "channel" | "author", arg: any) {
const ticket =
type === "ticket"
? arg
: type === "author"
? await coll.findOne({ userId: arg })
: await coll.findOne(type === "message" ? { ticketMessage: arg } : { supportChannel: arg });
if (!ticket) return false;
if (!ticket.logs) coll.findOneAndUpdate({userId: ticket.userId}, {$set: {logs: []}});
this.id = ticket.ticketId;
this.userId = ticket.userId;
this.status = ticket.status;
this.attachments = ticket.attachments;
this.acceptedAt = ticket.acceptedAt;
try {
this.ticketMessage = await ticketsChannel.messages.fetch(ticket.ticketMessage);
this.embed = this.ticketMessage.embeds[0];
} catch (e) {
console.log(e);
}
if (this.status === 1) {
this.channel = ticketsChannel;
this.channelMessage = await this.channel?.messages.fetch(
ticket.supportEmbed
);
this.supporters = await Promise.all(
ticket.supporters.map((s: string) =>
ticketsChannel.guild.members.fetch(s)
)
);
}
if (ticket.attachmentMessage)
this.attachmentsMessage = await ticketsChannel.messages.fetch(ticket.attachmentMessage);
try {
this.user = await ticketsChannel.guild.members.fetch(ticket.userId);
} catch {}
return true;
}
something here is giving unknown channel error, and I have not a clue why, anyone?
what line does the error say
Well discord's lovely and very handy API errors, DONT tell us the line
I have checked everything, I am 99% sure its between the try{}catch{} after this.acceptedAt, as I had console logs and it stopped there.
But I don't see how it could be
ticket.ticketMessage is in the db
and supportEmbed
etc
unknown message happens when you're trying to edit, delete, fetch, react to, etc, a message that has already been deleted
it could be any of your messages.fetch lines
could be that some id in there is wrong
add a try catch to every single messages.fetch in there, and console.log something different on each one
so you know which one its coming from
this one gets the error, but I do not see why, the id match's with the database and the message has not been deleted
if (msg.content.startsWith("/kick")) {
var SplitMessage = msg.content.split(" ")
const user = msg.mentions.members.first()
const reason = SplitMessage[2];
console.log(reason)
if (user) {
const member = msg.guild.member(user);
if (member) {
try {
user.send(`You Have Been Kicked From ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.member.tag} Has Been Kicked.`);
member.kick();
msg.delete();
} catch(error){
console.error(error)
}
};
};```
it kicked him but he didnt get the dm
ok also
if u try kicking another admin it errors obviously
but the error is literally "DiscordAPIError"
so i can throw an exception to that without it ignoring every error regarding the bot
so how do i overcome this
I do this
process.on("unhandledRejection", (err: any) => {
const ignoredErrors = ["Error [GUILD_MEMBERS_TIMEOUT]: Members didn't arrive in time.", "DiscordAPIError: Missing Access", "DiscordAPIError: Missing Permissions"]
if(ignoredErrors.map(x => err.toString().includes(x)).includes(true)) return;
error(err.stack.toString())
})
try {
throw 'DiscordAPIError: Missing Permissions'
user.send(`You Have Been Kicked From ${msg.guild.name}: ${reason}`);
msg.channel.send(`> ${user.member.tag} Has Been Kicked.`);
sleep(500)
member.kick();
msg.delete();
} catch(error){
console.error(error)
}```
howcome im literally throwing an exception to this error
yet it still catches the same error and gives me it
wait am i misintepreting try
ahhhhhh hello again
you're throwing the error then catching it again

