#development
1 messages · Page 874 of 1
wait
i would suggest using a different method
const mongoose = require("mongoose");
mongoose
.connect(
`uri`,
{
useNewUrlParser: true,
useUnifiedTopology: true
}
)
.then(() => console.log("MongoDB Connected..."))
.catch(err => console.log(err));
Should I use mongoose instead?
yes
I'd recommend going through these docs if you're planning to use the mongodb official package - https://docs.mongodb.com/drivers/node/
ok
@finite bough I wouldn't recommend an orm TBH.
is mongoose better?
mongoose is a MongoDB object modeling tool
ok
mhm
@golden condor orms always result in loss of performance, although it's pretty low for some orms like sequelize, for mongoose, the loss is pretty high.
doesn't matter
^
mongoose is easy-to-learn
@golden condor it is always a matter of personal choice and what you want to do.
from w3schools
DON'T
Why
Please don't use w3schools lol
why?
Just a recommendation, don't use w3schools cuz it's all mostly outdated
Yes
yes
The official documentation
ok
some examples
mongoose or mongodb ??
doesn't matter
@summer torrent
ok
xd
Are they the same?
no
no
Not quite
in a practical sense
they some some differences
No
o
mongoose is a object modeling tool for mongo
what differs them?
models
Which is faster and which is easier?
data schemas+
mongoose i think
Mongoose is easier, mongodb is faster
^
Although I would still recommend mongodb cuz it's still fairly easy
Ok
i remember getting a better lat with mongoose tho
I am using mongoose. It is so easy
They have some good tutorials
same NM
I use both
I am really confused on which to us
actually i am using better-sqlite 3 and mongoose both
Someone tell me how this happened?
module.exports = {
name: "eval", //command name
async execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
///Command Starts Here
function clean(text) {
if (typeof text === "string")
return text
.replace(/`/g, "`" + String.fromCharCode(8203))
.replace(/@/g, "@" + String.fromCharCode(8203));
else return text;
}
if (message.author.id !== config.ownerID) message.channel.send(NL3Embed);
else {
try {
const code = args.join(" ");
let evaled = eval(args.join(" "));
if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
const embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.username}`, `${message.author.avatarURL()}`)
.setTitle("Eval")
.setTimestamp()
.setColor([173, 216, 230])
.addField("**Input**", '```' + args.join(" ") + '```')
.addField("**Result**", '```' + clean(evaled) + '```')
.setFooter(`${message.author.username} evaled`, `${message.author.avatarURL()}`);
message.channel.send(embed);
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
}
};
```Someone show me what I missed?
so what should I do
@golden condor it's your choice
@high bough add return
and which one is more used
Both have the same support, and mongoose uses mongodb
a single entity cannot break stuff
which would you recommend
My Eval command blocks anything other than me, but for some reason, it broke?
@high bough try to add return
any errors?
that shouldnt matter
They asked about it
coz not everyone is making a discord bot
ok
Yes, lol
or are they ? xD
Who knows
I am stuck now in what to use
@golden condor as I said, go through both of their docs, whichever one you like better, use it
big brain
Yes

Which is why I say, go through both their documentation
Whichever one you can understand how to use, use it.
mongoose != the database itself
module.exports = {
name: "eval", //command name
async execute(client, message, args, Discord, config, eco, leveling, db, avatarURL, footer, clientname, NL3Embed, DevEmbed) {
///Command Starts Here
function clean(text) {
if (typeof text === "string")
return text
.replace(/`/g, "`" + String.fromCharCode(8203))
.replace(/@/g, "@" + String.fromCharCode(8203));
else return text;
}
if (message.author.id !== config.ownerID) return message.channel.send(NL3Embed);
else {
try {
const code = args.join(" ");
let evaled = eval(args.join(" "));
if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
const embed = new Discord.MessageEmbed()
.setAuthor(`${message.author.username}`, `${message.author.avatarURL()}`)
.setTitle("Eval")
.setTimestamp()
.setColor([173, 216, 230])
.addField("**Input**", '```' + args.join(" ") + '```')
.addField("**Result**", '```' + clean(evaled) + '```')
.setFooter(`${message.author.username} evaled`, `${message.author.avatarURL()}`);
message.channel.send(embed);
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
}
};
```I will say goodbye to my bot
It's going to the trash soon enough
The documentation
@quasi forge It comes out with errors
What are the errors?
have you actually got a mongo server running...
Yes
I connected to it before
with mongodb
(node:9470) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [corynth-shard-00-02-7lanh.gcp.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to corynth-shard-00-02-7lanh.gcp.mongodb.net:27017 closed```
MongoNetworkError: failed to connect to server
^
question
I feel that's a invalid connection URI thing
did u white list ur ip?
I didn't think I needed to since it worked earlier
ur bot's ip that is
You can also whitelist all IPs tho
yea
That should be safe if you keep your credentials secure enough
what
500 MB is free
512 MB
use localhost
I wanna do localhost
Not quite unlimited but whatever your device storage is lol.
Do I have to set it up?
Just go to the mongodb website to see how to install and set up a local server
^
It's pretty easy and well explained
What
@summer torrent thx
I'm sorry I'm being a real pain
Is it the community edition I need?
@🎗세월호 추모 (손재원)#6811 english please.

@finite bough do I need community edition
u need what
of the mongodb localhost driver
yes
ok
never tried local host so dunno
Community = free
Enterprise = paid
I'm trying to play a song using ytdl, but it shows me this : https://corynth.xyz/lumap/e7ZeUAHG.png
here is the code to play songs : https://corynth.xyz/lumap/fVKIDQok.png
I use eris 0.11.2
Mongoose works
:>
.connect
What is the best way to ignore the channelUpdate event if the update is made by the client user?
Should I work with audit logs or can I change something in the discord.js modules?
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var MyModel = mongoose.model('Test', new mongoose.Schema({ name: String }))
MyModel.findOne(function(error, result) { /* ... */ });
console.log(MyModel)
setTimeout(function() {
mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);``` How do I use schemas?
@nocturne grove fetching the executor from audit logs and checking
I am using the test code in the docs
@nocturne grove fetching the executor from audit logs and checking
@finite bough ok thanks
const anyname = mongoose.model("model name", Schema);
@finite bough what about inserting data
anyname.findOne(
{
primarykey: primar_key_data
}, (err, res) => {
if (err) console.log(err);
res.name = args[1]
res.save().catch(err => console.log(err))
var guilds = mongoose.model('Test', new mongoose.Schema({ id: String, prefix: String }))
primary key
here guild is the primary key
so
anyname.findOne(
{
server: message.guild.id
},
does anyone know why Discord website says If they (a member) have a nickname there will also be a be a ! after the @. if it's not true? My bot has no nickname (in all guilds) and a mention still shows a !.
when u are logging a mention
even if I manually type <@id> console.log(message.content) gives a !
yes I know
but they say: If they (a member) have a nickname there will also be a be a ! after the @.
So that means if they have no nickname, you won't have an !. But I still have a ! in the mention.
@golden condor
res.prefix = ugai
res.save().catch(err => console.log(err))
how do I change the data that has already been put in
like that
what is res in this scenario, the guild?
can u send me the link menno
sure
How many times approved bot??
my friend threw a request 2 hours ago and his bot is already in new
@finite bough how do I do that function
Guilds.findOne({id: '661923253488713729'}, function(error, result) { console.log(result) });```
It returns null
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
var guild = new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: true, suggestionChan: "666736935947206686"})
Guilds.findOne({id: '661923253488713729'}, function(error, result) { console.log(result) });
console.log(guild.suggestions)
setTimeout(function() {
mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);```
I tried this
Guilds.findOne({id: '661923253488713729'}, function(error, result) { if(!result) return new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: false, suggestionChan: null })
console.log(result) });```
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
var guild = new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: true, suggestionChan: "666736935947206686"})
Guilds.findOne({id: '661923253488713729'}, function(error, result) { if(!result) return new Guilds({id :'661923253488713729', prefix: 'c-', suggestions: false, suggestionChan: null })
console.log(result) });
console.log(guild.suggestions)
setTimeout(function() {
mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);``` This is my code @finite bough
Ok
True
thats not how u make a schema
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
Guilds.findOne({id: '661923253488713729'}, function(error, result) {
console.log(result) });
setTimeout(function() {
mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);```
this is so confusing
Do not use vars they suck
When I use "text" it's print "text" but when use "vc" then "text" replace to "vc"...I need both
So just this
const mongoose = require('mongoose')
const uri = "mongodb://localhost:27017";
mongoose.connect(uri, {useNewUrlParser: true})
var guilds = new mongoose.Schema({ id: String, prefix: String, suggestions: Boolean, suggestionChan: String })
var Guilds = mongoose.model('Guild', guilds);
setTimeout(function() {
mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});
}, 60000);```
now
@finite bough do you love javascript?
Uhm sorry,
its ok
@earnest phoenix code is personal preference. If you don't have something helpful/useful to say about the matter in here, please don't say anything.
facts tho^
My bad.
i mean not really,
Tho it's really useful tip
Var is generally regarded as something you should not use in those regards
he wasnt being negative, he was just saying what is good practice todo
tho it might of been more helpful to follow up with saying what they could / should use instead he wasnt in the wrong for telling a user a possible issue in their code or warn the user for using a process that might not be in the user's best interest to use 
https://canary.discordapp.com/channels/264445053596991498/272764566411149314/700274980629512302 so it works fine with "local" files, but not with ytdl ones wtf
tried reinstalling ?
eris?
yes
https://corynth.xyz/lumap/ISjHX2HK.png so no options.command
wt
lul
idk whats the problem
now u know why i never even touched eris xD
oof
I got this when running my bot FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memoryhow to fix this?
what is your ram size
@summer torrent 4GB. I use discord.js. Do you know how to optimize the use of RAM when you first run the bot? sorry for mention
Uhhhh.
It shouldn’t take 4GB for a new bot using d.js. Are you sure that nothing else is eatting ram?
when run your bot add --trace-warnings --max_old_space_size=4200 behind
like node bot.js --trace-warnings --max_old_space_size=4200
@restive night there might be memory leak issue
Issues with mongo
const {queue} = require("../queue.js")
const Discord = require("discord.js")
const {ownerid} = require('../config.json')
const { Guilds } = require('../db/db.js')
const escapeRegex = function(str){ str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}
exports.run = async (client, message) => {
if (message.author.bot) return;
if (message.channel.type == "dm") return;
if (!message.channel) return;
const db = require('quick.db')
let prefixx;
Guilds.findOne({
id: message.guild.id
},
async function (err, res) {
if (err) console.log(err);
if(!res){
prefixx = "c-"
const newDoc = new Guilds({
id: message.guild.id,
prefix: "c-",
suggestions: false,
suggestionchan: null
})
newDoc.save().catch(err => console.log(err));
} else if(!res.prefix) prefixx = "c-"
else prefixx = res.prefix
});
let mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`);
const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`);```
Says prefixx is undefined
Is this a reliable way to check if my client updated a channel name?
client.on('channelUpdate', async (oldChannel, newChannel) => {
const guild = oldChannel.guild;
const auditLogs = await guild.fetchAuditLogs({ user: !guild.me.id, type: 'CHANNEL_UPDATE' });
console.log(auditLogs.entries);
const updatedByClient = auditLogs.entries.first().changes.some((change) => {
return change.old == oldChannel.name && change.new == newChannel.name;
});
console.log(updatedByClient);
});```
I feel like something is missing with time
yes
try this
const Discord = require('discord.js')
const { queue } = require('../queue.js')
const { ownerid } = require('../config.json')
const { Guilds } = require('../db/db.js')
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
exports.run = async (client, message) => {
if (message.author.bot || message.channel.type === 'dm' || !message.channel) return
// const db = require('quick.db') I don't know why it's here?!!
let prefixx = 'c-'
Guilds.findOne({ id: message.guild.id }, async (err, res) => {
if (err) console.log(err)
if (res && res.prefix) prefixx = res.prefix
if (!res) {
const newDoc = new Guilds({
id: message.guild.id,
prefix: 'c-',
suggestions: false,
suggestionchan: null,
})
newDoc.save().catch(err => console.log(err))
}
})
const mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`)
const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`)
}
I changed my code a bit. Would this work for ignoring channel name updates by the client?
client.on('channelUpdate', async (oldChannel, newChannel) => {
const guild = oldChannel.guild;
const auditLogs = await guild.fetchAuditLogs({ user: guild.me.id, type: 'CHANNEL_UPDATE' });
const updatedByClient = auditLogs.entries.first().changes.some((change) => {
return change.old == oldChannel.name && change.new == newChannel.name && Date.now() - auditLogs.entries.first().createdTimestamp < 5000;
});
console.log(updatedByClient);
});```
I used this emoji \😄 and console shows (node:8825) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Emoji
Hey @plucky heart! Try using a Discord one similar to the emoji you want to use 🙂
@plucky heart how are you using it
😄 this one could help you
message.react(' \😄 ');
try removing the spaces
I deleted and still the same
I think he only copied from google and pasted it in his code
Hey @plucky heart! Try using a Discord one similar to the emoji you want to use 🙂
bruh
\😄
try that
When someone whitelists you and you accept what does it do?
what whitelist are you referring to
Like for a application or bot
what specific whitelist are you refering to?
the term whitelisting in general means that someone is allowed to do something
to whitelist someone is to grant them permission to do something
Is my code correct its been ages since I've made a bot and my code just doesn't look right
on the discord developer page?
@still merlin what doesnt look right?
nothing wrong there
Ok thanks
so many errors with mongodb
Yes on the discord developer page
I kept getting errors so I re-wrote it and I was just unsure if my code was right
0|index | TypeError: Cannot read property 'replace' of undefined
0|index | at escapeRegex (/home/cxllm/Bots/Corynth/events/message.js:5:32)
0|index | at Object.exports.run (/home/cxllm/Bots/Corynth/events/message.js:28:62)
0|index | at Client.<anonymous> (/home/cxllm/Bots/Corynth/index.js:23:7)
0|index | at Client.emit (events.js:311:20)
0|index | at MessageCreateAction.handle (/home/cxllm/Bots/Corynth/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
0|index | at Object.module.exports [as MESSAGE_CREATE] (/home/cxllm/Bots/Corynth/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)```
const {queue} = require("../queue.js")
const Discord = require("discord.js")
const {ownerid} = require('../config.json')
const { Guilds } = require('../db/db.js')
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
exports.run = async (client, message) => {
if (message.author.bot) return;
if (message.channel.type == "dm") return;
if (!message.channel) return;
const db = require('quick.db')
let prefixx;
Guilds.findOne({ id: message.guild.id }, async (err, res) => {
if (err) console.log(err)
console.log(res)
if (res.prefixx) prefixx = `${res.prefix}`
else if (!res) {
prefixx = "c!"
const newDoc = new Guilds({
id: message.guild.id,
prefix: 'c!',
suggestions: false,
suggestionchan: null,
})
newDoc.save().catch(err => console.log(err))
}
})
let mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`);
const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`);```
@quartz kindle Yes on the discord developer page
this?
Yes
i dont know if that has any effect on bots, its primarily for games and other applications
0|index | {
0|index | _id: 5e983d9863b24e55b79d09d3,
0|index | id: '697838346256515082',
0|index | prefix: 'c-',
0|index | suggestions: false,
0|index | __v: 0
0|index | }``` res logs as this
but check in your own developer portal and see if you have access to anything you didnt before
But how do i acces the application?
i dont see it
then idk
@golden condor Guilds.findOne is an async function
its results dont exist outside of its callback
so
Does my code
bot.login(token);
need to be at the end of my code or can it be anywhere
await
it uses callbacks, not promises
the function?
so you cant directly await it
i am going nuts tryna solve how this works
@still merlin it can be anywhere as long as its after bot and after token
@golden condor js code(dosomething, result => { // result exists here }) // result does not exist here
Ok thank you so much!
how i can edit msg using id ?
@golden condor
because async functions are executed in parallel, your code does not wait for it
so what should I do
you define let prefixx but the prefix is not defined in time, your code immediately tries to use it in prefixRegex without waiting for Guilds.findOne
aaaahh
You can promisify it or put the rest of the code inside the callback
^
yes that is the easier thing to do
Tim is always helpful change my mind 
he always is
Guys how do i get dm's from a bot and then check if the user has sent dm's earlier if he hasn't then create a channel with his userid in Tickets category and then send his message that was sent in that new created channel... This code currently kind of works but the user has to send two messages, in the first message his channel is created and in the second one his channel is moved to the Tickets category and then his second message is sent there... i couldn't figure out a better way to do that.. can someone help me with that.... Thanks for reading my really long message btw...😅
Can someone help with this...
instead of an if/else you just do an if with an async function
instead of this js bot.on("message", message => { if(!channel) { create channel } else { send } }) you do this ```js
bot.on("message", async message => {
if(!channel) {
await create channel
}
send
})
but if there is no channel then how can i create channel and send his message in it at the same time?
by using async await syntax
so your code properly waits for operations to finish before proceeding
ohh, ok yes that would work... thanks...
printDate(pdate){
let monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct",
"Nov", "Dec"
];
let weekNames = [
"Sat", "Sun", "Mon",
"Tue", "Wed", "Thu", "Fri"
];
let day = pdate.getDate(),
monthIndex = pdate.getMonth(),
dayIndex = pdate.getDay()
year = pdate.getFullYear(),
hour = pdate.getHours(),
minute = pdate.getMinutes();
return weekNames[dayIndex]+','+monthNames[monthIndex]+" "+day+","+year+" "+hour+":"+minute;
}
how do i get am or pm
i am using (ms) btw
if hours >= 12 pm
if hours < 12 am
if hours < 12 am
otherwise hours-12 pm
you can use locale functions to output the date in whatever region settings you machine is in and then extract from it, or do math like the answers above ^
ok thx
I'm getting a error in my code.
bot.on('ready', {) }
its unfinished code but I keep getting errors when I type it in
hello how i can delete message using id of the message in js
@still merlin bot.on(`ready`, () => { //code here });
tysm
@wide ridge
bot.on('ready', () => {
//code here
});
Client.on('ready', () => {
console.log(`Client [${Client.user.username}] online!`)
});
```@still merlin
{
console.log('Bot is now up and running');
})```
how i can delete message using id of the message in js
@earnest phoenix try channel.fetchMessage(lastmsgID).then(msg => msg.delete());
or just google
okey
anyone else receiving a LOT of (node:3265) UnhandledPromiseRejectionWarning: AbortError: The user aborted a request. messages? Seems like discord is going wonky again
I haven't received any as I just started a new bot
Don't
Joining servers randomly through your bot without any form of consent is against Discord ToS aka privacy breach
Don't
@slender thistle i know but i ask can it possible ?
It is
lol i never do that
- will
anyone else receiving a LOT of
(node:3265) UnhandledPromiseRejectionWarning: AbortError: The user aborted a request.messages? Seems like discord is going wonky again
@wide ridge not a big problem
I have something similar, it's used in the request assist command
a good mod will not give manage_invites perm to any bot
except invite manager bots
"a good mod"
lol
not an average owner
you know a server owner/admin is good when they actually read bot permissions before adding them
lol
well, if you say so...
How do I make my bot have a mention as a prefix
Example: My bot is called Dime so when I tag Dime with the command he'll do it normally
I already have some code but it seems to not work (the numbers are his ID)
var PREFIX = "@late stream ";
discord changed mentions to <@!number>
I made a ping pong command as a test and this is what happend
I'm sure this is not the right way
Oh ok thanks Tim
the correct way is to check for both <@id> and <@!id>
because discord keeps changing those for no reason
Actually isn't it always !id now?
I did @id and it worked as a test
Oh right they can change those anytime
i think its all <@!> now but you never know
ok
<@ID> works as well
but sometimes it becomes <@!ID>
it gets converted to <@!id>
oh
It works thanks!
on mobile it didn't convert, last time i tried
If I'm making discord bot what basic things I should include? Like logging every command. Health command. Stats command?
making a regex pattern is a good idea
<@!?id> something like that
@earnest phoenix anything you/people find useful
unlike covid bots
Like?
I'm not about bots core functionality, but extra functions bot must have.
Like ban users feature.
rate limiting
I'm making bot first time so I don't know what possible challenges I will face in future.
the command to change the slow mode delay on a channel was fun
hard tho
just finding out where
its easy if you use the docs tbh
Leave implementation to me, just tell me features
ok
or you can be lazy and do it by channel
I'm sure it shouldn't take more than 45 minutes.
lol it'll take
in my case I used a timed cache, which removes entries based on their age
😆
I didnt impliment mine yet
but I need to do it in a way where it says the time left
another thing that's nice to have, but hard af to implement efficiently is antispam
antispam?
but I need to do it in a way where it says the time left
@crimson vapor You meant cool down?
so you dont have users spam a channel with a command and you get ratelimited
yeah, like, trigger a event when an user send N messages in a short time
no, it's not
I've made two types of antispam: one that triggers on repeated messages and other that triggers on quick messages
depends
I'm getting a issue with my bot.
I typed out a command
bot.on("message", (message) => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "ping":
message.channel.sendMsg("pong!");
break;
}
});
and for some reason my bot still decides to do this:
I don't like to implement such a feature until it's really necessary.
it'll never be necessary
That's also true. I'm not lazy but I don't like to make overhead.
then you'll not make 
@still merlin im pretty sure sendMsg isn't a thing (or its deprecated), and the content doesn't match the argument you passed in meaning you have another handler somewhere
i hope you restarted your bot when you made changes
lol
in bot development there's no "overhead", you can develop any feature at any time
that's called "new feature"
Where're you from bro?
make your bot framework into a different folder so all you are doing is creating a new bot and adding commands to it
once I am bored enough, I will be moving everything to a folder like that
Where're you from bro?
not relevant rlly now
My bad.
don't worry
@earnest phoenix I don't know exactly what that means im bad a coding
how would that work?
Sorry I didn't get it
what would be the use-case of that email system?
against tos
Not discord
friggin ninjas
let say you want to create account on some website but don't want to give your main email
automatically creating any kind of account is against pretty much ANY tos
so many things people do here are against the tos but discord's t&s team sucks so much they don't care even about actual issues
Automatically?
OK I have got a question?
I am trying to make a command for example <Prefix>syc-roles on discord.js v11.4.2
I want the user to get the roles that he/she has on the main server and give the same roles on the staff server.
How can this be done?
no one said anything about account creation lol
Yea why would you want to create them automatically that's bad no matter what way you put it
just providing temporary emails like 10minutemail, but in discord
let say you want to create account on some website but don't want to give your main email
@earnest phoenix seems pretty much account creation to me
it isn't though
all you need is an SMTP server and you're good to go
Let say I want to download something from x website but they requires account on their website
physically no account creation is happening
ah, that
I have already created that bot
actually, that's a dope idea for a bot
There nothing near in this discord bot community. It's unique
But my main focus in on providing api
You might not like me but there're many scrappers for them this will be heaven.
Dude you're OP
"if you don't want to make an api for your website at least put ids in your tags"
---------- first rule of bro devs
@earnest phoenix would you mind if I add you?
bro or pro
bro
ahh
not all pro devs are bros
but you can always go through any amount of html and get the thing you want at some point
@modest maple you got me wrong.
So any one has an idea for me?
yeah, but with ids it's a lot easier
I'm talking about temporary mail api.
Or websocket. On which you can subscribe and I can broadcast new emails.
if its a temp email surley broadcasting to them is irrelevant
because they're getting destroyed anyway
@heavy marsh use map() on https://discord.js.org/#/docs/main/11.4.2/class/GuildMember?scrollTo=roles in guild A to map the collection to roles in guild B. something like map(r => guildB.roles.find(x => x.name === r.name))
you'll then have a collection of the roles in guild B and you can simply use https://discord.js.org/#/docs/main/11.4.2/class/GuildMember?scrollTo=addRoles and pass the mapped collection
live example http://temp-mail-api.live/socket/test1@shashin-don.online mail on test1@shashin-don.online it will pop on webpage
guess I'll buy a domain and make something similar, if you don't mind
it's a really dope idea
Sure thing go ahead.
at least for my devs
Or we can do it together.
just makes my life harder when dealing with spam bots 
yes, but not with java
Just joined server today and it's amazing to meet new peoples really interested in coding.

not style
Why is this not working?
ah, it's style
anyway
where's this tag located?
depending on where you placed it it might work or not
bot-img is an id
put in the end of your long desc
Why is this not working?
again, if it doesn't work then it's not right
yes
please kill me sorry
remove the dot
Hello. I think a function in my code is outdated (not up to date with version 12, which is what I’m using) and it isn’t picking it up because of that. Could anyone help me?
maybe. send what you're having problems with
Yeah, I was waiting for someone to respond until I sent an image because I didn’t want to clutter the chat
Is the image quality okay?
@quartz kindle Thanks, this worked
bot.on('message',async message=>
{
if(message.channel.type!=='text')
{
if(message.content.startsWith(config.prefix)) return;
supportchannelname=message.author.id;
foundchannel=bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname);
if(foundchannel===undefined)
{
await bot.channels.cache.get(config.defaultlog).send(`Created new ticket channel for ${message.author.tag}`);
await bot.guilds.cache.get(config.serverid).channels.create(supportchannelname, { topic: 'Ticket channel for'+message.author.tag});
bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).setParent('700024079348007029');
bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).send(`${message.author.tag} : ${message.content}`);
}
else
{
bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).setParent('700024079348007029')
bot.guilds.cache.get(config.serverid).channels.cache.find(c => c.name === supportchannelname).send(`${message.author.tag} : ${message.content}`);
}
}
})
i see it already
just send a screenshot or upload it somewhere
does mongodb work in the same way as mongoose?
I’ll try and copy and paste it rn
Will mongoose code work with mongodb
There are slight differences
I just sent the image so I could get the terminal error in there
case 'mute':
var person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]));
if (!person) return message.reply("I CANT FIND THE USER " + person)
let mainrole = message.guild.roles.find(role => role.name === "New Member");
let role = message.guild.roles.find(role => role.name === "Muted");
i think the error is in the bottom two lines
I’m reading it rn
Thank you. I’ll keep that article bookmarked so if I run into an issue like this again I’ll be able to fix it on my own
Mongoose is really laggy please help
you can use html in the long description
tldr use the <style> tag to override css on the existing page
you can find what to override by digging through the website html via inspect element
who can help me for C# api
probably meant help with discord.net or dsharp
let mention = new RegExp(`^(<@!?${client.user.id}> )\\s*`);
const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefixx)})\\s*`);
if (!prefixRegex.test(message.content)) return;
const [, prefix] = message.content.match(prefixRegex);
if (!message.content.startsWith(prefix)) return;
let args = message.content.slice(prefix.length).trim().split(/ +/);
let cmd = args.shift().toLowerCase();
let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));``` Not sure why I can do c! help and it still works with this code
if (command) {
if(command.category === "Owner" && message.author.id != ownerid) return;
command.run(client, message, args, queue).then( () => {
const Embed = new Discord.MessageEmbed()
.setTitle("Command Run")
.setDescription(`The command **${command.category}/${command.name}** was run by **${message.author.username}** in **${message.guild.name}**`)
.setColor(0x00aaff)
const cnl = client.channels.cache.get("697061184708280350")
cnl.send(Embed)}).catch(e => {
message.channel.send("Unfortunately, there was an error executing that command and I will inform the developer so he can fix it.")
client.users.cache.get(ownerid).send(`There has been an error executing ${command.name}\n\`\`\`js\n${e}\`\`\``)
})
} else return;``` the next part
does anyone know how to get the content of a message collected by a messageCollecter in discord.js?
@golden condor you check if the start of the message is the prefix (which it is) then you slice the prefix length, so you're left with help then you trim which turns it into help then you split which makes it [help]
Yes, but you can still remove whitespace from the end if you want with trimEnd()
whitespace?
does anyone know how to get the content of a message collected by a messageCollecter in discord.js?
@gritty bolt
to add onto my question above, I havecollector.on('collect', m => {and I'm trying to get the content by doingm.content
Say if I wanted the prefix as pp but also wanted but also wanted it to respond to pp @amber fractal how would I do that
you'd have to check for a single space, whereas trim simply gets rid of all whitespace (spaces, blank characters, etc)
I am not sure if this is completely development related, but has anyone got recommendations for hosing a python bot for free?
AWS EC2 first year is good
I don’t think glitch supports python
Glitch is node.js
Currently I am using google but I will have to keep the bot down 10 hours a month to keep it free
how many hours does google give you for free?
@earnest phoenix you mean google cloud?
Yes
What are the specs, do you know?
You can use heroku, if you put in your card details (without paying) you get 1000 hours a month which is enough to cover the entire monht
Hi, in discord.js, how can i add a cooldown to a command?
By making a new set and adding the user's id into it and deleting the user's id from the set after the amount of time you want @balmy knoll
There are several ways you could do it:
-
Use an array/set/single-item type of list for how long the cooldown is supposed to be. Remove the user after the time period has passed (e.g. 3 seconds). If the user is still in the cooldown when they run the command, deny them permission with an optional message saying they're being rate limited.
-
Use a map/collection and do the same thing. For example:
let ratelimit = 3; // 3 seconds
let blocked = new Set();
onCommand(() => { // Let's imagine this is run when the command is run.
blocked.add(userID);
setTimeout(() => blocked.delete(userID), time);
})
// Figure out how to check the user for if they're currently ratelimited.```

Not really spoonfeeding. It's an example.
@earnest phoenix @sudden geyser Thanks
Np
@golden condor You get 720 hours per month for a 1 shared cpu and 600mb of ram
@earnest phoenix try heroku like I said
You can use heroku, if you put in your card details (without paying) you get 1000 hours a month which is enough to cover the entire monht
@earnest phoenix ^
Ok, I will. Thanks for the help
anyone knows how to send dm's via bot with numeric userid in discord.js
Is that even possible?
But then how will I keep my bot going to sleep using python?
Give him some coffee, kidding. AFAIK I don't think bot will go to sleep.
if(collected.first().content == randomnumber) return message.channel.send(yesembed).then(coins.add(`${message.guild.id}.${message.author.id}`, parseInt(betdouble)))```
Why is this not working?
Btw betdouble = bet*2
and bet is args[0]
context please
its supposed to add coins
what's collected? what about the yesembed?
how i can check if member is not member.bot:
show the whole code block
me?
how i can check if member is not member.bot:
@placid vault member.isbot I guess?
@lyric mountain
const filter = m => m.author.id === message.author.id
message.channel.send(noguess)
message.channel.awaitMessages(filter, {
maxMatches: 1,
time: 10000 }).then(collected => { ```
this is the filter
if(collected.first().content == randomnumber) return message.channel.send(yesembed).then(coins.add(`${message.guild.id}.${message.author.id}`, parseInt(betdouble)))
...still out of context
this is supposed to add the coins if im right
where are you getting the collected variable?
what about the randomnumber and yesembed?
it sounds like you want the whole code?
im just asking why my coins adding is not working
the embed is being sent tho
I can't help you without knowing the whole code logic
that's like asking "what's wrong with my car" by showing a photo of it
well im showing the code and just saying that .then is not working
but the embed is being sent and everything is correct
bet double is = bet*2
and bet is args[0] (a number)
that betdouble is 2000 (which is correct)
but it wont add
somthing with .then
can i use somthing else on it ?
instead of .then
are you saving coins after that?
wdym
is it a variable or a database entry?
like, do you define it in the code or save it to a database?
and are you persisting the coins object after you're adding to it?
persisting = saving to database
yeah its auto saving in the db
the system is all ok but the part when .then will just not work
I'm out of ideas then
there's probably no other way to run that code after the embed is sent
do you really have to run it ONLY after sending the embed?
no
i can first do it then send the embed
if thats what u mean
it takes a miliseconds there is no difference
try doing it then
i tried
i still dont have coins
then it's most likely an issue regarding the database
coins.subtract(`${message.guild.id}.${message.author.id}`, parseInt(bet))```
i have this part where its removing your money after you bet
but if you win, it doubles the money and adding
double check the adding method
i use it with other commands
see if you're not forgetting anything
idk
let betdouble = bet*2```
is this the correct way ?
oh wait actually
maybe i need to do Number(bet)*2
meth
as I said, there's not much I can do without seeing the entire code
use parseInt()
idk what to say
What's the hex/unicode for this emoji? #️⃣
I am trying to add it as a reaction but it ain't workin...?
put a \ behind it
no it doesn't
?
as I said, put a \ behind that emote
Many*
and you'll get the unicode
#️⃣
On discord?
put.a.\.behind.it
Thats showing a square??
:hash:
:hash:
#️⃣
oh god
since discord uses standard google emojis
Phone users r different dude like for example to see an emoji id we do :-:emoji:
unicode actually
also for android users, which is the same as pc one
that's just the theme
Ye
anyway, copy this #️⃣
use this website to get emojis' unicode https://emojipedia.org/
The emoji search engine. A fast emoji search experience with options to browse every emoji by name, category, or platform.
where it's U+1234 you can replace with \u1234
hey um if any1 here into sharding someone can tell me why is my bot responds twice when i use sharding?
discord.js
(node:14145) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 guildMemberRemove listeners added. Use emitter.setMaxListeners() to increase limit
anyone know about this thing?
you have a memo leak somewhere
is this why the thing didnt work before?
are you creating event listeners inside commands?
im not sure
where are you checking for message deletion?
on events
ah, forget about it
so, where are you checking for members that leave the server?
see if you're not creating it inside a loop or something like that
i have one command where i do
idk about loop, its on a command that if someone leaves it will change the channel name
why do you have a command that creates a onGuildMemberRemove event?
you shouldn't need to create guild listeners more than once
so should i delete it or?
just create one and use member/guild IDs to handle it
and btw, can it be the reason why the coin think didnt work before?
probably no
oof
that would be the cause for your bot using 500+ MB of extra ram
can i send my command so you can help with the coins>
somthing similar happend to me before, so i got it out of the event and it started working
but i need this in the event so...
bruh
instead of creating one embed for each case you could create one embed builder and modify it for each one
embeds have a .clear() function to wipe them
ok but what is the problem?
still reading
@earnest phoenix does the coins.add() work somewhere else in your code?
yeah
on addcoins command
ik why
it wont work
listen
inside the function of the collect
it wont add/remove
if i do it outside it will work
have no idea how to do it without it being in the function
is the yesembed showing at all?
yeah
again
the coins.add wont work inside the collect function
if i do it OUTSIDE it will
I have a lot of values like: case1 , case2, case3 . how can I reference them by number? If you don't understand, basically I want this: (botc.raid + Number(args[2])) to be together when you reference by the number
i have do this
return console.log("Pas le compteur !")
} else {
if(!message.guild.me.hasPermission("MANAGE_CHANNELS")) return message.channel.send("**:warning: I don't have the `MANAGE_CHANNELS` permissions for change the name of counters (english to french).**")
variable_categorie.setName(`⭐ Stats du serveur`)
}```
but console say me Missing Access
How can i do
maybe your bot don't have permission for view that channel.
my bot has permission for view that channel
on
which
method
give us the full stacktrace
How would I check the global ratelimit on sending messages?
I know I can use a simple message post and check the headers and then I'll get this, but this is just the per channel (or per server?) limit isn't it?
per channel iirc
Struggles of using a library that handles ratelimits for you, not knowing when you're actually hitting them
/root/PB-master/Commands/about.js:5
async(bot, msg, args) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at files.forEach.file (/root/PB-master/bot.js:28:19)``` Keep getting an error for some reason and I have no idea what the issue here is
Mongoose is really lagging out and I don't know why
yeah
since they aren't specific per route
a bucket doesn't exist for global ratelimits
fun facts: dont try to find out the global ratelimit
and you shouldnt even need to know the global rate limit
because its high enough for it only to come into affect if you're doing ye old mass DM
You think they're high enough so that it'll be "impossible" to legitimately hit even for bots that get thousands of new players a day.
And quite a few of those actually sticking around and actively playing.
Especially during a special event of some sort 
I'm at about 10 to 20 commands a second (so basically 10 to 20 messages a second) for one of my bots
I see occasional "breaks" in-between the replies which i feel like those aren't my server messing up but simply a ratelimit of some sort.
It doesn't seem to be the per-channel one anymore that I'd usually get.
Maybe it's per server if that has it's own limit as well
don't know
when you look at a bot like pokecord which im pretty sure people abuse the fuck out of it on the daily, discord sees that it's in >n amount of servers and either gives it a ratelimit increase or tries to get in contact with the bot developer
rate limits are per server, but there is a global limit
so if you're really hitting 10 to 20 messages a second globally then its probably not something to be worried about unless it's in a specific server
do you know where it's coming from or nah
they're definitely per-channel too as 2 people in one channel can hit the limit while having those people split up will be fine
ratelimit is around 500 requests/sec
@modest maple shiemi told me to ask you about making mongodb/mongoose faster
thats weird
I mean, I notice it mainly in my support server which is obviously the most active place for commands
i dont think discord will get suspicious if you hit the message ratelimit per channel often
maybe
I made 10 command channels so people could actually play without chat flying by
unless the 1 hour ban is a still thing for the api
Maybe it's purely an issue in my server and I should just not have command channels anymore?
Or like use a slowmode in them
yeah you're probably fine for the most part honestly, if you do get api banned then talk to discord about it
Mongoose is really laggy please help
@golden condor Local or remote?
maybe just don't send a cooldown message at all and ignore silently until the cooldown is over for a frequently used command
local
it doesn't really have to be that lone either, maybe one second per command
What response times are you getting?
so people can't go ctrl + c, ctrl + v
how you handle that is up to you entirely but don't be concerned about your bot hitting channel ratelimit too much atm
what are the specs of the computer you run it on?
what about bandwidth and internet speed
can you do free -h and tell me the output?
I'm not sure then, could be a cpu issue, especially if it's local. I use mongo and have no problems like that
In a server with no prefix
it's fine
do you use mongoose or mongodb @amber fractal
This is my code for handling prefixes
Guilds.findOne({ id: message.guild.id }, async (err, res) => {
if (err) console.log(err)
let prefixx;
if(res) prefixx = res.prefix
else prefixx = "c!"
if (!res) {
prefixx = "c!"
const newDoc = new Guilds({
id: message.guild.id,
prefix: 'c!',
suggestions: false,
suggestionchan: null,
})
newDoc.save().catch(err => console.log(err))
}```
I use mongodb, but mongoose just connects to a mongo database
It is the official driver for mongo
yeah
How would I get this
var guilds = new mongoose.Schema({
id: String,
prefix: String,
suggestions: Boolean,
suggestionChan: String
})``` Onto mongdb
https://oliy.is-just-a.dev/6jfn0d_3576.png this is how I connect, https://oliy.is-just-a.dev/5odl39_3577.png this is an example of how I would use it
I hate this aaaaaaa
I just wanna use mongo-db
For prefixes
How do I use a schema in mongo db
I used it for prefixes like this https://oliy.is-just-a.dev/2vp0zq_3578.png
idk I don't use schemas
It will create one for you when you insert the first document
so like on guild join you can do something like
client.db.collection("prefixes").insertOne({id:message.guild.id,prefix:"prefix"})
here's the docs http://mongodb.github.io/node-mongodb-native/3.6/api/
what?
finding
use the docs and search find
Does anyone know if Cheerio can produce nsfw content? It doesn't SEEM like it but I haven't tested it a ton
Collections are created automatically on insert, but you need to create the database, I think the easiest way is via cli
Not collections
mb
howww
