#development
1 messages · Page 1374 of 1
so how can i do something like
const reason = SplitMessage[2 and above]
wait i forgot about iterating
String reason = ""
for(var i=2, SplitMessage.Length-2, i++) {
v = SplitMessage[i]
reason ..= v
}```
this should work right?
wait .. is lua
how do you concatenate
bruh u can do +
wtf
C:\Users\dogli\Documents\Discordbot\index.js:63
.setTitle(message.mentions.members.first().toString + 'called , ' + message.author.toString())
^
TypeError: Cannot read property 'toString' of undefined
at Client.<anonymous> (C:\Users\dogli\Documents\Discordbot\index.js:63:69)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\dogli\Documents\Discordbot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\dogli\Documents\Discordbot\node_modules\ws\lib\websocket.js:797:20)
my error
my code
if(message.content.startsWith(prefix + "call" )){
message.channel.send('Ur love');
}
if(message.content.startsWith(prefix + "call" )){
var embed = new Discord.MessageEmbed()
.setTitle(message.mentions.members.first().toString + 'fcalled , ' + message.author.toString())
.setTimestamp()
.setImage('')
message.channel.send(embed);
}
did you enable intents
...
Hi, my bot is not showing this image: https://top.gg/api/widget/763042495655313479.svg
Is that a valid image?
const reason = "";
for(var i=2; SplitMessage.Length-2; i++) {
v = SplitMessage[i];
reason += v;
}```
@earnest phoenix do u know why this isnt changing the value of reason?
what is that for loop
ok so
i know
My uh kick command
you want to skip the first two args
yes
but what's the reason for subtracting
also
in js, indexes are 0 based
they start at 0
i know
0 = command
1 = user
2+ = reason
ah
remove that subtraction
/kick user is very annoying
it doesn't make sense
if i didnt subtract 2
it would say
stop
spamming
your
code
you have been kicked for: user is very annoying null null
holy fucking shit i told you what the error is can you not read
@earnest phoenix what 🤔
if arr[0] is command and arr[1] is user
if i didnt subtract 2
it would say
"reason null null"
you're starting at a different index though
because its like wtf are the other 2 elements
this is how i made it on my lua version
local m = msg:split(" ")
local cmd, plr = table.remove(m, 1), table.remove(m, 1)
local reason = table.concat(m, " ")```
is something like this possible in js
@pale vessel can u help me
cry can help you
i asked you whether you had enabled intents and you still have not answered me so stop bothering other people lol
i said no
how
done
@pale vessel I know why its doing this, but i dont know how to fix it
When I tried your method it said like
/kick user very annoying
the dm would be
very,annoying
i can help u @earnest phoenix
how can i remove da , and space it out
m.join(' ')
oh
here ```js
if (message.content.startsWith('!kick')) {
let messageArray = message.content.split(" ");
let command = messageArray[0];
let args = messageArray.slice(1);
let xdemb = new Discord.MessageEmbed()
.setColor("#00ff00")
.setTitle("Kick Command")
.addField("Description:", `Kick a member`, true)
.addField("Usage:", `Kick [user] [reason]`, true)
.addField("Example:", `Kick @rain spam`)
}
ik
dank
is there like an unpack method for tables
and this ```js
if(cmd === 'kick'){
if(!msg.member.hasPermission('KICK_MEMBERS')) return msg.channel.send("You don't have permission to kick members :stuck_tongue_closed_eyes:.");
let toKick = msg.mentions.members.first();
let reason = args.slice(1).join(" ");
if(!args[0]) return msg.channel.send('Please mention someone to kick cutie :stuck_tongue_closed_eyes:');
if(!toKick) return msg.channel.send(${args[0]} is not a member :stuck_tongue_closed_eyes:.);
if(!reason) return msg.channel.send('Specify a reason :stuck_tongue_closed_eyes:.');
if(!toKick.kickable){
return msg.channel.send(':x: I cannot kick someone that is mod/admin cutie are u dumb :stuck_tongue_closed_eyes:. :x:');
}
if(toKick.kickable){
let x = new Discord.MessageEmbed()
.setTitle('Kick')
.addField('Member Kicked', toKick)
.addField('Kicked by', msg.author)
.addField('Reason', reason)
.addField('Date', msg.createdAt)
msg.channel.send(x);
toKick.kick();
}
}
@earnest phoenix still have error
message.mentions.members.first() is possibly undefined in your code which could cause the error @lucid prawn
how do i fix that
if(message.content.startsWith(prefix + "call" )){
message.channel.send('Ur love');
}
if(message.content.startsWith(prefix + "call" )){
if (!message.mentions.members.first()) return;
var embed = new Discord.MessageEmbed()
.setTitle(message.mentions.members.first().toString() + 'fcalled , ' + message.author.toString())
.setTimestamp()
.setImage('')
message.channel.send(embed);
}
@pseudo hare my embed is not working now
Any error message?
no
if(msg.member.hasPermission('KICK_MEMBERS')) {
Uncaught TypeError: Cannot read property 'hasPermission' of null
do what now
member is undefined
bot.on('message', msg => {
if(msg.member.hasPermission('KICK_MEMBERS')) {```
i think it sould be msg.author
@lucid prawn What is the command you run to check if it works?
bot.on('message', msg => {
if(msg.author.member.hasPermission('KICK_MEMBERS')) {```
is this discordjs?
Uncaught TypeError: Cannot read property 'hasPermission' of undefined
yes
and if i say js bot.on('message', msg => { if(msg.author.hasPermission('KICK_MEMBERS')) {
it says its not a function
give ur bot kick_members permission
it's msg.member
yes
author is a User
Uncaught TypeError: Cannot read property 'hasPermission' of null
oops havent used discordjs in quite a while lol
@pale vessel
is it a DM?
no
i fixed it
new problem
wait
no
aaa ill just make a mods array
this is annoying
repl is technically 24/7 free.
ok. does it work with discord.js?
aws has a free tier
repl is technically 24/7 free.
@solemn latch technically?
does it go offline sometimes or?
not that i am aware of
its just not an ideal playform due to the low ram and cpu power
var mods = {
"346100939297390613":true, //valurim
"608068786058428416":true, //Apple Master
"462020257071104010":true, //Pasta
"628020046941257738":true, //TwoDoritos
}
bot.on('ready', () => {
console.log(`${bot.user.tag} logged in successfully`);
});
bot.on('message', msg => {
if(mods[msg.member.id] === true) {```
heyyy again woo
Uncaught TypeError: Cannot read property 'id' of null
??
why does it get past that if statement
when the if statement is clearing erroring
🤔
wait
do errors not yield the script in js?
Is it true that Melania Trump is actually a man and their children are adopted russian orphans
client.on('guildMemberAdd', async member => {
console.log("hi")
const channel = member.guild.channels.cache.find(ch => ch.name === 'general');
channel.send("Welcome")
})
its a method
any errors?
no someone told me to do this https://media.discordapp.net/attachments/727242067201360042/775127832950341683/unknown.png?width=619&height=427
so i am gonna do it and try
it worked
Having this issue with my MongoDB, even though I've whitelisted it in Network Access
my error ```js
.setTitle(!message.mentions.members.first().toString() + 'called' + message.author.toString())
^
TypeError: Cannot read property 'toString' of undefined
at Client.<anonymous> (C:\Users\dogli\Documents\Discordbot\index.js:64:72)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\dogli\Documents\Discordbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\dogli\Documents\Discordbot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\dogli\Documents\Discordbot\node_modules\ws\lib\websocket.js:797:20)
my code
```js
if(message.content.startsWith(prefix + "call" )){
message.channel.send('Ur Making love');
}
if(message.content.startsWith(prefix + "call" )){
var embed = new Discord.MessageEmbed()
.setTitle(!message.mentions.members.first().toString() + 'called' + message.author.toString())
.setTimestamp()
.setImage('')
message.channel.send(embed);
}
@lucid prawn do message.members.members.first().user.username
instead of toString()
if im just storing data in a file as static, should I use a json file or should I just put it in a js file
ok
@lucid prawn for your code change var to const
@blissful coral the embed is not working
how to create bot in js?
are u a beginner?
@robust blade i have many other var embed = new Discord.MessageEmbed()
@lucid prawn oh
i meant "mentionable name"
how to create bot in js?
@quaint cairn
@lucid prawn You cannot mention users in the title
@lucid prawn No
Do not give people code
This code help you get started with your discord bot go to this website
https://pastebin.com/sPXPkh6K or https://pastebin.com/DxAMwfFd
update
///pls vote if this helps
///Btw i made this code
@quaint cairn
@lucid prawn ok
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@quaint cairn https://discordjs.guide
Ok
ok
how to create bot in js?
@quaint cairn this
Const Discord = require('discord.js')
Const Client = New Discord.Client
Client.on(' ')
And so?
New is not capitalized

const Discord = require(`discord.js`)
const client = new Discord.Client()
client.on(`ready`, () => {
console.log(`Bot online`)
})
client.login(`Token`)```
Starter code
Ok
const Discord = require(discord.js`)
const client = new Discord.Client()
client.on(ready, () => {
console.log(Bot online)
})
client.login(Token)
`
my embed is still not sending
Show code
I'm Brazilian but I use the translator here
if(message.content.startsWith(prefix + "call" )){
message.channel.send('Ur Making love');
}
if(message.content.startsWith(prefix + "call" )){
if (!message.mentions.members.first()) return;
var embed = new Discord.MessageEmbed()
.settitle(heyyy)
.setDescription(message.members.members.first().user.username + 'called' + message.author.toString())
.setTimestamp()
.setImage('')
message.channel.send(embed);
}
Because you are not putting heyyy in a string.
bot.on('guildMemberAdd',member => {
member.send(`Welcome to ${msg.guild.name}! The rules are as follows: \nRule1:\nRule2:\netc...`)
})```
is this the correct even name?
msg is not a value of client#guildMemberAdd event
member.guild.name is how you would get the guild name
@earnest phoenix go here it will help https://discord.js.org/#/docs/main/stable/general/welcome
oops i didnt mean msg lmao
i meant member
typo
but anyways
he didnt get the dm when he rejoined and i didnt get an erorr
Having this db issue, I put my IP in and everything but still doesn't work
make sure ur whitelisted
Because you are not putting
heyyyin a string.
@blissful coral
wym
make sure ur whitelisted
@blissful coral
Please learn basic js.
wdym?
Not you valurim
Talking to @raven urchin
@lucid prawn you need to do 'heyyy' instead of heyyy
I have it whitelisted
It has to be a string because heyyy is not a variable
@raven urchin attempt removing and readding it
Will do, brb
Mongo doesn't do that normally so I am not experienced with that issue
@blissful coral
my embed is still not sending
do u want to see what it doing
no error
bot.on('guildMemberAdd',member => {
console.log("Member Joined");
member.send(`Welcome to ${member.guild.name}! The rules are as follows: \nRule1:\nRule2:\netc...`)
})``` @blissful coral yeah the msg thing was a typo lol, ive been working with chat commands all day. Anyways, no errors when they join and the console doesnt log anything
bot.on(`guildMemberAdd`, (member) => {
member.send(`Hi`)
})
Make sure you have the GUILD_MEMBER intent @earnest phoenix
im confused on what u changed
o i c
do u want me to show u what the bot does
How many times am I gonna have to tell you that you have to make the title a string instead of a var because the var is not a thing
Still gives an error when I type in a command
weird
Could it be because I have the same database running on my other bot?
like this ? js .settitle('heyyy')
setTitle
still wont work 
ghostping op
@languid inlet can't really help you without the error and a code snippet
@solemn latch shhhh
rocky sorry for ping whoever you are
trying to
@lucid prawn Show your full code snippet of the embed and where you do <message>.channel.send(<embed>)
also I don't care about pings
if(message.content.startsWith(prefix + "call" )){
if (!message.mentions.members.first()) return;
var embed = new Discord.MessageEmbed()
.setDescription(message.members.members.first().user.username + 'called' + message.author.toString())
.setTitle('Heyyy')
.setTimestamp()
.setImage('')
message.channel.send(embed);
}
Put it in a bin
@blissful coral #development message
Try removing your return and see if it works
Throwbin is a website where you can store text online for a set period of time.
What is your error that you are getting
I don't know
Then I can't help you
I need a error to work off of
So that I can find the problem
how can I find a channel via id if the client has multiple shards, and send a message in it if it exists?
Like this:
TypeError: Request with GET/HEAD method cannot have body what does this mean? data is a dictionary with some parameters as key/value pairs
const res = await fetch("https://nekobot.xyz/api/imagegen", { body: data })
.then((r) => r.json());```
just like it says
but i need to pass parameters for the api
then idk tbh
<client>.shard.broadcastEval(`this.guilds.cache.get('${<guild>.id}')`).then(g => {
//Code here
})
// OR
//Inside of a async function
const getguild = await <client>.shard.broadcastEval(`this.guilds.cache.get('${<guild>.id}')`)
//returns the guild object```
@earnest phoenix
Sup
how can i reload a command on every shard
I’m using pm2 but the bot still goes offline when I turn off my pc
How can I make it stay online 24/7
Without never turning off my pc
vps
You buy a vps
- OVH: https://www.ovh.com/us/vps/
Starting at $3.35/mo for 1 core, 2GB RAM, 20GB SSD - DigitalOcean: https://www.digitalocean.com/
Starting at $5/mo for 1 core, 1GB RAM, 25GB SSD - Linode: https://www.linode.com/
Starting at $5/mo for 1 core, 1GB RAM, 25GB SSD - Vultr: https://www.vultr.com/
Starting at $2.50/mo for 1 core, 512MB RAM, 10GB SSD - Amazon(AWS) Lightsail: https://amazonlightsail.com/
Starting at $3.50/mo (first month free) for 1 core, 512MB RAM, 20GB SSD - Time4VPS: https://www.time4vps.eu/
Starting at €3.99/month for 1 core, 2GB RAM, 20GB SSD - VIRMACH: https://virmach.com/
Full Windows and Linux Desktop VPS starting at $7/mo and $1/mo respectively
ℹ️ This is a list of hosting providers, not a backing/support for them. You will need to make your own decision. All $dollar prices are in USD.
Is there any free ones I don’t want to pay
@earnest phoenix
Not really no
they are servers
is router hosting possible
Not really
routers often have under 50mb of ram
Kinda have to pay
Routers almost always have under 50mb of ram and it is already all being used by the network
@blissful coral it need to do this it was working now it just do ur making love
if you got a sick ass router with a custom os on it, yes 
^
Only fields and descriptions
@earnest phoenix I suggest you look itup
you upload your bots code to the vps, then run it
Need Filezilla, PuTTy a process manager and some other stuff
run it in a screen 
Bruh I’ll just keep my pc then
it's quite simple
^^
you just upload the code
that was did in title #development message
install te modules etc
Read what I said.
just like you would do on your pc
You cannot mention in a title
and then start it via pm2
It will show the <@!id>
ok
💩
guys i found a free vps
ibm
theres a paid verson
but theres also a free version
its probably bad but idc as long as it stays up
bruh a free vps sounds sketchy 
it always is
its not free
if it's not free you have to pay for it
For more than a century IBM has been dedicated to every client's success and to creating innovations that matter for the world
👍
looks legit ngl
it really deosnt
theres a lite version though
LOL wolfy genius !
thanks james !
so like this @blissful coral ```js
if(message.content.startsWith(prefix + "call" )){
message.channel.send('Ur Making love');
}
if(message.content.startsWith(prefix + "call" )){
if (!message.mentions.members.first()) return;
var embed = new Discord.MessageEmbed()
.setDescription(${message.mentions.members.first().toString()} called ${message.author.toString()})
.setTimestamp()
.setImage('https://ii.yuki.la/7/29/012c95f665ec8cc105e45d31e1eb347eb74bdfb603f0ab37a86392fff9d78297.gif')
message.channel.send(embed);
}
you can just send the whole object
@blissful coral
it will convert it into a mention
its literally an international coporation
@lucid prawn
real sketch huh
yes @earnest phoenix
🤦♂️

wolfy the emebed is not sending

why are you using 2 the same if statements??
your best with working with switch cases 
if (false !== true){
console.log("hello world")
if (false !== true){
console.log("hello world!")
}
}
like wot
which one is for bot hosting
amazon free tier
thats not an option
why would it be free????
which one is for bot hosting
think about it
i dont care
just
which one is for bot hosting
valurim if you know about vps then you should know the answer to that question
i dont know about vps
and i never said i did
The bot is doing this but it need to sended the embed @blissful coral
@earnest phoenix do u know the answr
Valurim lool my guess google basics in vps hosting and it will no doubt answer you question. Yes but this is for you to figure out or you wont understand my answer at all
i dont know how i google that
Bruh
hey google which one of these is for bot hosting
lol read them and figure out which one sounds like bot hosting, im not going to spoon feed you the answer when its already on your screen
its not spoon feeding its helping
spoon feeding would be asking for guidance the entire time
you clearly dont know
or you're just an asshole
Lol
ill take that as the first one
stop swearing!111!!!
Bruh i run my own network and know how to manipulate it to run my own projects lmao
then which one is it
"noT tEliNG YoU"
will be ur next words
Which one of those packages litterally tells you /defines bot hosting 
foundry
how was i supposed to know that
the word foundry literally sounds nothing like bot hosting
i was just guessing idk
maybe its speech to text
that was probably sarcsatic but u were right anyways
fine the answer is services -_- happy ?
oh
what
oh wtf
when u click services it opens like a million things
and discord bot isnt one of them
you can do anything with one
Bot hosting or anything along those lines
Bruh its not going to spell out "DISCORD BOT" you need to figure out which services will be suitable to run a discord bot 
Bot hosting or anything along those lines
@earnest phoenix
i mean, discord bots run anywhere nodejs runs on. and thats a lot of things
How use reactions on messages with Discord.js
it would probably run there, but may not be what you expect
wait i found on literally called Node.js
valurium your best with getting a blank vps and installing all of your bots dependencies instead of a premade vps , as some components within that vps may not include the libraries you need or they may be outdated. You can update all dependencies but its a pain xD
^
which this is ibm's vps lineup
https://cloud.ibm.com/gen1/infrastructure/provision/vs
How use reactions on messages with Discord.js?
whats a blank vps
nothings free long term
and you manually install all the dependencies and libraries you need to run your bot
youll pay one way or another
well, all of ibms stuff is paid in the long run
bruh im 14 and my parents dont even know i have discord
so dont use ibm if you demand free
i cant just be like
yo gimme vps
valurim you'll eventually need to pay for your own vps if you want your bot to last .. common sense xD
most parents are pretty cool spending $3 a month for kids who are excited to learn
then mow the neighbors lawn for $10 and get 3 months of vps 
trying to run a bot on a budget of almost nothing will not last, simple as that
¯_(ツ)_/¯
bruh ill just keep my pc on
does it hurt a desktop to keep it on 24/7
yes lmao
how
you can't keep your pc's running 24/7 it will run your system processes in overdrive if they dont have a daily restart
restarting takes like 1 minute
i can deal with that
just like how you can't function without sleep
ok, valurium do what you want lol
Sometimes ytdl won't play a song, it throws a "can't get video stream" error
Anyone have a fix?
retry to get it? 🤷♂️
maybe your being rate limited ?
No and no
youtube is pretty clear about ratelimits most of the time
lol i was just guessing xD
It's being thrown from ytdl and usually this doesn't happen
Before 4.0.1 it worked fine
Not really. For most PCs it doesn't really make a difference if you restart or not. Only part that generally matters with are storage devices like hard drives. If they aren't build for it they can get performance deterioration but even with most hard drives it would take quite a long time (over a month of continues runtime) for it to become actually noticeable. Actual long term deterioration usually will only happen if you run it in ways it wasn't designed to (high humidity or a place with a lot of vibrations).
my main concern about 24/7 pc running is the psu 🤷♂️
especially on prebuilt machines
i made my computer
did you get a good psu?

I have used prebuilt machines for decades and haven't had an issue but I do agree that prebuild psu's can be a point of failure.
bruh idk pc terms
power supply
If you made it you should have a part list somewhere? If not you could take off your cases side panel and just check it (model and manufacturer) on the power supply itself
Corsair?
yes
cant belive you kept a prebuilt for a decade and didnt replace the psu.
I get scared with a psu for 5 years even if its good
Should be fine then generally. Though I did have a fan fail on my Corsair CX 750M after a couple of years but I didn't do anything special 
it has a 5 year warranty
fan failure in a psu is a blessing in disguise. dead psus are scary
True
if ur using pm2 does discord have to be open or can it be off, but ur pc still on
my house got struck by lightning years ago, every electronic in the house died except my pc's.
bots have their own client
you dont need discord open
And I mean my original "gaming pc" was a prebuild HP Compaq from like 2008 that I ran for like 3-4 years still has the original PSU all these years later (today) and still runs fine. But anyway this is a bit off-topic.
Will server size effect my bot ultimately effecting my pc?
if your bot needs a lot of resources, yes it will slow down your pc
anything your bot uses, you wont be able to
99% the slowdown is member presences
It’s just 3 events
kick ban and member join message
Bruh how much is that rly gonna slow down my pc tho
🤷♂️ its impossible to say
You’re telling me a 100 line bot gonna slow down my pc more than my 50 60gb games
if they are both running together, any resources your bot uses your game wont have.
They're just saying that if your bot grows it could start impacting performance. Obviously it will different on the hardware to what amount but if it keeps growing it will keep eating up more system recourses.
Yeah I just checked
Currently my bot is 3 KB
doubt that’s going to effect anything
3kb can crash a pc

heck 100B can crash a pc
my bot ain’t running a while loop constantly
yeah, just saying size means nothing
I meant in terms of eating of resources
I know how to crash a pc in 11 bytes
start %0
%0
Actually, code size doesn't tell whether it's going to impact performance or not
^
Like, bigger code doesn't mean heavier code
with intents alone you can drastically change the performance of a bot.
Look at yandere simulator for example lul
what is an intent
i keep hearing that
do u mean like
the english word "intent"
or is that a js thing
its the events you receive from discord
mainly
Intent is something your bot "wishes" to use
You tell discord what you're gonna use and they send you the payload
bot.on(`guildMemberAdd`, (member) => {
console.log("Member Joined");
member.send(`Welcome to ${member.guild.name}! The rules are as follows: \nRule1:\nRule2:\netc...`)
})```
the less you have the less you get.
when they came out, i cut my bots network usage down almost 90%
u mean like that
Like, let's say I go to a fast food
you can have an intent without having an event
you can have an event without having an intent.
"i want to eat a cheese burger and drink a pepsi"
So I'll get exactly those two things
Those are my intents
yeah i know what the english word means
I'll not get a potato bag because I've not declared my intent for that
Same with discord
You'll not get voice status if you don't ask for it during initialization
That init command is a bit weird
ok but why does it say it doesnt exist
Like, if you just do start index.js won't it work?
What it's not finding is the name=index.js probably
Like, it's searching for some script called index.js inside index.js ig
uh
Try without name param
Start index.js
Without name param
That ain't the issue probably
The name?
yeah because
i did start index.js
but the file name is index.js
and the type is JS
do you have your package json and your bots dependencies ?
So index.js.js?
so it should be index.js.js
Lul
yeah
Hidden extensions
hey
anyone knows
me?
why appears this
Otisbotfinal\commands\mute.js:22
await (user.roles.add(role.id).catch(err => message.channel.send(Algo salio mal: ${err})))
^
ReferenceError: await is not defined
Because that's not how you use await shiro
._.
await (user.roles.add(role.id).catch(err => message.channel.send(`Algo salio mal: ${err}`)))
// await is not used like this
await user.roles.add(role.id) ... // finish the statement
i dont know if you can use await on roles.add but probably
oh
its saying its not defined cause
so i delete the
function (param1, param2)
function(param1, param2)
so you would remove the ()
extra
Wouldn't it be better to handle everything inside .then tho?
await user.roles.add(role.id).catch(err => message.channel.send(Algo salio mal: ${err}))
^^^^^
SyntaxError: await is only valid in async function


Guides to understand promises:
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already-created promises, this guide will explain consumption of returned promises before explaining how to create them.
That last one is kinda cute embed
Removes embed
idk
Also, if if if if

Use a switch case
oh thanks
Yeah, GUILD_PRESENCES
You cannot retrieve online status without that intent
Btw, yellow alert here
No
It's just the hard-coded prefix
Some people will get a bit uneasy without being able to change it
Although I guess otis! is quite unique
switch (somevar) {
case "a":
//do this
break;
case "b":
//else do this
break;
case "c":
//or this
break;
default: //if all else fails, do this
}
Case being your ifs
And somevar being user.presence.status

so in my case will be this
switch (ESTADO) {
case "dnd":
//do this
break;
case "idle":
//else do this
break;
case "offline":
//or this
break;
case "online":
break;
default: //if all else fails, do this
} ```
Almost
Instead of ESTADO it'd be user.presence.status
And below each case you'd do ESTADO = something
Think of switch-case as chained ifs
Like "with this var, check which case is true, then do something"
No, i mean, did you declare the variable ESTADO before assigning a value to it?
Like let ESTADO?
Ah
Just remove the default branch, I just added it there as example
It'll error if you do nothing inside it
Oh ok 👍
Nonetheless, you still need presences intent to be enabled
But how
Else all you'll get is offline status
It's in the discord developer dashboard
Note that you'll need to verify your bot if you plan to have more than 100 servers
When you apply for verification, remember to state that you'll need to use presences intent
Ok 👍
@client.command()
async def members(ctx):
member_count = len(ctx.guild.members)
true_member_count = len([m for m in ctx.guild.members if not m.bot])
bot_count = member_count-true_member_count
await ctx.send(f"**Total Members:** {member_count}")
await ctx.send(f"**Users:** {true_member_count}")
await ctx.send(f"**Bots:** {bot_count}")
In a large server, 150+ people, it says Total Members: 1, Users: 0, Bots:1. Why?
No cache probably
your using cached members
cached?
Yep, most libs will cache members as they trigger events
wdym cached?
Except if you have guild_members intent, in which case some libs will cache everything on start
things stored in memory
i have the intent
ok lemme walk you through what i did for intents
i enabled it on Developer Portal
and then
i added it in my code
intents = discord.Intents.all()
intents.members = True # this is redundant, all intents are already enabled
Ah nvm
ok
Sorry, don't know how discordpy works, maybe someone else here could help u
Nonetheless cache is your issue, you need to retrieve real member count
how would i do that
nah, python is a mystery.
o ok
Hey @lyric mountain
I did this
Its ok?
And for the await thing i turned on this
Its ok?
@earnest phoenix that's actually a quite clever way to do it
Haven't thought of using objects for that
Yes, that is the intent you need
You have an extra bracket there tho
Yeah but is from an other bracket
Ah ok
Yw shiro
module.exports = {
name: 'kick',
execute(message, args){
if(message.member.permissions.has("KICK_MEMBERS")) {
message.channel.send('you can kick people');
}
}
}
can someone tell me whats wrong with this?
its just supposed to return the message you can kick people if they have perms
oh
im eventually going to make it kick people but for now i want to get it to wrok
thanks
i have a functional kick command i will check
thanks
if (command === 'kick'){
client.commands.get('kick').execute(message, args).catch(console.error);
}
thats what actually initiates the action too
no its just going to be -kick
Can someone help me?
https://gyazo.com/e690e3e1f575e7e23354f72a27665692
you need to
because i just want to see if the perm check works
What's the error tony?
@analog onyx async (client, message, args, msg) => {
like this
async (client, message, args, msg) => {
if(message.content === ("test")){
message.channel.send('test');
something like that but with your command
Put a Console.log inside that command to see whether it's even going inside the perm check
Maybe it's not entering it
see i thought of that but nothing is sent to cosole
It makes a role
if(!message.guild.me.hasPermission('KICK_MEMBERS')) return message.channel.send('you cant kick people')
if(message.guild.me.hasPermission('KICK_MEMBERS')) return message.channel.send('you can kick people')
something like this @terse stirrup
Err, no
😭
Lul
Issue is the code isn't reaching inside that if
Also, else would be better in your example
can i call someone to ss for a sec?
I can't rn sorry
its fine
Let me retry
so tony
i can
so call me if you want but
i cant say nothing bc im not that good on english
its fine ill call in 1 sec lemme test this quick
how i can show in a let a value of a mysql table
a what now?
what
translation: "how do I define a variable from a value inside of a mysql table"
@opal plank y it no work >:ccccccc
if (true) {
true = false
} else if (false) {
false = true
}
/joke
@thick gull you clearly forgot a ; you dummie
just add 2 ;
nah jut 2
sadly I think that's valid JS
it’s not
message.author.username
Cannot read property 'username' of undefined
how do i fix this
Can't do much with that information
sounds like your message isn't actually a discord.js message object.
if(message.content.startsWith(prefix + "hug" )){
message.channel.send('**OMG YOUR HUGGING**');
}
if(message.content.startsWith(prefix + "hug" )){
var embed = new Discord.MessageEmbed()
.setDescription(message.mentions.users.first().username + ' huged ' + message.author.username)
.setTimestamp()
.setImage('https://gifimage.net/wp-content/uploads/2017/06/anime-hug-gif-11.gif')
message.channel.send(embed);
}
Cannot read property 'username' of undefined
@rustic nova is that ok
fairly certain you loking at the wrong place
@lucid prawn
this is likely returning undefined
cuz there isnt a mention
ok how do i fix it
why you not put first message.author.username and after message.mentions.users.first().username
ok i will fix that
how do i make my bot online 24 hours?
oe
I can put my bot 24/7 on my pc
But
I have to mantein the pc On all the night
yea
Yeah

how i fix that
[Python] I'm having trouble with dependency conflicts (aka one thing relies on X version, but another thing relies on Y version). From the looks of it, pip doesn't download the other version some other library would use, which causes conflict.
To illustrate, I'm using discord.py. It relies on the aiohttp library, which can use any version between 3.6.0 and 3.7.0. The latest version of aiohttp is 3.7.2, which I'd like to use in my source code. How would I resolve this?
@earnest phoenix you can't use async in that context
What are you trying to do exactly.
@earnest phoenix thats.... not how you run async code....
@opal plank how do I stay motivated
ok
Lol
I stay motivated to code by taking new challenges
erm, im not streaming on twitch
yes
cuz it looks like you wanna see cursed code
imma share it on myy private server
too many eyes here
👀
ok
Lol
Hi so im making a clear command for my bot but for some reason it gets rid of the messages, but the message saying it has deleted the message is not deleting afterwards, what should I do?
heres the code: `else if (command == 'clear'){
if (!message.member.hasPermission("MANAGE_MESSAGES") || !message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You cant do that Random Memer... Sorry!")
if (isNaN(args[0])) return message.channel.send("Please put a number that works!")
if (args[0] > 100) return message.channel.send("I dont have enough power to do over 100, but it has to be less than 100, sad")
if (args[0] < 1) return message.channel.send("HA less than 1 is not worthy of me power!!!")
message.channel.bulkDelete(args[0])
.then(messages => message.channel.send(`Deleted ${messages.size} messages like u asked`))
.catch(() => message.channel.send("Sorry but I cant do it for some reason :("))
}`
oof i put it in wrong on discord
Because you never actually delete it.
First you purge the messages, then you say the messages have been deleted, and that's it.
If you want to delete that message, resolve the promise then delete it. js message.channel.send(`...`).then((msg) => msg.delete(...))
ok thanks!
So for the ```.then((msg) => msg.delete(...)) its causing this error
oh wait
I think i solved it
Solved it
@sudden geyser you can try manually building after cloning the repo and editing the dependencies
ehh, that's not very elegant. I'd need to jump through a few hoops having a different version of the lib. Though, I did just find Pipenv and it looks like just what I was looking for.
Right, I keep forgetting about it 😂
how do i remove the commas again? i forgot
.join()?
ah yes
Right, I keep forgetting about it 😂
it's alright. though I feel all my struggles with pip vanishing
is refreshing my bot's custom status every 15 seconds API abuse?
I think the current limit is 5 per 1 minute (60 / 5 = 12), but there's no defined limit as it's dynamic. You should set it to something reasonable, like 1 per minute.
ah okay, thanks!
I think rate limit is about every 4 seconds, so 2 minutes should be fine.
thanks!
and taggedMember is message.mentions.members.first()
looks like that member isn't cached, that would do it
you can do something like ```js
if(taggedMember.partial) taggedMember = await message.guild.members.fetch(taggedMember.id);
If I recall how partials work correctly
eh okay i'll try that, thanks!
ok im dumb, taggedMember was message.mentions.users.first() so taggedMember.id worked.
thanks anyways
Is anyone well known of typescript here?
could you explain the issue you're having with ts?
ERWIN
So... I have extended the Client, how do I get typings of my extended client accessible within <Guild | Member | etc>.client.myProp
bcoz <Guild>.client still referencing the original Client, and gives error for .myProp
Hey @sudden geyser
Does someone know how to do this like idk how i need some help please :> i just follow orders
just for reference im hosting my bot on my pc
will having a warnings table cause preformance issues
what i mean by that
if i did like, "/warn bob"
it adds him to a dictionary with his amount of warnings
"Bob'sUserId": 1
also, if i make changes to the bot it will like reset the table
so how can i keep the table's values?
use a db
db?
database
naah, not much. Its just a normal process
There's a bunch of technologies out there
djs doesn't provide any databases, it just an api
is there any documentation on it
yes see the guide. There's a topic on it
bruh
is executed edit possible in any way?
so like if i did Array.insert() during runtime
it would actually be part of that array, while editing
if that makes sense
which language u using?
js
so u want to insert values into an array, at runtime? (When bot is online?)
but then it save those inserted values outside of runtime
maybe like insert them into a json file or something
ooh, u want to save the values, so when u restart the bot. The values should already be there. Am I right?
yeah
That's what databases are for
ah
read the guide
@earnest phoenix https://github.com/Belphemur/node-json-db
If you're new to all of these. I recommend you start with this package
const servers = [""]
const embed = new Discord.RichEmbed()
.setAuthor("Server Status")
fetch('https://api.nitrado.net/services', {
method: 'GET',
headers: {
'Authorization': `Bearer ${nitrapiToken}`
}
})
.then(res => res.json())
.then(json => {
json.data.services.forEach(async (el) => {
let stat
if (el.status === "active") stat = "✅"
if (el.status === "suspended") stat = "❌"
const obj1 = serverList
let obj = obj1[el.details.address]
servers.push(`[${stat}] ${obj.name}`)
});
})
console.log(servers)
let pve = servers.filter((s) => s.includes("PvE"))
let pvp = servers.filter((s) => s.includes("PvP"))
let duos = servers.filter((s) => s.includes("Duos"))
let tribes = servers.filter((s) => s.includes("Small"))
let events = servers.filter((s) => s.includes("Events"))
embed.setAuthor("Server Status", client.user.avatarURL)
embed.setColor("PURPLE")
embed.addField("PvE servers:", pve.join("\n\n"))
embed.addField("PvP servers", pvp.join("\n\n"))
embed.addField("Duos servers", duos.join("\n\n"))
embed.addField("Small Tribes servers", tribes.join("\n\n"))
embed.addField("Events", events.join("\n\n"))
message.channel.send(embed)
Someone knows why the bot is giving me the error that the addFields could not be empty, apparently the bot can't make the .push to the array





