#development
1 messages · Page 614 of 1
no
message.author.send() is correct
you dont need to open dm channels it happens automatically

theres always people online
kk
So I have an afk bpt
bot
so whenever u do !afk
u go afk
u know like dynos
client.on('message', async message =>{
if (message.channel.type === "dm") return;
if (message.author.bot) return;
let prefix = process.env.PREFIX;
let messageArray = message.content.split(" ");
let cmd = messageArray[0].toLowerCase();
let args = messageArray.slice(1);
let cmdFile = client.cmds.get(cmd.slice(prefix.length));
// return message.reply(`You are now not afk.`).then(msg => msg.delete(5000));
// return message.channel.send(`${user_tag} is afk. Reason: ${key.reason}`)
if (message.content.includes(message.mentions.users.first())) {
let mentioned = client.afk.get(message.mentions.users.first().id);
if (mentioned) return message.channel.send(`${mentioned.usertag} is afk. Reason: ${mentioned.reason}`);
}
let afkcheck = client.afk.get(message.author.id);
if (afkcheck) return [client.afk.delete(message.author.id), message.reply(`You are now not afk.`).then(msg => msg.delete(5000))];
if (!message.content.startsWith(prefix)) return;
if (cmdFile) cmdFile.run(client, message, args);
});
but this is bmy code
and when i do @mention it doesnt respong
no error, discord.js
how you make the bot update the photo it creates? The picture is updated by the NWS and the URL stays the same, the problem is that it shows the older photo instead of the updated photo.
if(!player){
player = JSON.parse(fs.readFileSync("./backup.json", "utf8"));
fs.writeFile("./player.json", JSON.stringify(player), (err) => {
if(err) console.log(err);
});
}
``` Can I know how can I make a if function that define if there is an error in a variable? I tried doing the one above but it doesn’t work. Is it because !player means if the player object doesn’t exists?
hey does anyone know some good templates for a command page on bootstrap like I already have the website just got to get the page content for the commands list something like pancakebot or dynobot would be cool
just making the commands page on my website
so in discord.js the MessageReaction has a property called me, which is always true no matter who adds the reaction. is this the expected behavior or is something funky going on?
In JDA, i've the message ID, how to get the message ?
I use this: event.getChannel().retrieveMessageById(event.getMessageId()), it's ok ?
@earnest phoenix event.getMessage()
@solid cliff I can't, it doesn't exist
net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
is it normal that bots can delete a webhook even by not having the manage webhooks permission?
I have a message duplication command that creates a webhook, send a message for each message with it and deletes it, but when I removed all of it's permissions right after it started to duplicate messages it was still able to delete the webhook
probably a permission messed up or channel overrides
if you checked all of those probably its better to official d.api server
I'm sure enough that it doesn't have the permission, because it can't create the webhook when it doesn't have those permissions, but still able to delete it once it's created
even with channel overrides or such?
look
it fails on create if it can't
so I'm sure of it
actually lemme try something
ok yeah, just tried by getting rid of the permission check regarding the webhook creation
Command raised an exception: Forbidden: FORBIDDEN (status code: 403): Missing Permissions
so it is able to delete the webhook freely without having the permission to
what 
I'm continuing this convo in dapi
thats interesting
const c = new (require("discord.js").Client)(), USER_ID = "Insert_ID_Here";
c.on("presenceUpdate", (o,n) => n.id===USER_ID && n.user.presence.status === "online" && o.user.presence.status !== n.user.presence.status ? c.users.get("334083271354744832").send(n.user.username + " is online") : null);
c.login(process.env.token);
how do i make this into a bot
and is this working properly?

I’d recommend looking up youtube bot tutorials
you run the bot
i'll check youtube for that then, any specific things i should search for to help me? 
You’ll need to go to discord online and go to the dev portal
And add a bot their, that’s where you’ll get your bots ID and such
You’ll also need to run some terminal execs to set up the library for the bot (on wherever your hosting it)
You’ll need to install the discord.js library
Etc
The tutorials will explain that a bit more detailed
Np
Make sure you have a code/text editor as well. Thers several good ones out ther
notepad++ is good?
ah
pretty sure he just wants to host it
he has the code, just needs to host it. no need for programming knowledge there
oh
Yeah
this is kinda complicated O.o
can someone simplify it so someone like me (a retard) can understand? S:
You just gotta get a tutorial and follow it step by step lol
https://skl.sh/designcourse20 - First 500 people to sign up will get their first 2 months free! -- I've had a lot of requests to cover Discord.js, so here it...
will this one work? 
here
start with learning to code
then start at https://discord.js.org/#/
I’d use both that tutorial and the database creeper sent
const c = new (require("discord.js").Client)(), USER_ID = "Insert_ID_Here";
c.on("presenceUpdate", (o,n) => n.id===USER_ID && n.user.presence.status === "online" && o.user.presence.status !== n.user.presence.status ? c.users.get("334083271354744832").send(n.user.username + " is online") : null);
c.login(process.env.token);
this is the code i want to use, is this enough? 
That’s it?
@junior sail xou need the token
he already has that
@grizzled spruce yes, only that x)
Ak. ok
Again I wouldn’t actually host that code I gave you... it’s really poorly written and hard to manage... I only did it to prove a point cuz someone said they could write better spaghetti code than me, so...
I think it was Cyber prob lol
i wish i could write code
Well you can, there are lots of guides
i think it was @mossy vine that challenged you or something xd
i mean, i only wanted to have this bot, other than that i don't have much interest 
i would recommend using sublime text as your editor, has a lot of features for beginners
for JS vscode might give more support to newer devs
but sublime is great too
if you want to be elitist use vim tho
well yea the biggest thing is that sublime text can be used on just about everything
yea
plus it's totally free 😃
I might be wrong, but I believe you have to be certified to use that
gotcha
ironically you did it the right way at first, there must be some kind of other reason why it doesn't work in specific situations
On load
I don't even know why erlite told you to put a js code there, why not just put an html comment instead?
I tried comment
I think what you can do is ask how other devs made their iframes work smoothly
like this one
the issue with iframes is if you don't have your website responsive it can be a mess
I have responsible but i cant manage to make it fit
fonction.channellogs(message)
if (!Dresseurs[sender.id]) return message.channel.send("Erreur : `Vous devez être un Dresseur pour effectuer cette commande : ?start`")
let xoargs = message.content.split(" ").slice(1);
let xo03 = xoargs.join(" ")
if (!xo03) return message.channel.send("Erreur : `Entrez le nom du pokémon après le ?setfamilier`")
const filterItems = (query) => {
return (Dresseur.Sac.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) > -1))
};
if (filterItems(xo03)[0] == Dresseur.Famillier) return message.channel.send("Erreur : `Ce Pokémon est le même que celui que tu as actuellement ...`")
if (Dresseur.Sac.includes(filterItems(xo03)[0]) || (Dresseur.LSSac.includes(filterItems(xo03)[0]) || (Dresseur.SSac.includes(filterItems(xo03)[0]) || (Dresseur.LGSac.includes(filterItems(xo03)[0]))))) {
Dresseur.Famillier = `${filterItems(xo03)[0]}`
Dresseur.SoonNA2 = ''
//Dresseur.Sac[Replacing] = Dresseur.Famillier
//.setImage(Pokemon.Gifs[FinalRand])
Test2 = Gall.Noms.indexOf(Dresseur.Famillier)
const familier = new Discord.RichEmbed()
.setColor(embedcolor)
.setTitle(`__Définis avec succès :__`)
.addField(`Nom :`, `${Dresseur.Famillier}`, true)
.addField(`Surnom :`, `"${Dresseur.SoonNA2}"`, true)
.setImage(Gall.Gifs[Test2])
message.channel.send(familier)
}
else {
message.channel.send("Erreur : `Pokémon introuvable, sois vous ne l'avez pas capturé sois vous l'avez mal orthographié ex : ?setfamilier Roucool (Normal)`")
}
}```
My code work but I can't make this const filterItems = (query) => { return (Dresseur.Sac.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) > -1) && (Dresseur.SSac.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) > -1)) }; Why ?
return (Dresseur.Sac.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) > -1) && (Dresseur.SSac.filter(el => el.toLowerCase().indexOf(query.toLowerCase()) > -1))
=
return (filter && filter)
= return(true/false)```
Hu ?
you're using && wrong
your function returns the result of the && condition
it will always return either true or false. it will never return the filtered object you want
what would you use to invert the colors on an image within node js?
@cold niche you can use an image processing library like sharp
hi
what would you recommend, sharp or gm?
you're using && wrong your function returns the result of the && condition it will always return either true or false. it will never return the filtered object you want
So i can make what I want ...?
you can use Object.assign for example, to combine two objects
🤔
but it depends on how your data is structured
This is in a json
you're getting data from Dresseur.Sac and Dresseur.SSac, what are they? are they both the same structure?
Dresseur.Sac and Dresseur.SSac is ["1","2"]
ah so they're arrays
Yes
then you can use array.concat()
🤔
what the fuck
300 iq code
i dont even want to understand whats going on
im pretty sure neither does the op
^
let sac = Dresseur.Sac.filter(...);
let ssac = Dresseur.SSac.filter(...);
return sac.concat(ssac)```
Oh yes it's better ?
its easier to understand
Hey is there documentation for a setwelcome command for js?
what is a setwelcome
some random person said: "just make a command that does !setwelcome #channel"
people just think that there are docs for every individual command
so join messages?
yeah he wants join messages
So now i'm confused
because this server only accpets them in #265156361791209475
- get channel from message
- save it to a db
- when a member joins, find the channel with id from the db and post the message
easy
the rest is on you young jedi
like just use quick.db lol that is so easy as its just a wrapper
what
There are bots which already does welcome messages
if it is your bot
you need to set logging messages like welcome/leave in #265156361791209475
Yes I know my bot does a Welcome thing and the channel has to be Welcome to send...
Then it will spam errors in terminal
You should learn how to make it for custom channels
can I send code?
If you want help you can send the code in #development however we will not baby feed you the code to make it custom
Ik
usually custom welcome channels require a database
I have this
bot.on('guildMemberAdd', member => { member.guild.channels.get('channelID').send("Welcome"); });
yes
So I would put the #265156361791209475 channelId in it and ill be fine
you could make it ignore welcome messages only here
idfk how because I am not in js
Question: Lavalink.jar, which folder should I place that in? Same one as my main application, or in node_modules?
is there a node java?
not specifically, but discord.js-lavalink runs off a server run by a jar file
ah
Just tryna figure out if it matters where it's located
it really doesnt matter
you yourself said it's a server
as long as the jar file is open lavalink will have it's server ports open
@pliant needle you need to run Lavalink.jar
Yeah, I got that
Where you place it doesn't matter
I appreciate it n.n
java -jar Lavalink.jar
I tried to install bufferutil when this happened...
https://gist.github.com/SinistreCyborg/f62478727bab9eabbce3add125050358
the native code is broken
Was wondering how do you improve and test a bot without it affecting other servers it is currently on?
or do what I do and make it modular
then unless you need to change the core application, your bot is up 24/7 while you dev on the same api key
How can I get my bot to track when someone has voted for my bot?
webhooks
that is the most contradicting statement i've ever seen
Ok thanks
hmm
how do i create configs for a guild
like for example: if i wanna make a prefix only available for 1 guild
custom prefix?
yes
ohh
yea
@buoyant wagon
i wanna set a prefix as a server config
so do i have to like make a table
and then
db/{table}.add(`welcomechannel_{guild.id}`, arg)
</@earnest phoenix >
i guess you could do that
its going fine but the prefix doesnt work
let prefix = ">"
let fetch = db.fetch(prefix_${msg.guild.id})
if (fetch === null) prefix = ">"
else prefix = fetch;
something happened
this code just breaks the prefi
prefix*
db.set
the prefix is undefined
hmm maybe use if (!fetch) prefix = ">"
or if(fetch) cuz prefix already set to that ?
loop through the members, increment a variable if their status is set to online, use the variable
example please
what lib are you using
discord.js
let onlineMembersCount = 0;
<Client>.users.forEach((value, key, map) => {
if(value.presence.status == "online") onlineMembersCount++;
});
i didnt test it, but it should work :p
@mossy vine
add console.log(onlineMembersCount)
ok
or return it
@mossy vine nice its work thanks for helping me
youre welcome
isn't it more efficient to just use .find or .filter?
most likely
the most efficient way would be to use for
any errors?
it's .toString()
depends on what kind of bot is it
multipurpose
also
a http request returns something like this
[{'abc':'123','link':'template'},{'abc':'345','link':'template'}]
this is in json format
how do i get a random element from that and get its link
you parse the json and do what u do with a object in an array
ok
guys when i tried to change the server prefix config it didn't change the data for some reason
this is what i did
prefixes.fetch(`prefix_${msg.guild.id}`)
prefixes.set(`prefix_${msg.guild.id}`, args[0])
A rather unrelated question, however, in c++, when inputting characters in the console, there seems to be a 4094 character limit. Is there any way to work around this limit or is it hard set?
I have always this error when i start the bot with pm2
https://gyazo.com/5ea299d5b1dcdd4372c7b844d190cb9f
you're trying to read a non-existent folder, or your path is wrong
it exist and when i run it locally it wokrs
locally you mean your computer, right? and the bot is in a server?
yes
does the folder exist in the server as well?
yes
is the path the same there?
yes
can you post your code and your folder structure?
the folder structure of the server
hmm, you have ./ in your readdir and ../ in your require
@limber swan its because of how fs works. Try fs.readdir(`${__dirname}/commands/`)
Nop
What does that log tho
the same
you didnt post your folder structure so idk what you're working with
but you're trying to access two different locations in that code
you're trying to read the commands folder in the same directory your bot is in, and you're trying to load a file in a parent folder
^
that's an issue, but it looks like the error is related to files being undefined?
so, what i do
yeah
Still same error
console.log(__dirname)
^ do that before you attempt to read the directory if you can. it's not clear where this file is relative to your other files
async with aiohttp.ClientSession() as session:
address = "https://ow-api.com/v1/stats/pc/global/%s/profile"%(name)
async with session.get(address) as response:
if response.status == 200:
data = await response.json()
return data
elif response.status == 404:
raise Exception("account not found. Please try again!")
elif response.status != 200:
raise Exception("an error occured, sorry for the inconvenience!")
loop = asyncio.get_event_loop()
loop.run_until_complete(self.getInfo(address))
im getting this error: argument of type 'coroutine' is not iterable
can someone help me?
Can i get help?
Code: ```bot.on('guildCreate', guild => {
let Joining_Welcome = new discord.RichEmbed()
.setFooter(Thanks for adding ${bot.user.username}!)
.setDescription("Hello! My name is: Sky Bot. ")
.addField("Prefix", My prefix is \s!` You can change it: `s!setprefix <new prefix>`) .addField("__**Started**__" , To get started say `s!help` for see All commands.`)
if (guild.systemChannel) return guild.systemChannel.send(Joining_Welcome)
bot.guilds.find(guilds => guilds.id === guild.id).channels.forEach(channel => {
if (channel.type !== 'text') return;
function getchannel(channel, guild){
let Random_channel = channel.calculatedPosition(Math.floor(Math.random() * guild.channels.size))
}
try{
Random_channel.send(Joining_Welcome).then(
function(){
return;
}
)
}catch{
getchannel(channel, guild)
}
})
})```
error?
Error:TypeError: channel.calculatedPosition is not a function at getchannel (C:\Users\User\Documents\Sky Bot\index.js:55:38) at bot.guilds.find.channels.forEach.channel (C:\Users\User\Documents\Sky Bot\index.js:65:11) at Map.forEach (<anonymous>) at Client.bot.on.guild (C:\Users\User\Documents\Sky Bot\index.js:51:62) at Client.emit (events.js:189:13) at ClientDataManager.newGuild (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\ClientDataManager.js:35:21) at GuildCreateHandler.handle (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:17:26) at WebSocketPacketManager.handle (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65) at WebSocketConnection.onPacket (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
oh
If started channel removed it sent this: ```TypeError: channel.calculatedPosition is not a function
at getchannel (C:\Users\User\Documents\Sky Bot\index.js:55:38)
at bot.guilds.find.channels.forEach.channel (C:\Users\User\Documents\Sky Bot\index.js:65:11)
at Map.forEach (<anonymous>)
at Client.bot.on.guild (C:\Users\User\Documents\Sky Bot\index.js:51:62)
at Client.emit (events.js:189:13)
at ClientDataManager.newGuild (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\ClientDataManager.js:35:21)
at GuildCreateHandler.handle (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:17:26)
at WebSocketPacketManager.handle (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
Can I get help?
I guess this is an error? My bot wont reply to anything in this server and idk why
What is error?
The red is not error
Can I get help? ^^
that's a deprecation warning
try your best not to use deprecated terms even if they work
since they're discontinued
@earnest phoenix i presume somewhere in your code you have <#Collection>.find('name', 'pink') or something like that... you should change it to <#Collection>.find(r => r.name === 'pink')
Can I get help???????????
and may be removed or something
@earnest phoenix i will try my best to help
Okay
@earnest phoenix just do calculatedPosition
go on
what is channel?
let Joining_Welcome = new discord.RichEmbed()
.setFooter(`Thanks for adding ${bot.user.username}!`)
.setDescription("Hello! My name is: **Sky Bot**. ")
.addField("__**Prefix**__", `My prefix is \`s!\` You can change it: \`s!setprefix <new prefix>\``)
.addField("__**Started**__" , `To get started say \`s!help\` for see All commands.`)
if (guild.systemChannel) return guild.systemChannel.send(Joining_Welcome)
bot.guilds.find(guilds => guilds.id === guild.id).channels.forEach(channel => {
if (channel.type !== 'text') return;
function getchannel(channel, guild){
let Random_channel = channel.calculatedPosition(Math.floor(Math.random() * guild.channels.size))
}
try{
Random_channel.send(Joining_Welcome).then(
function(){
return;
}
)
}catch{
getchannel(channel, guild)
}
})
})```
@lament meteor I want it do random channel
stable or master
why do you have a function in a for loop?
from what I know stable has channel.position
also can u do this
```js
code here
```
oh
neither are deprecated
do this guy use mast er or osmething
@lament meteor but that wouldnt stop it from replying in other servers would it?
probs stable saya
My bot works in every server I have it in expect this 1
hmm
@lament meteor Can I GOT HELP??
do you have anything in ur code that has like if (message.guild.id === 'some numbers') return?
so ok for now
me?
explain what that code trying to do
Probably
the indents is killing my eyes
I would only do that for private commands though
first thing I noticed is
its not a function
^
why you are using it as a function?
I said it is not a function
why you are using it as a function?
Error: TypeError: channel.calculatedPosition is not a function at getchannel (C:\Users\User\Documents\Sky Bot\index.js:55:38) at bot.guilds.find.channels.forEach.channel (C:\Users\User\Documents\Sky Bot\index.js:65:11) at Map.forEach (<anonymous>) at Client.bot.on.guild (C:\Users\User\Documents\Sky Bot\index.js:51:62) at Client.emit (events.js:189:13) at ClientDataManager.newGuild (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\ClientDataManager.js:35:21) at GuildCreateHandler.handle (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:17:26) at WebSocketPacketManager.handle (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65) at WebSocketConnection.onPacket (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35) at WebSocketConnection.onMessage (C:\Users\User\Documents\Sky Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
If started channel removed it sent this^^
its not a function
and why do you have functions in a for loop
Code ```bot.on('guildCreate', guild => {
let Joining_Welcome = new discord.RichEmbed()
.setFooter(Thanks for adding ${bot.user.username}!)
.setDescription("Hello! My name is: Sky Bot. ")
.addField("Prefix", My prefix is \s!` You can change it: `s!setprefix <new prefix>`) .addField("__**Started**__" , To get started say `s!help` for see All commands.`)
if (guild.systemChannel) return guild.systemChannel.send(Joining_Welcome)
bot.guilds.find(guilds => guilds.id === guild.id).channels.forEach(channel => {
if (channel.type !== 'text') return;
function getchannel(channel, guild){
let Random_channel = channel.calculatedPosition(Math.floor(Math.random() * guild.channels.size))
}
try{
Random_channel.send(Joining_Welcome).then(
function(){
return;
}
)
}catch{
getchannel(channel, guild)
}
})
})```
I sent what you need
its not a function
lemme clean this code a bit
its a property
@sinful lotus ok thanks
use it as a property and not a function
omg
what
bot.on('guildCreate', guild => {
let Joining_Welcome = new discord.RichEmbed()
.setFooter(`Thanks for adding ${bot.user.username}!`)
.setDescription("Hello! My name is: **Sky Bot**. ")
.addField("__**Prefix**__", `My prefix is \`s!\` You can change it: \`s!setprefix <new prefix>\``)
.addField("__**Started**__" , `To get started say \`s!help\` for see All commands.`)
if (guild.systemChannel) return guild.systemChannel.send(Joining_Welcome)
bot.guilds.find(guilds => guilds.id === guild.id).channels.forEach(channel => {
if (channel.type !== 'text') return;
function getchannel(channel, guild){
let Random_channel = channel.calculatedPosition(Math.floor(Math.random() * guild.channels.size))
}
try {
Random_channel.send(Joining_Welcome).then(
function(){
return;
}
)
}catch{
getchannel(channel, guild)
}
})
})```
what
another thing is that code is just so messy
issues with the code:
- don't create a function in a function
- calculatedPosition is not a function
- Random_channel was never defined outside the function
What's happens if you have 2 bots with the same prefix in 1 server ?
@earnest phoenix they both respond
bot.on('guildCreate', guild => {
const Joining_Welcome = new discord.RichEmbed()
.setFooter(`Thanks for adding ${bot.user.username}!`)
.setDescription("Hello! My name is: **Sky Bot**. ")
.addField("__**Prefix**__", `My prefix is \`s!\` You can change it: \`s!setprefix <new prefix>\``)
.addField("__**Started**__" , `To get started say \`s!help\` for see All commands.`)
if (guild.systemChannel)
return guild.systemChannel.send(Joining_Welcome).catch(() => null)
for (const channel of guild.channels) {
if (channel.type !== "text") continue
if (!channel.permissionsFor(guild.me).has(['VIEW_CHANNEL', 'SEND_MESSAGES', 'EMBED_LINKS'])) continue
channel.send(Joining_Welcome).catch(() => null)
break
}
})
@earnest phoenix this is literally what you want to do without complexity
I know how fix it. all good
use that as your reference for your future endeavors
i fixed it
your choice, I gave you a better looking code
its up to you whether you want to learn better ways or not
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
at Client.emit (events.js:178:17)
at WebSocketConnection.onError (C:\Users\User\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:374:17)
at WebSocket.onError (C:\Users\User\node_modules\ws\lib\event-target.js:128:16)
at WebSocket.emit (events.js:189:13)
at _receiver.cleanup (C:\Users\User\node_modules\ws\lib\websocket.js:211:14)
at Receiver.cleanup (C:\Users\User\node_modules\ws\lib\receiver.js:557:13)
at WebSocket.finalize (C:\Users\User\node_modules\ws\lib\websocket.js:206:20)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)```
@sinful lotus it ur code
I see
what I made is your code I just changed the loop
add client.on('error', console.error)
i fix it
Anyone know why my bot only works on my servers ?
You must have it set to only accept commands from a certain server id
What of this shit is totally useless?
everything
Does the message event fire for webhooks?
for webhooks, or from webhooks?
yes
no
webhooks dont connect to the gateway
they only make rest requests, message sending specifically
I believe he meant, if a discord webhook sends a message to a channel, does said message fire the message event
Which yes it does
how can i make it, that my bot sends messages to a special channel?
i use discord.js
guild.channel.find(args).send
instead of args i write the channel id right?
if ur using id then you can use get on client.channels
ok, thanks
Can I send someone a link to my code so they can help me figure out why my bot doesnt work on other servers
its about bot development
Yep
it's not about bot development it's about bot rebranding
also both names are bad you should call it m335
One message removed from a suspended account.
One message removed from a suspended account.
@commands.Cog.listener()
async def on_member_remove(self, member):
welcome_channel = self.bot.get_channel(channels.channel_dict["joins&leaves"]) # get the welcome channel
await welcome_channel.send("*" + member.name + "* has left the server.. They will be missed..")
for guild in bot.guilds:
for channel in guild.channels:
def is_me(m):
return m.author.id == member.id
await bot.purge_from(channel, limit=100, check=is_me)
``` Trying to code bot to remove all of users' messages upon leaving. I am having trouble because of the migrating.....
this is massive api spam
you remove his messages from all of the servers your bot is in and all of the channels in them
One message removed from a suspended account.
discord has it's own remove feature on banning this is just absured
One message removed from a suspended account.
One message removed from a suspended account.
@sage bobcat can you send the code of pingerino
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i don't understand this "api spam"
One message removed from a suspended account.
pastebin
One message removed from a suspended account.
One message removed from a suspended account.
the bot is only in one server (mine) lmao
then why for guild in bot.guilds
One message removed from a suspended account.
One message removed from a suspended account.
make sure you are in the correct folder
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
that means it executed successfully
yes but it stops running
meaning, something in your code is causing it to terminate
without him closing it
that usually happens when you dont have any event listener
One message removed from a suspended account.
One message removed from a suspended account.
he clearly has
One message removed from a suspended account.
One message removed from a suspended account.
the syntax is off
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
what's that?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
the last lines
One message removed from a suspended account.
it's not on the paste you sent
One message removed from a suspended account.
One message removed from a suspended account.
it should be outside
One message removed from a suspended account.
you also didnt close the array in fields
One message removed from a suspended account.
One message removed from a suspended account.
thats stupidly wrong
One message removed from a suspended account.
One message removed from a suspended account.
lmao
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
np
I'm stuck in a stumpilitous spot, how would I go about making sure that links people send aren't containing specific bad words (i know but its what i do lemme alone); So what I have right now is a certain set of links are uncensored because the thing that happens is when people do links that are images for example contain random characters to create the link etc. and the bot has some regex .+'s so it gets caught up some times. But now I'm encountering a problem like whatever.com/fuck is no longer censored. How should I go about actually doing this, I doubt theres any way to test if a string of characters is random etc. maybe seeing if the site is real? I really dont know halp plag
word filters are a pain in the ass, if you want to keep your sanity, just dont do it
there will always be a new way to bypass the filtee
ive already done it and pretty well at that
making requests to random sites to see if theyre valid is a huge security issue btw
im talking specifically about links
yea ik
im just tryin to brainstorm :/
cuz idk how i would go about this
bad_words = ["fuck"]
content = "whatever.com/fuck"
for bad_word in bad_words:
if bad_word in content:
print("user said a bad word, now calling their mommy")
``` @slim heart
is that not what i sent
a link is a string
you see if the string contains a bad word
read the question pls
cuz im uncensoring certain links because they have random strings
but sometimes people can find this and add the bad word to it
if your ultimate goal is to make sure links and the message itself does not contain a bad word, then why wouldn't my solution work
if people do something like this
https:/google.com/wfgiwejiodKCkijw.png
its not a real thing but for example, it'll pick up on f.+ck so i uncensor google.com but then https://google.com/fuck isnt censored
uh, then why even use a regex that matches so many things then if you want it to be exact
because i dont want it to be exact
the point is to include a lot
but then problem comes in when there's random strings involved
why do you want it to include a lot...
so that its not easy to bypass
I need an unconventional method of solving this, i dont want to have an argument over what already works well please
then just use the levenshtein distance
i'm asking these questions because the way you want to approach this is very hard to do and unnecessary
because i cant nor will just like make it less recognizing etc. i need something that isnt simple because im willing to be all those simple things would ruin what i already have
500% not a weebToday at 6:14 PM
then just use the levenshtein distance
making it match everything will create so many false positives
Probably check the similarities of the strings in a link to censored words?
ive worked to make sure it doesnt
i have a list of bypasses with each key, it just works im not talkin this :p
friends up cats kite would be a false positive under your "algorithm"
its argument by argument
split by spaces*
and actually half the time the curses are contained within said phrase
can you give me some examples or something
theres litterally like links such as whatever/weoij__FuC__saj.png etc.
you need to realize nobody is able to help you because you're acting very arrogant and unable to provide examples or anything
im kinda at a loss right now for anything specific cause my solution to those links are literally just adding them to uncensor lol
censor this: fuck
censor this: aafuckaa
also censor this: whatever.com/fuck
but, do not censor this: whatever.com/aafuck
correct?
idk whatever nvrm theres nothing i can really do 
🤷
then you need to rethink how you want the system
my proposed solution would probably be enough if you also make it ignore links (anything with https?:// or www.)
i mean what ive done with the system is something unique and works very well;
and the links ignoring is then anyone can be like https://fuckyou
then if they shouldn't be able to do that, but the "fuck" can be a part of the domain (such as google.com/aaafuck123), then you're kinda contradicting yourself with what you want
either you allow it in the link or not
maybe you could allow it in the domain path only and not the domain name part?
but the domain path is usually the problem
it has random strings that can set off the filter
i can't help you if you don't even know what it should do
just nvrm
k
Someone help me for God's sake, I'm 12 days trying to make a bot command to block someone by the id of using the bot, please, if you're reading know, help me please!
Use a database to store the id of the blacklisted person and every command is checked to see if they see in the database if they are it will not respond and if they aren't then the bot will respond
I tried, however, for several annoying bugs that I can not solve
1.) what code are you using?
2.) what are the bugs?
trying to run my bot through AWS can anyone lend me a hand? im stuck
Steps on doing that.
- Learn to use a database, probably use mongo if you dont want to deal with sql
- Once you learned how on using it, make a command that takes a user id as a parameter
- Fetch and see if you can access this user, if you can access it meaning theres no error in fetching the user save the ID to the database
- on your command handler, when the bot knows the command exists, do a query to database if the msg.author.id is saved on your blacklist database, and if it do exists, return
@glacial pecan
Mongo changed their license, didn't they?
send the whole log
@earnest phoenix I have tried through AWS, but hasn't worked. if you find a way to do it with python, please tell me!
hello i am new to this can i get some help plz
notwhatimeantbutk
We cant help if you dont tell us your problem xD
right...ok so is it possible to learn programing and coding by u or anyone..im good with tech but not that great at coding and programming
ok...s-sorry to bother...
o-oh g-god w-why d-do you s-stutter in t-text
istilluseasync I dont know anything about rewrite foof
ha #oof
I still need help with making a bot
should I submit a bot with this amount of commands. if no, what should I add? (it's multipurpose)
needs a weeb avatar to be truly generic
its more about purpose than individual commands these days. having commands that share a purpose or belong to a system with a purpose is better than having lots of unrelated commands
pick 1 thing and do it well
Ayy is go a good lang to learn??
ree
@west spoke I couldnt get it working , can someone recommend me something other than glitch , AWS and heroku?
@earnest phoenix you could buy a machine or a old computer like LazyNeko said or you could rent a server
🔶 👌
renting a server is more reliable and will probably be cheaper
digital ocean, $5/mo
Old computers are great for it wym
Extra hardware laying around is the cheapest way lol. But then you rely on your home internet. Which no matter what you have is garbage compared to any host
if you pay your own electricity bills, a vps is much cheaper
can i make css related questions here
yes
Calculating out the avg wattage my main box pulls from the wall, I am paying ~$4/mo for electricity (r7 1700 / 16gb / 512 nvme). I really doubt I could get that from a vps for that cheap. I do realize that not everyone just has that sitting around
But you can
then you live somewhere with really cheap electricity
there are places you pay like 50usd a month for having a fridge
If I lived in Hawaii (Highest cost per KWh, $.275) It would go up to $11.88, still not bad for the specs
But switch that out with like an old core 2 quad, shit mobo and large array of HDDs and then its not worth it
yeah the bigger the machine you need, the cheaper it gets
hence why big servers use dedis
otherwise for small projects its overkill hardware and not worth it
another problem is that many places charge a minimum fee + taxes and yada yada for electricity
so you're paying 4usd/mo for the power consumption plus 10usd for base fees plus taxes + public lighting shares
or something stupid like that
whats the way to have the activity status say "playing etc.."
@earnest phoenix what language?
python sir, sorry!
what lib?
What version of lib
3.6
Library, not Python
v1.01 i believe
# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))
# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))
# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
thankyou, sorry for the misunderstanding
it's fine
Wrong chat @hybrid oasis
obviously, that's why it was deleted
sometimes you just want to show how much of a city planner you are and get caught up in the excitement
It's still there for me but alright
It's a mobile thing
is it possible to somehow detect new lines in a discord message?
contains("\n")
and if i just want to go line by line i can just split at \n right?
yep
aight cool
module.exports.conf = {
enabled: true,
guildOnly: true,
aliases: [ 'latency' ],
permission: 0
}
client.commands = new Collection();
fs.readdir("./files/commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
const props = require(`./files/commands/${file}`);
client.commands.set(file.split(".")[0], props);
});
});
how would I make the command handler register the aliases
loop through the aliases and add an entry in client.commands for each of them
I just add them as I load the commands
This is how I normally handle my commandsjs this.aliases = new Map(); for (const file of fs.readdirSync("./commands/")) { if (!file.endsWith(".js")) continue; // ... for (const alias of cmd.aliases) { this.aliases.set(alias, cmd); } }
I do mine like this
jsfiles.forEach((f, i) => {
let props = require(`./cmds/${f}`)
bot.commands.set(f, props)
bot.aliases.set(f, props.aliases)
});```
can someone give an example of adding the aliases in my current method
client.commands = new Collection();
fs.readdir("./files/commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
const props = require(`./files/commands/${file}`);
client.commands.set(file.split(".")[0], props);
});
});
general question regarding msuic players: How do you deal with youtube blocking 403-too many requests?
We gave you two solutions... it's up to you to implement them... @errant ocean
Yeah, I'm trying
While we could send the exact lines of code you'd have to copy/paste, that'd be considered spoonfeeding, and it won't benefit you at all.
Well what r u having troubles with?
I tried adding aliases to the set but that just errors it
What's the error? What's the code you ran?
client.commands = new Collection();
fs.readdir("./files/commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
const props = require(`./files/commands/${file}`);
client.commands.set(file.split(".")[0], props);
client.aliases.set(file.split(".")[0], props.aliases);
});
});
Of course it errors, we dont give you code to copy and paste. We encourage you to learn, and will often only provide broad examples
Lemme guess, you didn't define client.aliases...
I created another set
You created a Set?
Set????
Collection*
k
Your code doesn't show that at all...
@amber fractal if you do it that way, how would u search a command by its alias
client.commands = new Collection();
client.aliases = new Collection();
fs.readdir("./files/commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
const props = require(`./files/commands/${file}`);
client.commands.set(file.split(".")[0], props);
client.aliases.set(file.split(".")[0], props.aliases);
});
});
Code right now ^
testing
what would I change in the file where I run the command
What's the error?
By knowing js
try{
var alias = bot.aliases.find(a => a ? a.aliases.includes(args[0].toLowerCase().slice(prefix.length).toLowerCase()) : "")
}catch(e){}
if(alias){
let command = bot.commands.get(`${alias.command}.js`)
if(command){
command.run(bot, message, prefix)
}
}``` is what I do
and I guess I did .toLowerCase() twice
Oh well
i need help with giving my bot a custom role like tatsumaki and some other bots have
Wdym @mystic shell
Discord will make a role if it is invited with permissions
But generally people dislike those roles
on servers where my bot has a role given by the server owner the bot doesn't work and gives me a "missing permissions" error
on what action
i want to create a role for every server the bot is in that will give it the right perms
sending an image attachment
Well you can do that by changing the invite link, but people may not like it
if you try to assign a role to the server owner or someone who has a role higher than the bot's highest role it will throw
you can't modify people higher than your bot in the hierarchy
That's for kicking or banning, you should be able to give roles though @earnest phoenix
tried where
In a server that I don't own
what about my bot giving a special role to itself when it joins a server
@mystic shell I told you you need to set the permissions in the invite link
You can give roles to people above you as long as the role is below you
you should catch exceptions regardless though, some people may invite your bot without the required permissions
Yes
ok yeah, got the invite link fixed
so to get the perms fixed on the preexisting servers im gonna have to ask the server owners to fix them?
Whenever that Missing Permissions error shows up, just make the bot send a reply message to the server, reminding them to give the specific permissions that the command needs.
oh ok i can add an event listener for that, right
@mystic shell well that's an error, so I'd check if the bot has the proper permissions before doing the task it needs to do
ok
Using d.js as an example: ```js
const perms_for_client = message.channel.permissionsFor(client.user);
if (!perms_for_client.has("MANAGE_MESSAGES")) throw "I'm lacking MANAGE_MESSAGES perms!!!";
message.channel.bulkDelete(10);```
wait how do i figure out which permissions my bot is missing
you can check what permissions your bot has
by doing
message.guild.me.hasPermission("PERMISSION_NAME");
it will return a boolean (false if the permission is missing and true if the bot has the permission)
@mystic shell
you can use the eval command to display it or you can log it to the console.
i got that already
ok
its ok now i figured out a fix
cool
@earnest phoenix what do you mean you don't know how to use it
have you added it
to the discord bot page
then add it
look in #502193464054644737
there is a guide on how to do so
np
hello
@commands.cooldown(1, 120, commands.BucketType.user)
async def email(ctx, *args):
mesg = ' '.join(args)
email = 'the gmail'
password = 'the pass'
send_to_email = 'the target email'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(email, password)
subject = 'Sent by {0} , {1}'.format(ctx.messsage.author.name, ctx.message.author.id)
message = "Message:\n {0}".format(mesg)
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = send_to_email
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
text = msg.as_string()
server.sendmail(email, send_to_email, text)
await client.say("The message of ```{0}``` has been sent to the owner for review, thank you!".format(mesg))```
why would this not work?
File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'messsage'```
this is the error
and yes im typing prefix email (message)
i switched hosting services and when i installed everything like all the modedules I see this ```(node:5384) UnhandledPromiseRejectionWarning: Error: FFMPEG not found
at Function.selectFfmpegCommand (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\prism-media\src\transcoders\ffmpeg\Ffmpeg.js:46:13)
at new FfmpegTranscoder (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\prism-media\src\transcoders\ffmpeg\Ffmpeg.js:7:37)
at new MediaTranscoder (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\prism-media\src\transcoders\MediaTranscoder.js:10:19)
at new Prism (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\prism-media\src\Prism.js:5:23) at new VoiceConnection (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\discord.js\src\client\voice\VoiceConnection.js:46:18)
at Promise (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\discord.js\src\client\voice\ClientVoiceManager.js:63:22)
at new Promise (<anonymous>)
at ClientVoiceManager.joinChannel (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\discord.js\src\client\voice\ClientVoiceManager.js:45:12)
at VoiceChannel.join (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\node_modules\discord.js\src\structures\VoiceChannel.js:130:30)
at Client.<anonymous> (C:\Users\chillkey123123123213\Desktop\ChillBot\discord-bot\bot.js:969:36)
at Client.emit (events.js:189:13)
install ffmpeg
https://www.ffmpeg.org/download.html this right
yeah just follow instructions there
wait when i download
what when
but last time i didnt do anything like this
not because you didnt do anything like that means you dont need to do anything like that
every provider is different
google cloud
I feel like thats a windows pc
yea
go ask on d.js support server on how to put ffmpeg on path
for I never hosted my bot on windows
k
I would like to use rateLimitPerUser, but I do not know how to install discord.js dev, can you help me?
yarn add discordjs/discord.js#11.4-dev``````sh
npm install --save discordjs/discord.js#11.4-dev```
Did you install the dbl package?
yes
How'd u define dbl?
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('my key', client);
that is weird, as the source code does include an isWeekend function
yeah but it doesnt work
can you show your code?
dms
i have no idea
I use JavaScript for dev have another language for dev with Atom ? Thx
atom supports multiple languages if thats the question
can someone come with a suggestion of commands?
what
@trail dagger A great bot is one with original features...
if we had ideas for original features why wouldnt we make it ourselves
^
Plus how would the ideas be original if you'd be taking them from us...
Whenever I open my fresh install of zsh, it shows MacBook-Pro% instead of ~
@opaque eagle yes, thats what a fresh install of zsh does
How do I change it to the ~ that many have?
custom themes
oh-my-zsh is very good for themes, and comes with a ton preinstalled
i personally use dracula https://draculatheme.com/zsh/
~ is your home directory on linux btw
Oh
I like gruvbox but I'll check out omz
What does the color of the arrow mean in omz
?
Every time I turn on my bot, it goes online, but when I turn off my computer, the bot automatically turns off and goes offline. How do I keep my bot online until I turn off my bot?
A VPS or virtual private server is a virtualized server instance run in the cloud. It acts like a normal server, allowing you to remotely login and manage it just like a physical server or computer. If you're looking for a way to keep your bot online 24/7 a VPS is a great option. Having trouble choosing a VPS provider or don't know where to start? Click here for a list of common and affordable VPS providers.
hello all anybody that could maby help me with this seeing that this code works on my other bot but on this 1 i keep getting it like this 😢 http://prntscr.com/nn9exd
what code you want @opaque eagle ?? message.js or level.js ??
Visual Studio Code @dreamy heath
Yes
Just make sure that the bot ignores messages from itself. @slate kayak
I typically use WebStorm and vim (depending on how large the project is)
Ok
Popular VPS Providers
Being on this list does not in any way shape or form represent a partnership or endorsement from me or DBL, all prices shown in USD unless otherwise noted
- GalaxyGate https://galaxygate.net/
Starting at $3/month, 1 vCPU, 1GB RAM, 15GB Disk, 100Mbps Network, Unlimited bandwidth, Weekly backups - DigitalOcean https://www.digitalocean.com/
Starting at $5/month, 1 vCPU, 1GB RAM, 25GB Disk, 1TB Transfer - Vultr https://www.vultr.com/
Starting at $2.50/month, 1 vCPU, 515MB RAM, 10GB Disk, .5TB Bandwidth - OVH - https://ovh.com/
Starting at $3.35/month, 1 vCPU, 2GB RAM, 20GB Disk - HostMyServers - https://www.hostmyservers.fr
Starting at 2.49€/month, 1 vCPU, 2GB RAM, 50GB Disk
If you have suggestions to add to this list please let me know and I'll look into adding them
Wasn't there a similar pin before?
Yeah
@zealous veldt isn't it in the pins already?
unpinned old one
Oh ok
Yea
@zealous veldt could you add hostmyservers.fr as well?
Thanku

