#development
1 messages · Page 1222 of 1
wrong mention, mb
lol
i still haven't got it working
Add a break also after the you don't have the crafting table
k
What break does is it stops the loop
let settings = await Guild.findOne({
guildID: guild.id
});```
yeah
what is guild?
yay
the schema
show the code
let settings = await Guild.findOne({
guildID: ——> guild.id <——
});```
let settings = await Guild.findOne({ guildID: guild.id <—— });```
@digital ibex what should it be becuase it cant be message.guild.id which is what would normally be used

it can be whatever u want, just as long as its unique
what's wrong
@sweet kestrel
nah
and why cant it be the servers id?
a real bruh moment
it needs to be the guild id
um.. yes?
becuase its not specific
but what is guild ?
guild where
let settings = await Guild.findOne({
guildID: ——> guild.id <——
});```
i don't get it, what is wrong with that
just don't accept dm commands
@digital ibex how would i get the guild id in that context?
I mean, is suppose to run the embed messsage and the await ctx.send("Opening crafting table...", delete_after=3)
isn't it?```
@radiant kraken
it cant be
why?
now is just running the else command, I have a crafting table, so it should not run the else command
it needs to be in the message event
no it doesn't
bruh
the upper part
true

but
maybe 🤷
I mean, is suppose to run the embed messsage and the await ctx.send("Opening crafting table...", delete_after=3)
isn't it?```
@sweet kestrel u added a return after the opening crafting table, just remove it
unless discord.js has parsed that shite
yeah
how r u importing member?
@digital ibex Module.exports = async (client, guild, member) => {
show ur event handler
@sweet kestrel it should've send the embed tho
fs.readdir('./events/', (err, files) => {
if (err) return console.error;
files.forEach(file => {
if (!file.endsWith('.js')) return;
const evt = require(`./events/${file}`);
let evtName = file.split('.')[0];
console.log(`Loaded event '${evtName}'`);
client.on(evtName, evt.bind(null, client));
});
});
ok

sad
@radiant kraken help noooooooooo
it's probably something to do with ur db afaik
😦
in this case, “guild” is the member, so if u do guild.id, it’ll return the member who joined, their id
bruh
member isnt a thing
yeah
I think you breaked the if statement
😦
noooooooooooooooo
noooooooooooooooooooooo
noooooooooooooooooooooooooooooooo
bruh
TypeError: Cannot read property 'roles' of undefined
its endless
let role = guild.roles.cache.find(r => r.name === settings.autoRole);
member.roles.add(role).catch(console.error);
I think you breaked the if statement
what do you mean by breaking the if statement ?
yes it should've stopped after the if statement
what is guild?
should that also be guild.guild
what break does is that it exits the loop
yh
or replace break with return, which exits the function entirely
Dm me if you can program c#
@digital ibex nope.
nope?
let role = guild.guild.roles.cache.find(r => r.name === settings.autoRole);
like that?
idk try it
i did
no work
;(
at least the console is logging autoRole: 'Member',
i just need to figure out how to give the member the role
let role = member.guild.roles.cache.find(r => r.name === settings.autoRole);
maybe member.guild
nope
I am doing it like that for message event.
let role = message.guild.roles.cache.find(role => role.name == "test");
no
what no?
it wont work like that
its not a message event
its guildMemberAdd
so message is undefined
ok
im trying to auto role
but pulling the role from my database
so giving a member a role in guildMemberAdd
and this didnt work? member.guild.roles.cache.find(role => role.name == "member");
You could also just create the role and then assign it, so it will work on all guilds. If your idea with the database doesnt work
TypeError: Cannot read property 'guild' of undefined
the database is not the issue
it is able to find the data from the db fine
it is just applying the role
member.guild.roles.cache.find(role => role.name == "member"); logs TypeError: Cannot read property 'guild' of undefined
try this just for fun ok?
verified = await member.guild.roles.create({
data: {
name: "member",
color:"black",
permissions: [],
position: member.roles.highest.position + 1
}
})
let role = member.guild.roles.cache.find(role => role.name == "member");
message.member.roles.add(role)
Just to test it out, if "let role = member.guild.roles.cache.find(role => role.name == "member");
because for me it worked, if I remember correctly. I dont have ide right now, to test it.
ok
btw i cant do message.member.roles.add(role)
TypeError: Cannot read property 'guild' of undefined
you deleted it
thats what i am using?
it is the same thing
just with a handler
<client>.on('guildMemberUpdate', (oldMember, newMember) => {
try{
const removedRoles = oldMember.roles.cache.filter(role => !newMember.roles.cache.has(role.id));
if (removedRoles.size > 0) console.log(`The roles ${removedRoles.map(r => r.name)} were removed from ${oldMember.displayName}.`);
const addedRoles = newMember.roles.cache.filter(role => !oldMember.roles.cache.has(role.id));
if (addedRoles.size > 0) console.log(`The roles ${addedRoles.map(r => r.name)} were added to ${oldMember.displayName}.`);
}catch(err){console.log(err)}})
what does console log says?
use this event as well
to get more information
it doesnt matter? You get more information tho?
The syntax to add members when they join your guild is right.
yes, it is just an other event
idk, as you see, collection.roles.add works. They use IDs tho..maybe you can try that with an Id?
why does this not work when i say "!ping"?
client.on('message', message => {
if (message.content === '!ping') {
// send back "Pong." to the channel the message was sent in
message.channel.send('Pong.');
}});
what does the rest of your file look like?
one sec
client.login('${token}');
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
{
"prefix": "!",
"token": "MY TOKEN",
"meaning_of_life": 42,
"passwords_array": ["please", "dont", "hack", "me"],
"secret_passcodes": {
"bank": 1234,
"home": 4321
}
}
client.on('message', message => {
if (message.content === '!ping') {
// send back "Pong." to the channel the message was sent in
message.channel.send('Pong.');
}});
move client.login to the bottom
ok
lol
client.login() must be bellow const client = new Discord.Client();
you cant really put json formatting into a js file
yeah
you're gonna wanna make a file called config
also this here
{
"prefix": "!",
"token": "MY TOKEN",
"meaning_of_life": 42,
"passwords_array": ["please", "dont", "hack", "me"],
"secret_passcodes": {
"bank": 1234,
"home": 4321
}
}
change to
let object = {
"prefix": "!",
"token": "MY TOKEN",
"meaning_of_life": 42,
"passwords_array": ["please", "dont", "hack", "me"],
"secret_passcodes": {
"bank": 1234,
"home": 4321
}
}
and require it like it says
at least make it into a object
nah
thats too complex
add that into a file and save it as config.json in the same directory
and then add const config = require('./config.json'); to the top of your main js file
do what seasnail says, but if you want to keep that in your file, change it at least into an object
also you can delete everything other than prefix and token lol
idk where you downloaded that from but its useless
this doesnt work
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
{
"prefix": "!",
"token": "MY TOKEN",
}
client.on('message', message => {
if (message.content === '!ping') {
// send back "Pong." to the channel the message was sent in
message.channel.send('Pong.');
}});
client.login('${token}');
ofc not
ok
add that into a file and save it as config.json in the same directory
and then add const config = require('./config.json'); to the top of your main js file
so...
do this
ok
and put your actual token
ik that
in the " " after token
he did this
client.login('${token}');
you didnt define token as a veriable.
when you did what seasnail said change this part into
client.login(config.token);
oh yeah lol
yeah
the whole thing
it has comments and shit
imagine copy
also
hello Ben
you have been typing for a very long time
feel free to hit enter
LMFAO
@open oracle bruh, read the discord.js guide before you do a bot xD
we noticed
its not really that easy
well
it can be
but you will run into a LOT of issues if you dont even understand basic js
bruh.
my bot was declined for a second time because it could be used to abuse the api. what type of rate limiting do i need for this command?
!h 2v2v2v2 xbox halo reach. this command creates 4 channels for the 4 teams. My bot originally allowed any number of teams and there was no rate limit to the number of commands that could be entered. I limited the number of teams to 12 and put in a rate limit to the command as requested by the mod who declined the bot. after a month the bot was just denied again today. i talked to the mod a bit, but never got a clear answer about how to rate limit this in an effective way. how should i rate limit this command?
can someone spam this command
there is a 5s cooldown
my idea is to have these rules numberOfApiCalls <= 12; cooldown = numberOfApiCalls * "5 seconds";
client.on('guildMemberAdd', member => {
try{
let role = member.guild.roles.cache.find(r => r.name === 'Member');
member.roles.add(role)
}
catch{
console.log(Error);
}
});
@charred geyser this is what I use for a server and this works for me.
I was looking on my ide to check if there is something else, but there isnt..your problem is still not solved right?
i just want to have a solid answer before i submit my bot and wait a month
@charred geyser this is what I use for a server and this works for me.
I was looking on my ide to check if there is something else, but there isnt..your problem is still not solved right?
@midnight blaze from this i got[Function: Error] { stackTraceLimit: 16 }
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', message => {
if (message.content === '!ping') {
// send back "Pong." to the channel the message was sent in
message.channel.send('Pong.');
}});
client.login(config.token);
```this doesnt work
is node supposed to magically know what config is
and then add const config = require('./config.json'); to the top of your main js file
@charred geyser
@midnight blaze from this i got [Function: Error] { stackTraceLimit: 16 }
for your code
Idk, it works for me 🤔
🤷
try catches are expensive
why not just simply check if you can add the role in the first place instead of catching errors when it fails
TypeError: Cannot read property 'guild' of undefined
someone knows how can i put the circle next to the text? (html)
https://i.imgur.com/rRTObuR.png
Code: ```html
<div id="preloader">
<div class="loading-area">
<div class="banner">
<h1 class="animate__bounceInDown">Suggestion is loading... <div class="lds-ring"><div></div><div></div><div></div><div></div></div></h1>
</div>
</div>
<div class="left-side"></div>
<div class="right-side"></div>
</div>
I only added those so he can catch the error messages 🤔
ah
me?
y
const Guild = require('../models/guild');
const mongoose = require('mongoose');
const Discord = require('discord.js')
module.exports = async (client, guild, member) => {
const Guild = require('../models/guild');
let settings = await Guild.findOne({
guildID: guild.guild.id
});
let role = member.guild.roles.cache.find(r => r.name === 'Member');
member.roles.add(role)
};
@ember lodge use a span, or a more "proper" way is to align with a css flexbox
you can ignore the settings bit for now
ok thxs
that is just for the db
bruh this is so broken
ill try it in my main js
bruh
it works as a seperate thing in bot.js
just not with the event handler
@Chrøma#1711
wdum @midnight blaze
what are the rules for rate limiting discord api calls?
client*
which endpoint?
@proven lantern how about you join the discord server for that? API
https://discord.com/developers/docs/topics/rate-limits @proven lantern
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
i know what the rate limit is @midnight blaze
or that
just ask there your questions
why not here
10
but my bot is getting declined and i am rate limiting users
ReferenceError: guild is not defined @midnight blaze
i might just use it not in the event handler lol
yes
@charred geyser yeah, just use it on your main. It doesnt matter too much after all
what are the rules for rate limiting api calls made from the bot?
my bot has been denied twice now. i added the rate limiting rules they asked me to but it was declined again for the same reason
now its not working :/
@charred geyser xD but it worked before
i know
lmao
bruh
now it is giving me
ReferenceError: message is not defined
ok i got it working
and with the database!!
nice
hi
this is a part of my index.js that i just added
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
const lol = timeLeft / 60;
return message.reply(`please wait ${lol.toFixed(1)} more minute(s) before reusing the \`${command.name}\` command.`);
}
}
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('lol dude that command doesn\'t exist');
}
and im getting this error
TypeError: Cannot read property 'execute' of undefined
ok now why is this timer not working
lol
let timeout = 3.6e+6
let amount = Math.floor(Math.random() * 900 + -100)
let timer = await db.fetch(`timer_${message.author.id}`);
if (timer != null && timeout - (Date.now() - timer) > 0) {
let time = ms(timeout - (Date.now() - timer));
message.channel.send(`You can only work again in **${time.hours}h ${time.minutes}m ${time.seconds}s**`)
}
this isnt workinggg
i dont see anything wrong here
oof
what
wdym
its for this line
command.execute(message, args);
but it works fine everywhere else
How to generate a server invite link discord.js
d o c s
N O P L Z
Docs are kind of gay
coding a bot without docs is kind of gay
just use botghost like me, no coding skill required 😎
Bruh botghost is ass
How do I check if a number is NaN in JavaScript? NaN === NaN and NaN == NaN both returns false for some reason.
== is equalizing i gues === is used to check
== checks for value and === checks for value and type
NaN is defined as a number so idk how should i check if a number is NaN
nvm i found the isNaN() function 😅
i think you can just check for message.guild
btw why do you want to check for the guild’s id lol
just check for the channel type i guess?
wdym
lol
So, basically. I am a dumbass in coding because I am learning it.
@vale garden bruh, I am learning it. I really don't know it. I am not a master in coding like you guys.
I started it a week ago. So, Just get it. 😂
Python?
hi
oh kk
btw how do you find the logo for a server
lol
i thought message.guild.icon would work
What lib
me?
yeah
js
idk then
message.guild.icon works, it returns the hash of the guild's icon
use the method if you don't want to construct the url yourself
@vale garden it works it just updated ti iconURL IN V12
It was iconURL in v11 too, it's just a method now
But it worked as icon in v11 for me wth 🤔
It also works as icon in v12, this return a string of the icon's hash, the method just constructs a url to the icon
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
const lol = timeLeft / 60;
return message.reply(`please wait ${lol.toFixed(1)} more minute(s) before reusing the \`${command.name}\` command.`);
}
}
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('lol dude that command doesn\'t exist');
}
?
@earnest phoenix can you explain the issue that you are experiencing with errors, your expected and actual output rather than pasting a bunch of code. Please also use code blocks:
```JS
// code here
```
Stupid thing don't work I added a index.js and it isn't working at all
ur bot?
Stupid thing don't work I added a index.js and it isn't working at all
@earnest phoenix please don’t say it isn’t working. We need the following things to help you:
- your code ✅
- expected output ❌
- actual output ❌
- any errors in the console ❌
CODE: https://sourceb.in/ / https://hastebin.com/
ERROR: (provide screenshot)
EXPLANATION: (blah blah)
someone pin that maybe?
idk
if peeps need help with their code ig
¯_(ツ)_/¯
people like using vps's and bot hosts to host their bots but me, i dont use a bot host or a vps
length of guild's channels property
nvm
@vale garden #Message.guild return guild not guild manager
so you can just use .channels
wat
message.guild.channels
^
i got it working by using message.guild.channels.cache.size
Why use the js in keyword (any context)
please read docs
in? you mean "guilds" in message.client?
for example
or for in?
@vale garden read docs https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=mfaLevel
I just read the docs 
kk
nOt yOU
dud
firefox
I read those docs
hi
hi
hi
{ name: "Server Name", value: message.guild.name, inline: true},
{ name: "Server Owner", value: message.guild.owner, inline: true},
{ name: "Server Description", value: message.guild.description, inline: true},
{ name: "Server Region", value: message.guild.region, inline: true}
btw
here
Hm what are you tryna do
the first 3 fields are on 1 line
u cant change it
only 3 each line
like 1st 2 on the 1st line
Discord manages it
and next 2
4th goes another line
oof
This is so sad
lol
😩
😶
oof
Once Tim is online I would request him to say - My dad works at discord
const prefix = 'bow'.toLowerCase() am i doing it right?
b-but it's already in lowercase
so const prefix = 'BOW'.toLowerCase()?
Pointless
Might as well go into a constant .toUpperCase().toLowerCase() loop
prefix = 'bow'
if message.content.toLowerCase().startsWith
Yea i use a handler so no message.content.startsWith()
Wait hold on i got a idea for that
Brb
done it worked
ty all
apparently my interval status for my bot doesnt wanna work
oh wait
it works now
strange
hi
how do i get the user whos message has been collected
im tryna make a 4 player card game
oof
most likely from how your message.js or commands.js is set up
also
im too lazy to look back at my code, albeit i copied and pastad it into a sourcb.in file
does this look ok. ik it isnt but i want everyones opinion
its an experimental command as of rn
how do i get the user whos message has been collected
@vale garden collect.on takes a callback function and the first parameter is a Message class of discord.js
Why i am getting this error ?
oi
`let invite
if (invites.size > 0) {
invite = invites.first() // Invite Exists
} else {
let channelID // Invite does not exist. Create one.
const channels = message.guild.channels.cache
for (const c of channels) {
const channelType = c[1].type
if (channelType === 'text') {
channelID = c[0]
break
}
}
const channel = channels.get(message.guild.systemChannelID || channelID)
invite = await channel.createInvite()
}
bumpLogic(client, message, row, invite)
lastDate[message.guild.id] = now
}).catch(console.error)
})
}`
Ur invite command sur
@earnest phoenix ARE YOU sure you are entering correct auth
thanks @supple oriole
:D
:D
-bots 587663056046391302
not here ;-;
Yes

Which auth do you mean
and @earnest phoenix if this related to top.gg api
#topgg-api
wtf
webhook auth doesn't return any errors
🤐 cool
Can some one help me?
If someone vote my bot then he will receive a coins
Is this code is right?
hi
does anyone also now how to collect like 4 messages from 4 different people at the same time
like i have 4 filters
but idk how to collect all of them at the same time
or together to be exact
@earnest phoenix Yes, you are running the webhook but did you make sure the port 5000 is actually open in your router settings?
lol
that's not smth to lol about
wtf is wronf with you

Developers didn't made video on it
wut
Developers didn't made video on it
@earnest phoenix yes we did

I mean, there's plenty of tutorials on how to open a port
what even is a port
surfing through the internet and sailing on ships through ports 
In computer networking, a port is a communication endpoint. At the software level, within an operating system, a port is a logical construct that identifies a specific process or a type of network service.
An unique value appended to the IP/domain address
nice
Just help me in vote
: (
@earnest phoenix we can help with the dbl shit in #topgg-api we can't tell you how to give coins for voting since we dunno how your code works
yeah dbl shit
You're not being helpful at all
uhhh yeah but i never even tried to anything with the api so
@earnest phoenix Are you hosting the webhook on a VPS
Nope
80 too
skype loves to steal 80
btw if you're gonna use the webhook on a VPS with .env files go for process.env.PORT cuz most VPSs default to the PORT variable in env files when doing http shit
huh
a vps doesn't care what you run on it
it doesn't care about your .env file
It's certain frameworks/websites that care about .env
With a VPS you choose the port yourself

@earnest phoenix What the fuck are you on about?
Can you not spread false info!?
is there a prefix discard command when the bot is tagged
guys i have an error with my main bot file with the mongo db code:
TypeError: User.FindOne is not defined
@cinder sandal Sequelize ?
read the title of the issue, mongo db
yeah mb sorry MongoDB use models?
I think the problems are there
also the issue is in my main.js file
// export
module.exports.User = User
//import
const db = require("./data/user.js")
db.User.findOne()
if my memories are good
i have them imported in the main.js file like that:
global.User = require('./data/user.js')
is it wrong?
global?
did i exported it wrong or no?
i edit my message look
can i do const User = require('./data/user.js')
it is better to give another name to your constant so as not to confuse them
Anyone wanna be distracted
This is #development
@thorn spruce now it gives TypeError cannot read property 'FindOne' of undefined
i really should not use any databases and not make economy commands they give only errors....
let user = DBModules.User.FindOne({ guildID: message.guild.id, userID: message.author.id });
let guild = DBModulesGuild.Guild.FindOne({ guildID: message.guild.id });
if (!user) {
User.create({ guildID: message.guild.id, userID: message.author.id});
}
if (!guild) {
Guild.create({ guildID: message.guild.id});
}```
if i remove DBModules and define User it will send an error even without defining it
i'm making a discord bot dashboard how would i go about saving data?
you know that's not true
TypeError: User.FindOne is not a function
hwo to fix it?
code:
let user = User.FindOne({ guildID: message.guild.id, userID: message.author.id });
let guild = Guild.FindOne({ guildID: message.guild.id });
if (!user) {
User.create({ guildID: message.guild.id, userID: message.author.id});
}
if (!guild) {
Guild.create({ guildID: message.guild.id});
}```
then async it
exports.run = async (client, message, args) => {
//code, this depends on your command handler and how you set it up in your index.js
}```
my command handler is that
const args = message.content.slice(process.env.PREFIX.length).trim().split(/\s+/)
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
if (!command) return;
if (command .guildOnly && message.channel.type === 'dm') {
return message.channel.send('You can\'t use that command in DMs!')
}
if (command.args && !args.length) {
let reply = `Wrong Command Usage!`;
if (command.usage) {
reply += `\n Command Usage: \`${prefix}${command.name} ${command.usage}\``;
}
return message.channel.send(reply);
}```
where i put it
is that your index.js 
so you don't have a command handler?
i have
if (message.author.bot) return;
client.nodb = (user) => console.log(`[DataBase] the user is not in the database.`);
let user = User.FindOne({ guildID: message.guild.id, userID: message.author.id });
let guild = Guild.FindOne({ guildID: message.guild.id });
if (!user) {
User.create({ guildID: message.guild.id, userID: message.author.id});
}
if (!guild) {
Guild.create({ guildID: message.guild.id});
}
// prefix
if (message.content.indexOf(process.env.PREFIX) !== 0) return;
// const args = .. etc```
If it shows invalid user does it mean not has been declined??
If it shows invalid user does it mean not has been declined??
@strange nacelle bot*
send your full index.js and bin it pls
btw js is case sensitive
just figured it out
ok
i need to change client.on('message', message => {
to
client.on('message', async(message) => {
i don't have any commands in main.js
because i have a command handler
to avoid the main.js file to be big
yeh thats what most people use
adding async gives many unhandled rejection warnings
then only add it to your 1 command
well you probs will need it if your bot gets big
it only gives bugs etc. quick.db was more stable but it's trash
catch the errors then lol
mongodb is a complex database system, it requires some knowledge to be able to use effectively
they're most likely outdated or you didn't follow them correctly
most likely outdated
const example = "examplestring";
How do i make this not case sensitive?
what do you actually want to do
Make my bot prefix not case sensitive ;-;
you can transform both strings (to lowercase / to uppercase), however that will have an impact on performance
both as in, prefix and message content
that happens when you try to access a channel or message that you no longer have access to
for example edit/delete a channel or message after your bot was kicked from the guild
Hi Tim
You know how I can to do status like this 1,500 Members
?
@quartz kindle
Help?
setActivity or setPresence in discord.js
That will set the entire file to prefix
You would do
const { prefix } = require(...)
@manic osprey you try ?
Works?
yes
Oh ok
@low shard do you know module.export?
See what ?
i have bad problem.
Show me
@quartz kindle you can help me ?
What is your bad problem
@manic osprey you show me ?
C:\Users\User\Desktop\tester\command\UptimeCommand.js:3
module.exports = class UptimeCommand extends GeneralCommand {
^
TypeError: Class extends value #<Object> is not a constructor or null```
see
It’s v12?
Look up the type error
this is type error
hey guys why is my leave command notworking?
at Object.<anonymous> (C:\Users\User\Desktop\tester\command\UptimeCommand.js:3:46)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (C:\Users\User\Desktop\tester\index.js:20:21)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10```
because discord.js isn't a class?
Yeah look up the type error at the very top
no idea tbh
why is this leave command not working?
channelID property is undefined
as error
Then thats why its not working
yeah
that should work lol
cant class
i changed it to channel only
the id can be resolved to a channel
flezape
should that work?
can you help me?
with?
from fix error
GeneralCommand is not in discord.js, i don't think
where did you even get that code from
ok sec
i watched a tutorial for mongodb economy commands discordjs and it errored that mongo.js file doesn't exist
the file
what it does
it's didn't even mentioned
module.exports = class UptimeCommand extends GeneralCommand {
constructor(client) {
super(client, 'uptime', {
desc: 'Gets a bot\'s uptime.',
usage: '<id>'
});
}```
Is your path correct?
that's not GeneralCommand
remove?
what the file even does
is it useless?
is monjo.js file necressary for economy commands?
it's not from discord.js
ah=(
Naturally
How would you know what the file does if it doesnt exist
And why are you requiring it if doesnt exist

client.on("message", async (message) => {
if (message.content == "!leave") {
client.channels.get('734123034243367003')
client.leaveVoiceChannel(message.member.voiceState.channel);
const exampleEmbed =
new Discord.MessageEmbed()
.setColor("#FF0000")
.setTitle("**Leave/Join traffic**")
.addField("The bot has left your voice channel!", '*Resurrect the bot again using !join, if you are in a voice channel!*')
.setImage('https://media.giphy.com/media/sFuUyrIqP0mpG/giphy.gif')
.setFooter("Command hosted for Cameronbra!");
message.channel.send("<@" + message.author.id + ">")
message.channel.send(exampleEmbed);
why is this not working?
(node:8976) UnhandledPromiseRejectionWarning: TypeError: client.channels.get is not a function
also
client.leaveVoiceChannel is not a function in v12
really
yes
what should i use then
message.guild.voice.channel.leave()
You might want to check out the Discord.js Guide on upgrading to v12
https://discordjs.guide/additional-info/changes-in-v12.html
How do I define messageReminderModel in my node-schedule function?
global.messageReminderModel = mongoose.model('messageReminder', messageReminderSchema);
global.messageReminder = new messageReminder({user: user, messageLink: messageLink, time: time});
messageReminder.save(function(err) {
console.log(err);
console.log("Successfully saved reminder." + messageReminder);
});
});
}
});
} catch (err) {
console.log(err);
}
},
//Node-Scheduler Function
nodeSchedule: async function scheduler() {
try {
await messageReminderModel.find({}).forEach(data => {
let currentUnix = Date.now()
if(data.time <= currentUnix) remindUser()
schedule.scheduleJob(data.time, remindUser);
console.log("Scheduled a reminder.");
});
} catch (err) {
console.log(err);
}
}
}```
@pale vessel
https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=guild message.guild
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=voice guild.voice
https://discord.js.org/#/docs/main/stable/class/VoiceState?scrollTo=channel voice.channel
https://discord.js.org/#/docs/main/stable/class/VoiceChannel?scrollTo=leave channel.leave
that should explain it
bruh
can anyone help with my problem?
i've been trying to fix it for the past 20 mins and idk what to do
i am looking at that for like 3 seconds now and already i am confused
messageReminderModel.find({}).forEach()
what
hi can someone tell me how can i add a presence to my bot that changes every few seconds?
currently i have a static presence
you can do that by setting an interval, tho i recommend to not change it too often
like every 30 seconds should be fine
its working with a db
uhm
just add ```js
let presences = ["hello","it is I","am dumb"];
setInterval(()=>{
client.user.setPresence({activity:{name: presences[Math.floor(Math.random()*presences.length)]}})
},30000)
Flaam what library
discord.js
that is discord.js
im trying thanks constantin
I'm trying to schedule tasks for each item in the db
@finite stirrup you can add, remove or modify presences the bot has a chance to set in the "presences" array
using node-schedule
so go wild
Yeah Constantin's example is good. Also make sure the interval time is reasonable (I recommend at least 30 seconds like in the example)
ok
mhh i don't know what im doing wrong but it's not working
glitch gives me an error
i really don't know, this is my first bot
messageReminderModel.find({}).forEach()
@earnest phoenix this is how I find everything in my mongoDB Model and preform a function on each of them correct?
like all the way up, there should be something like const something = new discord.Client() @finite stirrup right?
@earnest phoenix this is how I find everything in my mongoDB Model and preform a function on each of them correct?
@gritty bolt no
how do I do that
the .find(function) is used to find an element in an array that matches the conditions
the .filter(function) is used to filter stuff out
it's mongo lol
const bot = new Client({
find returns an array of results
@finite stirrup then replace "client" on line 3 of my sample with "bot"
then it should work
ok
so then how do I preform a function on each entry
i want to do a function on every entry in the DB
messageReminderModel.find({}).then(values => {values.forEach()}) or in an async function, (await messageReminderModel.find({})).forEach()
wait isn't that what I had
no
depends if you have an async function or not
if you dont have an async function, then its js messageReminderModel.find({}).then(values => {values.forEach()}) or ```js
(async function() {
(await messageReminderModel.find({})).forEach()
}())
if you do have an async function already, its ```js
(await messageReminderModel.find({})).forEach()
i already have an async function
then you can use the bottom one
that didn't work
Hi someone know how patch the bug of typescript shardingManager (Import error) i test with require i got same error
process.exit() should do the trick
kills the process, but since pm2 is active, it will restart
I use process.exit(1) for mine
I use
process.exit(1)for mine
@ember flame exit(1) technically tells your system that your application closed with an error
It doesnt really matter as long as you dont catch it, but exit(0) is a successful exit
looks good
oh didnt even look at that
!message.author.id === false // true
Can you even negate message.author.id like that?
message.author.id !== '684409102830403587'
This is what he wants to see I guess 😄
JS can type convert like it is nobodies business
message.author.id !== '684409102830403587'
Can you even negate message.author.id like that?
@nimble kiln
yes
yeah and with his === 'ID'?
that will compare false to the id
👍
hey
anyone know how i can center some text in PIL:
like not in the middle tho
like in the bottom middle
Bruh you still not figured it out?
https://stackoverflow.com/a/1970930
Maybe this?
ty
@nimble kiln no lol
but ill try, ty
also, how can i do something when a message is reacted to
like i add reaction
and run code when a reaction is like added
With discord.js you have <client>.on('messageReactionAdd', (reaction, user) => {
im using python
Then I can't help, sorry 😄
bot.on("ready", () => { let i = 0; console.log([READY] ${bot.user.tag} has been successfully booted up!); setInterval(() => { const statuses = ["Playing 1", "Playing 2"]; i === statuses.length - 1 ? i = 0 : null; bot.user.setActivity(statuses[i], {type: "PLAYING"}); }, 600000); });
can someone tell me why this code is not working?
Well whats wrong with it
Any errors?
You never increment i, so it will always show Playing 1
?
Also that ternery expression is super unnecessary and just makes things hard to read. Use an if statement
hi
so im making a card game command
and this is my code so far
i just started it
const filter = m => m.author.id === message.author.id
const filter2 = n => n.author.id === message.author.id
const filter3 = o => o.author.id === message.author.id
const filter4 = p => p.author.id === message.author.id
const collector = message.channel.createMessageCollector(filter, { time: 15000 });
message.channel.send("Type `ready` to enter the game");
collector.on('collect', m => {
if (m.content == "ready" && m.author.id === message.author.id) {
message.author.send("test")
}})
const collector2 = message.channel.createMessageCollector(filter, { time: 15000 });
collector2.on('collect', n => {
if (n.content == "ready" && n.author.id === message.author.id) {
message.author.send("test")
}})
const collector3 = message.channel.createMessageCollector(filter, { time: 15000 });
collector3.on('collect', o => {
if (o.content == "ready" && o.author.id === message.author.id) {
message.author.send("test")
}})
const collector4 = message.channel.createMessageCollector(filter, { time: 15000 });
collector4.on('collect', p => {
if (p.content == "ready" && p.author.id === message.author.id) {
message.author.send("test")
}})
but for some reason
it is dming me 4 times
when i type ready once
plz help
or just use i !== statuses.length - 1 ?? i = 0;
it is dming me 4 times
@vale garden you made 4 collectors react to ready ofc it will dm 4 times
Wait, why do you have 4 collectors in the first place?


\




