https://regex101.com/
best regex tester btw
Regex101 allows you to create, debug, test and have your expressions explained for PHP, PCRE, Python, Golang and JavaScript. The website also features a community where you can share useful expressions.
1 messages · Page 948 of 1
https://regex101.com/
best regex tester btw
Regex101 allows you to create, debug, test and have your expressions explained for PHP, PCRE, Python, Golang and JavaScript. The website also features a community where you can share useful expressions.
🤔
or just use an api lul

@slender wagon that has nothing to do with command handlers whatsoever
much slower
slow as regex
^
even slower
so use regex and only regex
5Head

°-°"
bot.once ('ready', () => {
console.log('Ready!');
bot.user.setPresence({
status: "dnd",
game: {
name: "Type $help for help!",
type: "WATCHING"
}
})
});```
can someone help me?
the status wont show up
what version of discord.js?
^12.2.0
I made a clearwarns command but if i do !clearwarns nothing happen, any idea why? the warns are stored on mongoDB
bot.once ('ready', () => {
console.log('Ready!');
bot.user.setActivity('Do $help for help!', {type: 'Watching'});
});``` set it to this and it wont work yet
the line is broken to another one cause it cant fit discord
wdym @copper cradle, i'm basically new to everything commands handlers and alot of stuff, and also i never used async before
weird
I just use a JS for my warning system 
@slender wagon async/await has nothing to do with command handlers
yes ik
alr
i used to write everything in the main file
@earnest phoenix do I have to guess what your code looks like, what errors you get, or are you gonna show your code?
alr
can anyone help me?
bot.once ('ready', () => {
console.log('Ready!');
bot.user.setActivity('Do $help for help!', {type: 'Watching'});
});``` set it to this and it wont work yet
the status wont show up
WATCHING
what's the problem
im dumb af xD
ah
@copper cradle i forgot to send the code 😅
So, the data is stored in data base and this code should delete the warns from data base, but it doesn't ```js
warns.deleteOne({ User: wUser.id, Guild: message.guild.id })
const warns = require("../../models/warns");
let Schema = new mongoose.Schema({
Warns: Array,
User: String,
Guild: String,
})
module.exports = mongoose.model("warns", Schema)```
@earnest phoenix warns.findOneAndRemove({...}) you can try
Ok
@earnest phoenix nothing :/
impossible.
does anyone know how I can make the bot send a message to everyone in the server?
like do $broadcast message
and it sends a message to everyone
i tried this bot.on ('message', msg => { if (msg.guild && msg.content.startsWith('$broadcast')) { let text = msg.content.slice('$broadcast'.length); msg.guild.members.forEach(member => { if (member.id != client.user.id && !member.user.bot) member.send(text); }); } });
use a for loop
but it wont work
any errors?
yes
whats is it
?
i mean no
msg.guild.members.forEach is not a function
V12?
its against ToS and will get both you and your bot banned
i mean no
@modest maple Dude i wont publish the bot Im making my bot for my private server
🤷
@wet iron That doesnt change anything
Might want to use a role mention or @everyone
if its private its allowred right?
NO
@wet iron v12?
yes
It's discouraged overall
why the fuck would it being private make it allowed?
Mass Dms are still ToS breaking
Discord doesnt care if your bot is private or public
chill dude
wether its on Top.gg or not
they do not allow Mass DM bots, it is ToS breaking in every form
if you want to tell everyone about somthing use the @everyone mention
it exists for a reason
hi there. So I made a quick function in js which is supposed to fill userstatus.customstatus with something, but the problem is that the output of userstatus.customstatus is empty, but if I execute the code via a eval command it works just fine. Any idea why?
https://cdn.lumap.me/jn6uzviw.png
yes
show code @earnest phoenix
show full error
@tight plinth How does that even return an empty string, shouldn't it be "No Custom Status" if there was nothing anyways?
idfk
enable-pnpm
Do you alter it elsewhere?
@earnest phoenix modüller yüklüyse enable çek
@earnest phoenixhi bro can u help me
plz
turkish in #memes-and-media smh
didnt see the else
lumap, you need to define userstatus.customstatus first in order to concatenate it
can u help me plz
unless you did
well then
@amber fractalbro i want my bot to show its guild info like number of servers etc
can u help me plz
i dont know how to code that
@earnest phoenix yüklü yav kafayı yicem
@earnest phoenix try enable-pnpm in console
@earnest phoenix we're not gonna give you code. if you want people to help you develop the bot, we're not gonna help you
@tight plinthi have coded the bot and its ready . i just wanted to know that how to input the guild info
after let activity = ... just try to console.log the activity, that's where I'd start
read the docs
plz i request
what have you done so far regarding the guild info command, hype?
have you tried creating it?
you wont get anywhere if you just ask for help for every single code you need
it doesnt seems to log anything...
Is it with your presence?
oh sec
restarted the bot
it logs the presence
and presence.activites exists
yes it's my presence
and after a restart it seems to work
what the
cache is trash
grab args and put args as description
message.content
but
wait
you define args by splitting message content by spaces
what an interesting method
you already use message.content, and I assume you know how to split strings in javascript. just do that
like
.split(prefix.length+cmdName.length).trim()
this should give you args
should
lumap
const args = message.content.slice(prefix.length + cmdName.length).trim().split(/\s+/);```
this would be ideal
you can also separate the command from the args by using args.shift()
i mean, define them
just do message.react() twice
i made my own function that does that but
also which is better,
for (...) {
await promise().catch(handle)
}
// or
Promise.all([promise1, promise2].map(p => p.catch(handle))
``` ?
[JS] hi! I'm switch to mongo, and I would like to know how to get one specific value of a matching object. I know how to get the whole object with smth like .findOne({type:'covid'}), but idk how to get only one of its values
EDIT: wait I just realized how stupid my question is. just smth = col.findOne(stuff); smth2 = smth.smth2. but is there still a way to to what I asked quicker?
one line>* @grizzled raven
one line isnt always the case tbh, they both look nice on its own, its really only when its in a block of code
@spice smelt you could do (if this isnt py 😳) const { smth2 } = await col.findOne(stuff)
object deconstruction for the win
@grizzled raven wait I didn't understood. wdtm?
is this js or is this py
its js
do you know how to use async/await?
when you const {x} = some object it will set x to the value assigned to the key x in some object
@grizzled raven I do
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
have you done ```js
const { Client } = require("discord.js")
so in the mongo object, the key that will be named x has to already be named x ?
it can be anything
well it doesnt matter what it's called
it's just deconstructing the object into single variables
it will assign a variable from an object with that variable name
@grizzled raven actually no x) ```js
const client = new Discord.Client();
for example,
const { Client } = require("discord.js")
const Client = require("discord.js").Client
``` these are the same but one is cooler
It works either way, but deconstruction saves a line... lmao
well I'll read the MDN docs, but I still don't understand how this can find the right key if the names don't have to be the same
see look
@grizzled raven actually...yes
well in your example, smth = col.findOne(stuff); smth2 = smth.smth2., you could just do const {smth2} = col.findOne(stuff) you'd have to await it ofc so like await col.findOne(stuff) etc
you can do any of the following - ```js
const { prop } = await col.findOne({id: 123})
const prop = await col.findOne({id: 123}).then(d => d.prop)
const prop = await col.findOne({id: 123})
prop = prop.prop
or, const prop = (await col.findOne({id: 123})).prop 

I think I've understood. But in that case : ```js
MONGO:
{
id: 1,
object: {
az: 0,
er: 1,
ty: 2
}
}
js
{ ui } = collection.findOne({id:1})
Would this work? Or has `ui` to be `az` or smth?
wait so you're trying to get az and assign it to ui?
exactly. I guess it won't work, right?
yeah you can do that but it may get a bit more complicated for new people
how?
// az is the property, ui is a new variable
const { az: ui } = await col.findOne({id: 123})
great! I got it
and if we name the ui const az, then would this be ok? js const { az } = await col.findOne({id:123})
think of it this way:
// a normal js object
const object = {
key: "value"
// key is the key,
// "value" is the value
}
const { key: variable } = object
// key is the key,
// variable is the value (of the key in the original object)
// we get the value of the key "key" in the object
// now you can do stuff with variable
I need help
embed wont work
the bot crashes
i get the error
Range [EMBED_FIELD_VALUE] MessageEmbed field values may not be empty
value cant be an empty string
Did I say that im dumb? 
you can use blank characters \u200b
did you define it or did you mean to get the channel on the msg object
Adversiting????
no
Yes
Negative.
and he attempted
What is this
I assume they mean the discord invite
Deletrd XD
how i can turn on my bot on ruby?
require 'discoruby'
client = Discoruby::Client.new()
client.on :debug do |message|
puts("[DEBUG]: #{message}")
end
client.on :error do |err|
puts("[ERROR]: #{err}")
end
client.on :ready do
puts("[LOG]: Bot Ready!")
end
client.on :message do |message|
puts("#{message.author.tag}: #{message.content}")
end
client.login('token')
```i have that
for how much time does discord show the "I'm new to Discord, say hi" thing in a new profile?
have .run at the end of your code @earnest phoenix
Hope my bot gets approved
@celest shard a week
@celest shard a week
@white anvil tysm
How can I find out which Invite link the user used to join my server Discord.js?
if (command == 'vote') {
if (userData[sender.id].voted == 0) {
botData[botId].votes = botData[botId].votes + 1
userData[sender.id].voted = 1
let voteEmbed = new Discord.RichEmbed()
.setDescription('Vote')
.addField('Voted', `You have voted, there has been ${botData[botId].votes} so far.`)
message.channel.send(voteEmbed)
} else {
let voteEmbed = new Discord.RichEmbed()
.setDescription('Vote')
.addField('Error', ' Already Voted.')
message.channel.send(voteEmbed);
}
}
How can I make this where the data actually loads and saves?
if (command == 'votes') {
let votesEmbed = new Discord.RichEmbed()
.setDescription('Sync')
.addField('Votes', botData[botId].votes)
message.channel.send(votesEmbed);
}
Only shows 0 even if it has a vote
use a database
I am
if (!userData[sender.id]) userData[sender.id] = {
messagesSent: 0,
warnings: 1,
money: 100,
jobDelay: 0,
level: 0,
xp: 0,
job: 0,
voted: 0,
annoying: 0
}
if (!userData[botId]) botData[botId] = {
upvotes: 0,
votes: 0,
commands: 18,
commandsSent: 0,
messagesSentTotal: 0
}
``````js
var userData = JSON.parse(fs.readFileSync('Storage/userData.json', 'utf8'));
var statsData = JSON.parse(fs.readFileSync('Storage/stats.json', 'utf8'));
var otherData = JSON.parse(fs.readFileSync('Storage/otherData.json', 'utf8'));
var serverData = JSON.parse(fs.readFileSync('Storage/serverData.json', 'utf8'));
var botData = JSON.parse(fs.readFileSync('Storage/botData.json', 'utf8'));
{}
( ^ Database Files )
json oh god
JSON should not be used as a database
It can get corrupted
and then all the data is gone
Use Mongo or SQL
._.
It runs on heroku in github
and it works well with my work command for json
and Mongo if you scroll down a bit it litterly says : "Rich JSON Documents"
and its not corrupt even if I rebuild it it doesnt work
fun fact: mongodb is an actual db unlike a json file
not to mention it uses bson
not json

The more your bot gets used the higher the chance the JSON files will be corrupted
._.
Im not talking about corruption
Im talking about the code
I can handle that later
but im trying to fix the code
not sign up for a subscription for database storing
what
you selfhost mongodb
not pay for it
lul
same with literally everything thats sql
plus what use is working code if your "db" gets corrupted
bruh its on github if it gets corrupted it wont corrupt the file
it will corrupt the heroku file
then I can rebuild it
and lose the data
heroku cant even write to json
this big brain right here lmao
lol
the process is just runing on a vm which contains the processes
it's why the storage is ephemeral
I hAs UnLimItEd BaCkUpS uSiNg GlItcH aS mY rAiD SyTEm
bruh Im not paying I cant even pay for one
congrats you got the point of my message
you're having way too big expectations from something you're using for free
Im just trying to make a simple bot for my servers and maybe a few other servers
I would never expect it to be used for like 1k servers
and im not using glitch
I code for fun not to pay for its not a full time job :/
so do 90% of people here
let counter = Object.keys(result).length - 1;
console.log(`Channels counter in ${oldState.guild.name} are now ${counter}`)
let guild = oldState.guild;
let updateChannel = guild.channels.cache.get(mainChannel);
updateChannel.setName(`Crea Canali 👷 [${counter}/30]`)
.then(newChannel => {
/* Some Code */
})
.catch(console.error);
I have a problem with discord.js: in this code the bot cannot set the channel name with the correct value contained in the COUNTER variable. The variable contains the right value and I can confirm this from the console.log.
how often are you changing the name
@earnest phoenix The name is changed circus twice a minute. But I know this feature I'm recreating is used in other bots that change it even faster. And anyway with the same code until yesterday it worked.
Hi, i made a custom welcome channel message, but the bot is not sending any message, help?
here is the code
https://pastebin.com/FuyaJJ7U
@earnest phoenix Have you tried console logging the channel?
client.on('messageReactionAdd', async (reaction, user) => {
if(reaction.emoji.name === ':star:') {
if(reaction.message.partial) {
const fetchedMsg = await reaction.message.fetch();
const Embed = new MessageEmbed()
.setAuthor (fetchedMsg.author.tag, fetchedMsg.author.displayAvatarURL())
.setURL(fetchedMsg.url)
.setDescription(fetchedMsg.content)
.setFooter(fetchedMsg.createdTimestamp)
const starboard = client.channels.cache.find(channel => channel.name.toLowerCase() === 'starboard');
if(starboard) {
starboard.send(Embed);
}
}
}
}```
can someone help me
this is my code for starboard
and it wont send the embed
to the starboard channel
Could someone help me please : https://stackoverflow.com/questions/62092474/discord-bot-js-bot-has-no-audio-after-joining-with-play-command-no-errors-in-co
Can someone help me with JDA error? I am getting this error on start: https://hastebin.com/onazoqinob.pl
JDA version: 4.1.1_121
Java version: 11
just a sec, gonna read the error
update to 4.1.1_140
it's an error connecting to discord's gateway
compile group: 'net.dv8tion', name: 'JDA', version: '4.1.1_140' if you're using gradle
@uncut token note that the new constructor is like that:```java
JDA client = JDABuilder.create("YOUR INTENTS")
.setToken("YOUR TOKEN")
.setChunkingFilter(ChunkingFilter.NONE) //IF YOU DON'T HAVE GUILD_MEMBER GATEWAY
.disableCache(CacheFlag.ACTIVITY, CacheFlag.CLIENT_STATUS) //IF YOU DON'T HAVE PRESENCES GATEWAY
.setMemberCachePolicy(MemberCachePolicy.NONE) //IF YOU DON'T HAVE GUILD_MEMBER GATEWAY
.build()
.awaitReady();
I already have new constructor but thx man!
How can I set a guilds icon
discord.js
i couldent find it in docs
probobly just missed it
i saw it in the docs
as guild.setIcon
could i do message.guild.setIcon("url") cas it didnt work
Anyone got any tips on getting people to use my bot? I have no money to bid on tags 😦
I’m probably using wrong channel too
Anyone got any tips on getting people to use my bot? I have no money to bid on tags 😦
@ripe epoch make a good/useful bot, join servers and become active until you get a chance to talk about your bot, make a cool bot page, be very detailed in your bot's description, etc
just remember
NEVER
EVER SPAM
client.on('messageReactionAdd', async (reaction, user) => {
if(reaction.emoji.name === '⭐') {
if(reaction.message.partial) {
const fetchedMsg = await reaction.message.fetch();
const embed = new MessageEmbed()
.setColor('#0xEEC649')
.setAuthor(fetchedMsg.author.tag, fetchedMsg.author.displayavatarURL())
.setDescription(fetchedMsg.content)
.setFooter(fetchedMsg.createdTimestamp)
const starboard = client.channels.cache.find(channel => channel.name === 'starboard');
if (starboard) {
starboard.send(embed);
}
}
}
``` This is my code for the starboard but the bot wont send the message to the channel
i made a custom welcome channel message and the bot is not sending any message, i got no errors and if i do console.log i got Promise { <pending> } undefined help ?
only talk about your bot IF the context allows it
Yeah
Is there any way to get a file to a link like upload it to a image hosting site or somethign
can anyone help me?
Is there any way to get a file to a link like upload it to a image hosting site or somethign
@nocturne dagger use some image hosting site's api
client.on('messageReactionAdd', async (reaction, user) => {
if(reaction.emoji.name === '⭐') {
if(reaction.message.partial) {
const fetchedMsg = await reaction.message.fetch();
const embed = new MessageEmbed()
.setColor('#0xEEC649')
.setAuthor(fetchedMsg.author.tag, fetchedMsg.author.displayavatarURL())
.setDescription(fetchedMsg.content)
.setFooter(fetchedMsg.createdTimestamp)
const starboard = client.channels.cache.find(channel => channel.name === 'starboard');
if (starboard) {
starboard.send(embed);
}
}
}
``` This is my code for the starboard but the bot wont send the message to the channel
anyone help?
i made a custom welcome channel message and the bot is not sending any message, i got no errors and if i do console.log i got
Promise { <pending> } undefinedhelp ?
@earnest phoenix that's a promise, you gotta handle it
@nocturne dagger https://apidocs.imgur.com/

Status for the API can be found at status.imgur.com!
Imgur's API exposes the entire Imgur infrastructure via a standardized programmatic interface. Using Imgur's API, you ca...
what if the message isn't a partial lol
ok
client.on('messageReactionAdd', async (reaction, user) => {
if(reaction.emoji.name === '⭐') {
if(reaction.message.partial) {
const fetchedMsg = await reaction.message.fetch();
const embed = new MessageEmbed()
.setColor('#0xEEC649')
.setAuthor(fetchedMsg.author.tag, fetchedMsg.author.displayavatarURL())
.setDescription(fetchedMsg.content)
.setFooter(fetchedMsg.createdTimestamp)
const starboard = client.channels.cache.find(channel => channel.name === 'starboard');
if (starboard) {
starboard.send(embed);
}
}
}
``` This is my code for the starboard but the bot wont send the message to the channel
Anyone help please?
w8
about that error
i mean
it doesnt pop up anything
it wont send the message on the starboard
you're using fetchedMsg and that's only a thing when the message is a partial
@balmy knoll discord changed the rate limits
you can only change channel name and topic 2 times in 10 minutes
Yes i saw. Now i contacted the discord staff because now my bot can't work properly
you're using
fetchedMsgand that's only a thing when the message is a partial
@pale vessel what do you mean partial? I dont understand
did you code that
ooh i see im dumb
client.on('messageReactionAdd', (reaction, user) => {
if (reaction.emoji.name !== '⭐') return;
let starmsg = message;
let channel = reaction.message.guild.channels.cache.find(c => c.name == 'starboard');
let starEmbed = new Discord.MessageEmbed()
.setAuthor(message.author.tag)
.setColor("#FFFC00")
.addField(":star:", starmsg);
let limit = 4;
if (channel && reaction.emoji.name == '⭐' && reaction.count >= limit) {
client.channels.cache.find(channel => channel.name === 'starboard').send(starEmbed)
};
``` Ok I changed the code and I thought it worked perfectly but if you star a message but there are more messages beneath it it will star those messages and eventualy it turns into spam
any help?
help please
throw new TypeError("question is empty / undefined");
^
TypeError: question is empty / undefined
error
Is there any way to have the bot send a image, and then get the discordapp link from that image
just await the message, then get its attachment url
@toxic jolt check what's on line 320
client.on('messageReactionAdd', (reaction, user) => {
if (reaction.emoji.name !== '⭐') return;
let starmsg = message;
let channel = reaction.message.guild.channels.cache.find(c => c.name == 'starboard');
let starEmbed = new Discord.MessageEmbed()
.setAuthor(message.author.tag)
.setColor("#FFFC00")
.addField(":star:", starmsg);
let limit = 4;
if (channel && reaction.emoji.name == '⭐' && reaction.count >= limit) {
client.channels.cache.find(channel => channel.name === 'starboard').send(starEmbed)
};
``` Ok I changed the code and I thought it worked perfectly but if you star a message but there are more messages beneath it it will star those messages and eventualy it turns into spam
any help for me?
@quartz kindle sorry i don't follow
you need to send the message
so i have the attachment
and wait for the return value
const attachment = new Discord.Attachment(canvas.toBuffer(), 'pride.png');
message.channel.send(attachment)
what would I do after that
either await or .then()
how would i set that as a variable though
like .then(let url = message.attachments)
i'm sorry if im anoying you at all
message.attachments is a collection of attachments, since a message can have more than one attachment
you're only sending one, so its safe to use .attachments.first()
then you get the .url property from it
can you give me a example
sentMessage.attachments.first().url
const attachment = new Discord.Attachment(canvas.toBuffer(), 'pride.png');
message.channel.send(attachment).then(
let url = sentMessage.attachments.first().url
)
}
?
you need to define the return value of the .then
.then(bla => {
bla.attachments.first().url
})
ok
client.on('messageReactionAdd', (reaction, user) => {
if (reaction.emoji.name !== '⭐') return;
let starmsg = message;
let channel = reaction.message.guild.channels.cache.find(c => c.name == 'starboard');
let starEmbed = new Discord.MessageEmbed()
.setAuthor(message.author.tag)
.setColor("#FFFC00")
.addField(":star:", starmsg);
let limit = 4;
if (channel && reaction.emoji.name == '⭐' && reaction.count >= limit) {
client.channels.cache.find(channel => channel.name === 'starboard').send(starEmbed)
};
``` Ok I changed the code and I thought it worked perfectly but if you star a message but there are more messages beneath it it will star those messages and eventualy it turns into spam
If anyone knows to help me just ping.
So, I am attempting to make like a fast spotify playlist to music queue system for lavalink. I did this easily in ytdl, but I built the queue system much diffrently there. I could basically just add the name to the queue and it would load it when its going to play.
But for lavalink, it has to be loaded while in the queue, right. So my first attempt was a slow one, because I loaded each track 1 after another, causing the load time for like a 14 song playlist be like 15 seconds. So I decided that maybe it would work if I basically loaaded em all at the same time inside of a forEach and then placed them right, however I have no idea how to replace songs in the lavalink queue system, etc. Please help me, thank u!
Any idea how I would make categories for commands in html
(basically a table dropdown menu that opens another table)
const { Events } = require('util/Constants');
module.exports = (client, packet) => { const { old, updated } = client.actions.MessageUpdate.handle(packet.d);
if (old && updated) { /** * Emitted whenever a message is updated - e.g. embed or content change.
* @event Client#messageUpdate
* @param {Message} oldMessage MSG
* @param {Message}
newMessage MSG
*/ client.emit(Events.MESSAGE_UPDATE, old, updated);
} };```
why is it all one line
Didnt copy well
Anyway, I have this as whatever is being used to make the bot listen to edited messages
Not sure where it actually goes
did you just copy that from somewhere?
Yes
that will never work
it relies on internal code that can only be used from inside wherever you copied it from
Is there anywhere I can use to see and learn / use what requires to do that?
you need to use the messageUpdate event
Hey tim. So I got the mesage link to work
but, I got another error
message.channel.createInvite().then(invite => {
let embed = new Discord.RichEmbed()
.setTitle("New server joined Mission Pride")
.setDescription(invite.url)
.setFooter("Mission Pride 2020")
.setThumbnail(message.guild.iconURL)
client.channels.get('715623522218672158').send(embed)
})
.get isnt defined
cannot read send of undefined?
(node:3581) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
meant to send that with it
then the problem is client.channels
for some reason client.channels is undefined
where are you getting that client from?
console.log(oldMessage);
await oldMessage.fetch();
console.log(oldMessage);
});```
that's really weird then, what version of d.js do you use?
This only logs edited message in terminal, but doesn't respond to edited message
Is there something missing?
@nocturne dagger is this on the main file or on a separate file?
main
is it inside an event?
@fallow steppe you need to apply the same logic from your message event to it
ie: check if newMessage starts with prefix, if its a valid command, etc...
How so? I'm new to d.js sorry about it
@nocturne dagger are you doing client = new Discord.Client() in your command file?
no
I edited the message from !ping to !help, but no response from the bot, only messages being logged
good
want to see the whole command?
i guess
@fallow steppe how did you code your commands?
the same thing you did in your message event
you need to do the same in messageUpdate event
@nocturne dagger thats your command file right?
delete the bot = new Discord.Client() part
show how you use that command in your main file
yea
et prefix = ".";
let msg = message.content.toLowerCase();
let args = message.content
.slice(prefix.length)
.trim()
.split(" ");
let cmd = args.shift().toLowerCase();
if (!message.content.startsWith(prefix)) return;
try {
let commandFile = require(`./commands/${cmd}.js`);
commandFile.run(Discord, client, message, args);
Is it possible to mention someone with his name and discriminator ?
or to get his client id
Could someone help me please ? I have a music bot. He played well every day. But today i tried .play and he joined the voicechannel. he joined, had a green circle but didnt have any audio. I restarted the bot and the pc but the problem is still not solved. Also I tried to update some things. Still the problem. I used the code from crawl music bot tutorial. So the code is clean. Obviously he worked all the days beofre. I catched the video and the song in my console. And yeah he got the link and everything he needs. But the problem is the ytdl-core. I have the core 2.1.3 and discord.js 11.6.4. Didnt change anything.
@nocturne dagger you're doing .run(Discord,client,message,args)
but your command is .run = async (client, member, message)
Restarting your pc will do nothing about your problem 
message arguments are passed by order, not by name
ok
the first argument is Discord, so in your command file, the first argument is also Discord, meaning you gave it the name client but it is actually a copy of Discord
changed that
@quartz kindle sorry for late response, I code bot on glitch, and I have the command separately in commands folder. I posted this code in server.js file
hi
so
i have js client.getRESTUser(guild.moderations.filter((e) => e.kick.user === message.member.id).map((e) => e.kick.mod)) and i'm getting user_id: Value "475371795185139712,475371795185139712,475371795185139712" is not snowflake. ik what the error means and why i'm getting it, but i don't know how to fix it. if anyone can help that'd be great :)
You can get it by specifying a single user. Are you trying to get all moderators who punished the user?
no @sudden geyser
i only have the mods id, and i'm trying to get their username
wait, yeah. i am trying to get all the mods who punished the user
im pretty sure I got banned from youtube
https://i.txj69.com/ft6kh2mN5m.png
I cant figure out what is causing this error
nightmare of an API
is there a way to get the name of the currentfile you’re in? (discordjs v12)
???
like the root directory of the project?
yes or just the filename
u can do __dirname.split('\\').pop()
oke imma try that
wait
no
thats gonna giv u the folder its in
it would be __filename.split('\\').pop()
he's using js
So i have discord.js. My Discord bot worked well for 3 weeks with no changes on the script. But today he play no audio. He finds the video, get the url, joins the channel but plays no audio. So he has the audio. He knows which audio he plays. He lights green but has no sound. And i didnt get any errors. So I think the issue is the ytdl-core with dispatcher. Could someone help me pls ;)
discord.js = 11.6.4
ytdl-core = 2.1.3
Is it a music bot?
ye
no thats not why it plays audio from a youtube url
FFmpeg
I installed ffmpeg, ffmpeg-binaries, ffmpeg-statics. And it worked well for 3 weeks. Today I updated them after i got this issue
You would need FFmpeg so the bot can convert yt vids into playable music files that the bot can play
@mossy vine ffmpeg and binaries have the same version like 2 weeks before. Got no updates since 1 year or something i gues.
Nothing helpful just trying to get me to use other stuff for save the files even though thats not the problem, it works with my work command, and I use github with heroku so if I rebuild it the files will not be corrupted so its not helpful.
And @clever tree What is it running on?
node.js
K
Ill send you a download file that got my FFmpeg to work
I had the same problem
It was a heroku buildpack
but heroku buildpacks are just code added onto your project
43 seconds ago wut
So maybe this is a hint. I got a error this day with saving my index. It told me that the file is newer then on my pc. After i didnt save my file ig ot that error.
?
I got this error. Randomly after changing some normal things. Also i didnt have my bot on any websites, only on my pc.
Try to revert to before that err message
I was not able to revert. I turned my pc off yesterday when i got that error. So after i got this error i deleted the original index.js and copy and pasted the code into a new one
Game.ts?
module.exports = {
name:'announce',
description:'announce',
execute(msg) {
const Discord = require('discord.js');
const client = new Discord.Client();
if (!msg.member.roles.cache.find(r => r.name === "Staff")) return msg.channel.send('You dont have permission! :angry:');
let text = msg.content.slice('$announce'.length);
const Embed = new Discord.MessageEmbed()
.setColor('#C21807')
.setTitle('Announcement!')
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
.setThumbnail("https://us.123rf.com/450wm/dragomirescu/dragomirescu1902/dragomirescu190200619/116454959-stock-vector-grunge-blue-white-alphabet-letter-combination-bc-b-c-on-black-background-suitable-as-a-logo-for-a-co.jpg?ver=6")
.setDescription(text);
const announcements = client.channels.cache.find(channel => channel.name.toLowerCase() === 'announcements')
announcements.send(Embed)
}
}
``` `Error: Cannot read property 'send' undefined` can someone help me?
if (!announcements) return
@wary kraken what do u mean with game.ts ?
add to your code, 200 iq
Failed to save 'Game.ts'
app.get("/", (req, res) => {
//The actual discord stuff
console.log("url: " + req.url)``` for some reason req.url outputs `/` when its suppost to output `/?code=blah`
@wary kraken a screenshot from web xd
Not mine. xd
any idea why?
idk
its Oauth2 (discord)
@mystic violet
Try
`url: ${req.url}`
its not the string, the thing is. the value itself is "/"
And app.get("/"
this is how oauth2 responds
https://flexiboat.ga/?code=fR1YZozx3Maz3UQlXX2vsljxm8G2JV```
@earnest phoenix Now it wont send... and the channel exists
@wet iron remove toLowerCase() and try
You can try
`Url: ${req.url}`
If its only sending the https://flexiboat.ga/?code=fR1YZozx3Maz3UQlXX2vsljxm8G2JV
But if its not try to change it to
app.get("", (req, res) => {
//The actual discord stuff
console.log("url: " + req.url)
why you're creating new client?
@earnest phoenix cause then it wont detect the client, cause i created the command handler
client is message.client
yeah
And @earnest phoenix In Discord.js whenever a message is sent in discord.js it can be like
const Discord = require('Discord.js');
const bot = new Discord.client();
oh
@wary kraken shut , i know it.
My bot works with new

I know , i am not a new user.
client for me is a constant equal to new Discord.client()
I got a command like this:
message.channel.send("Hi! My prefix here is ${prefix}")
}``` But is not working, why so?
Do `` instead of ""
You can't use message.client ?@wet iron
@fallow steppe
if (message.content == "@dusky veldt") {
message.channel.send(`Hi! My prefix here is ${prefix}`);
}
Ok I gtg
@fallow steppe put client.user.toString() instead of your bot's id and try im sure it will work.
You can't use
message.client?@wet iron
@earnest phoenix I dont understand you now
Okay, Ill see
@wet iron so, I mean define msg.client instead of creating new Discord.Client()
No, still isn't working
@wary kraken This isn't what I mean, the first line is what I have issue with
@wet iron so, I mean define
msg.clientinstead of creatingnew Discord.Client()
@earnest phoenix I dont understand it even more now, i tried to doconst client = msg.clientbut nope
oh
i realized now
i did new msg.client
instead of msg.client
wHaT
im dumb xD
its my first time creating a bot in js
i mean
its the second
the first one got sh*t on
@fallow steppe can you try if (message.isMentioned(client.user)){ //... }
Actually
yes actually
The terminal says this: "message" is not defined
added 156 packages from 99 contributors and audited 859 packages in 27.27s
found 27 vulnerabilities (7 low, 10 moderate, 10 high)
run npm audit fix to fix them, or npm audit for details
could someone help me ?
How could i fix this issues completly. If i type npm audit fix the issues come again if i install something new
Ayy ok
@fallow steppe did you fixed?
No, still same thing
it detects some songs but not some music Bot has a problem, how can I eliminate this problem, is there someone to help?
client.on('message', async message => {
const args = message.content.slice(prefix.length).split(' ');
if (message.content.startsWith("!fortnite")) {
let username = args[1]
let platform = args[2]
fortnite.user(username, platform).then(console.log);
let embed = new Discord.MessageEmbed()
.setTitle(`${username}'s Lifetime Stats`)
.setColor("RANDOM")
.addField("Matches Played",lifetime.matches)
message.channel.send(embed)
}
})``` i get this error (node:2004) UnhandledPromiseRejectionWarning: ReferenceError: lifetime is not defined
module.exports = {
name:'clear',
description:'clear',
execute(msg, args) {
const Discord = require("discord.js");
if (!msg.member.hasPermission("MANAGE_MESSAGES")) return msg.channel.send("You dont have permission! :angry:")
if (!args[0]) return msg.channel.send("oof.")
msg.channel.bulkDelete(args[0]).then(() => {
msg.channel.send(`Deleted ${args[0]} messages`).then(msg => msg.delete(3000));
})
}
}
``` I have this giant error `UnhandledPromiseRejectionWarning: TypeError [MESSAGE_BULK_DELETE_TYPE]: The message must be an Array, Collection, or number.`
can someone help?
have both of you tried expanding ur javascript knowledge?
Fuck, what was the code for grabbing an avatar url again? discord.js
@pliant needle ^
you guys should actually try to learn
ya don't know what you're doing
@hardy vector where did you define lifetime
it isn't defined
try to like
read the error
https://flexiboat.ga/?code=blahblah doesn't work (for req.url)
http://localhost:1000/?code=KRRolAMtTeF4AxPdtkOfx30YFYFAjw works
for some reason``` any idea why?
probably cloudflare?
im so confusedl ol
sorry i dont want to just jump in but i wonderd how to sort bots from people like in this example image in my bot, i would also like to know how theyre getting users previouse name history too
hi
you do realize that this server has nothing to do with the discord team right
https://flexiboat.ga/?code=blahblah doesn't work (for req.url)
http://localhost:1000/?code=KRRolAMtTeF4AxPdtkOfx30YFYFAjw works
for some reason``` any idea why?
@mystic violet have you tried to remove the s on https it might not be able to establish secure connection try just http on your first example
ok
you do realize that this server has nothing to do with the discord team right
@copper cradle i was just wondering man chill
why do i have to keep reopening console
i mean
whenever i have no errors with my java script it sends "Ready!" and i cant type anymore
Is there any basic guideline out there on the internet on how to create a web dashboard for a discord bot?
I've searched but couldn't find much about it
not really
rip
I'm gonna have to search more general stuff then
once you are familiar with the required concepts its not hard
Yeah, the only thing related to discord is the login stuff
whenever i have no errors with my java script it sends "Ready!" and i cant type anymore
@open oracle anyone?
what diggy u keep adding reactions but not saying anything xD
-_-
@open oracle thats how cli programs work
cant type where?
once the program is running, the command line will show you that is running
oh then ^^
if the command line returns control, it means the program ended
you can force it to close with ctrl+C
Could someone help me please ? My ffmpeg for my music bot does not convert into audio. Everything works but the bot plays no audio. I reinstalled ffmpeg and ffmpeg-statics but it still dont work. No error. This issues start today after 3 weeks of working well with no problems.
h,,,,,
you can force it to close with ctrl+C
u just saved me xD
client.on('message', async message => {
const args = message.content.slice(prefix.length).split(' ');
if (message.content.startsWith("!fortnite")) {
let username = args[1]
let platform = args[2]
let data = fortnite.user(username, platform)
let embed = new Discord.MessageEmbed()
.setTitle(`${username}'s Lifetime Stats`)
.setColor("RANDOM")
.addField("Matches Played",data.lifetime.matches)
message.channel.send(embed)
}
})```node:2148) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'matches' of undefined
https://hastebin.com/lepudisepi.cs this is the data that gets logged
lifetime is in stats
oh so data.stats.lifetime.matches
yes
now i get this
(node:2175) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'lifetime' of undefined
did you console.log(data)?
i dont need to right? if im just getting the json stats
logging is usually the first step to debugging
how would i tell if the message was sent by a bot?
in what lib
wdym lib
library
normal message
discord.js, jda, discord.py
Anyone knows why ffmpeg stoped working without changes after 2 weeks ?
hey
i got my bot muted due to "Responds to other bots" any fix anyone, ping me
discord.js
node.js
https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=author https://discord.js.org/#/docs/main/stable/class/User?scrollTo=bot
thx
@sinful belfry const dispatcher = ServerMusicQueue.connection.playStream(ytdl(song.url, { filter: 'audioonly', quality: 'highestaudio', highWaterMark: 1 << 25 }))
is that what you currently have?
yes
Thats the problem: I didnt get any error. I did no changes. So it just stoped form nothing xd
maybe you're getting rate limited by youtube but the error is being swallowed somewhere
I reinstalled all of the ffmpeg packages. i have ffmpeg and ffmpeg-static. When this error started i had ffmpeg and ffmpeg-binaries. The bot joins in the channel, gets the video light up green but has no audio.
:/
@quartz kindle What should i do now xd
@sinful belfry https://stackoverflow.com/questions/62092474/discord-bot-js-bot-has-no-audio-after-joining-with-play-command-no-errors-in-co this is my stackoverflow btw :)
ah okay
i remember, i got this problem a while ago
but i really cannot remember what i did
which is irritating
ok. I could not find any result in web so i dont know what to do now xd
But how could a code break without changeing anything. Especially ffmpeg after almost a year.
why does this not work there are no errors
client.on('message', message => {
if (message.content === 'GG') {
if(message.author.bot) return;
message.channel.send(':tada:')
}})
I keep getting unexpected token but I have already reset my token and only happens in discord.js v12
@earnest phoenix check if the command author is a bot
Zod, try doing this instead:
client.on('message', message => {
if (message.author.bot) return;
if (message.content === "GG") return message.channel.send(":tada:");
}
@earnest phoenix that error has nothing to do with your token
ok
woops sorry forgot to end it
that error is caused by running an older node.js version
its alright
discord.js v12 requires node.js v12 or higher
Oh yeah oof forgot that
@drowsy grail it still doesnt work for the bot
hmm... ok
wait
I tried doing the code you did on a test bot and it worked
what is the reason why there are 2 of each command
you ran your js file twice
Let me see
oh god another hoister no hoisting
either that or you forgot to terminate a process
xD
I added black background on CSS, stills white
@earnest phoenix check if the command author is a bot
@glossy elk ill have a look thank you
f
client.on('message', message => {
if (message.author.bot) return;
if (message.content === "GG") return message.channel.send(":tada:");
});
```anyone know why this works with a bot and a user?
This is the code to post in how much servers my bot is in?
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
SHOOT
so i noticed
i have 2 commands as a prefix, how do i get rid of one?
its hosted on a vps
How i can upload video of hackers to be banned ?
@terse thunder
On what?
“hackers” = ppl you gave admin that abused it
or that gained admin thru a bot that had its token leaked
K
discord is a secure platform and no one is able to gain access to your server without you giving them access @terse thunder
(except the discord staff team)
And also if the token is leaked on the internet discord sends you a message (I had one sent to me too)
Hey ___
Safety Jim here! It appears that the token for your bot, ___ has been posted to the internet. Luckily, our token-scanning gremlins noticed, and have reset your bot's token - hopefully - before anyone could have maliciously used it!
Your token was found here: ___
Be more careful in the future, and make sure to not accidentally upload your token publicly!
Obtain a New Bot Token: ___
yes
@open oracle
then they have multiple services in support now
?
when I got my token leaked it was only github
What do you mean by "why this works with a bot and a user?"
how do i make the bot make an invite in the channel i want?
like, when someone joins my server it auto goes to a specific channel that isnt available yet due to verification, how can i fix that and make it go to a certain channel?
Lol mine was just accidently put on public
if i say "GG" it sends 🎉 and same with the bot
@coral dragon channel.createInvite
you cant change the channel the user is selecting
message.channel.send(channel.createinvite)
@open oracle
if (message.content.includes('GG')) return message.channel.send(':tada:');
@open oracle what the fuck
There
.createInvite(inviteSettings) returns a promise
if (message.content.includes('GG')) return message.channel.send(':tada:');
oh ok
Is to fix
srry xD
same thing
srry it took so long to respond had to do somethin
@wary kraken?
welp they are gone
xD
if(message.author.bot) return;
if (message.content.includes('GG')) return message.channel.send(':tada:');
anyone know why this works for user messages and bot messages?
oh ok
if(message.author.bot) return;
if (message.author.id !== '(Your Bot Id)') return;
if (message.content.includes('GG')) return message.channel.send(':tada:');
yes
I keep getting this from this code, any idea on what could be wrong?
at C:\Users\Samst\IdeaProjects\ClockMaster\index.js:64:41
at Array.forEach (<anonymous>)
at C:\Users\Samst\IdeaProjects\ClockMaster\index.js:61:16
at FSReqCallback.oncomplete (fs.js:155:23)
module.exports.help = {
name: "wcsetup"
}```
```js
jsfile.forEach((f, i) => {
let props = require(`./Commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props)
})
});```
ok. yeah. I think I wont get my ffmpeg working again. So idk. Maybe it will fix it by itself. Lets wait some days haha. Idk what went wrong, but my bot definitly wont play audio again except of playfile xd
module.exports.help = {
name: "wcsetup"
}
my bot
OKBoomer does the bot id have to be MY bot?
if (message.author.id !== '(Your Bot Id)') return;
??
thats the bot id im talking about
is that what you have in your code
with MEE6's ID
??
I didn't
wdym
hi so do any of you know how to set up a way to generate my own snowflakes
(as in ids like 296044953576931328)
????
im making it whenever MEE6 says someone has leveled up my bot says "stfu nerd"
xD
dont question it
zSnails?
@sick cloud snowflakes are glorified timestamps
i know
and i want to know how to do them
unless you can suggest a better unique identifier system
I have my commands in a folder called commands/, what do I write in server.js to make the bot listen to them?
if(message.author.bot) return;
if (message.author.id !== '(Your Bot Id)') return;
if (message.content.includes('GG')) return message.channel.send(':tada:');
```anyone know why this works for user messages and bot messages?
First if you have if(message.author.bot) return; then it ignores all bots, so the second line isnt useful
@open oracle if (message.author.bot && message.author.id !== 'mee6's is') return;
@sick cloud https://github.com/s-yadav/FlakeId
found a library for it
I keep getting this from this code, any idea on what could be wrong?
at C:\Users\Samst\IdeaProjects\ClockMaster\index.js:64:41 at Array.forEach (<anonymous>) at C:\Users\Samst\IdeaProjects\ClockMaster\index.js:61:16 at FSReqCallback.oncomplete (fs.js:155:23)module.exports.help = { name: "wcsetup" }``` ```js jsfile.forEach((f, i) => { let props = require(`./Commands/${f}`); console.log(`${f} loaded!`); bot.commands.set(props.help.name, props) }) });```
@gritty bolt
can someone help with this
?
@knotty steeple so that works great but the ids are like in the 9800000000 region, how can i get them to start lower
that's completely normal lol
read Twitter's doc on snowflakes to see how snowflakes behave
it's in their archives i think
timeOffset : (Defaults to 0) Time offset will be subtracted from current time to get the first 42 bit of id. This help in generating smaller ids.
i know
you can set it to the first second of today or something, has to be a value that doesn't change if you want consistency
discords epoch is the first second of 2015
how would i get the first second of today then
you're a cert dev shouldn't you know that lol
working with dates is like fundamentals but ok
i'll google it if all you want to do is call me an idiot
oof
still erroring
still wont open up
have you checked status.glitch.com?
Hey is it hard to make a discord bot
Hey is it hard to make a discord bot
@sharp pond It is not
You can make a bot from botghost.com
I have made one and it is in approval
botghost !== coding bot
is it safe to use?
Yes
no
they said make though
you can just visit its website
xd
it says this
see this bot
it says error
It does not say error
Unmodified instances aren't allowed.
is this safe to use
i have made 2 bots with botghosts
Also @late egret no one can view that besides you / moderators as it's not yet approved/declined yet.
its from ghost bot
@sharp pond yes it's safe. Most dashboards require that.
ok
its from ghost bot
@sharp pond it is botghost.com
don't suggest them that site
it teaches you nothing
^
how do you like invite the bot to your server?
A small calculator that generates Discord OAuth invite links
Does the botghost host it?
host what
hey so i have this sort of layout and was wondering how to get the side div to stick while the other div and it's content scrolls
so like there'll be a pinned sidebar
@sick cloud - position: fixed
Or position: sticky
Read up on those
OR - use flex
Which is prolly easiest
cool ok
how do i find a role by it's ID?
Like how you search a member/user by its id
get it from client/guild
try to avoid getting stuff from client
alright
(node:8112) UnhandledPromiseRejectionWarning: TypeError: fn is not a function
(from the discord.js file)
what do
what is your discord.js and node.js version
Still Wondering how to get the user's nitro badges without the oauth2 authorization
How can I convert the "joinedTimestamp: 1590819577442" to a normal date?
use moment package
How can I convert the "joinedTimestamp: 1590819577442" to a normal date?
message.member.joinedat
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Jassm\Desktop\Alpha\modules\core\error.py", line 18, in on_command_error
ctx._ = functools.partial(ctx, cog="ErrorHandler")
TypeError: the first argument must be callable``` help
An hour is 60 minutes
so that's not an hour?
it adds 1 hour to my giveaway timestamp
but i need to only add 1 minute
I'm getting a feeling you're getting milliseconds there
yeah those are milliseconds
Well those calculations aren't needed
you're getting minutes (60), seconds (60), and then milliseconds (1000)
oh
.setTimestamp(Date.now() + (stated_duration_minutes *60*60*1000))```
wait i think i got it
yup fixed it
ty
i just left the milliseconds for a minute as the bot only works with minutes
if i have a string that's exactly true or false, how do i convert it to a boolean accurately, without using string checking
I just got this message from discord: It appears your bot, *bot name*, has connected to Discord more than 1000 times within a short time period. Since this kind of behavior is usually a result of a bug we have gone ahead and reset your bot's token. but I have no idea why, I haven't changed the code for a while so is it possible that this is a host issue?
did you restart it really often?
how many times are you using this in your code?
new Discord.Client
Hello, so I have a question regarding this guild list. Is there a way to add pages to this list as it does not show all the servers the bot is in?
Thanks for your help!
yes you can make a for loop and first get guild 0-24 (max 25 fields), then 25-49 etc.
In discordjs is there a quick way to list a count of all voice connections
yes, I think you can filter all guild members so you know which are connected a a voice channel
hmmm
How do I get total guild count for all shards using eris sharder?
I mean, dunno if Eris screws this up/has some sort of thing that will make normal code break... but just do a broadcastEval and sum the results?
Can a bot publish a news in a news channel? [discord.js]
do you mean an announcement channel?