#development
1 messages Β· Page 928 of 1
just do the above
im on discordjs and I want a way where a user can do a command, and it saves the info thats after the command. Right now I have it slice off the command part, but i want it to put in a json like
"000id": {
"ric": xxx
"btc": xxx
}
how can I do that?
show example of the command
code:
let user = bot.users.get(args[0]);
let fetched = db.fetch(`blacklist_${message.guild.id}_${user.id}`)
error:
Cannot read property 'id' of undefined
in v12 its .cache.get
i'm still in v11
then the user was not found
but if it isn't found it should send a message
you dont have any code that checks for that
if(!user) {
const nulgasesc = new Discord.RichEmbed()
.setDescription(":no_entry_sign: **Utilizatorul nu este valid!**");
message.channel.send(nulgasesc);
}
i have, but i didn't send it
that code has to be before the fetch code
it is
const db = require("quick.db");
const Discord = require("discord.js");
const config = require("../botconfig.json");
exports.run = async(bot, message, args) => {
if(message.member.hasPermission("ADMINISTRATOR")) {
let user = message.mentions.users.first();
if(!user) {
const nulgasesc = new Discord.RichEmbed()
.setDescription(":no_entry_sign: **Utilizatorul nu este valid!**");
message.channel.send(nulgasesc);
}
let fetched = db.fetch(`blacklist_${message.guild.id}_${user.id}`)
if(!fetched) {
db.set(`blacklist_${message.guild.id}_${user.id}`, true)
const aprimit = new Discord.RichEmbed()
.setDescription(":white_check_mark: **Utilizatorul a primit blacklist!**");
message.channel.send(aprimit);
}else{
const edeja = new Discord.RichEmbed()
.setDescription(":no_entry_sign: **Userul este deja pe blacklist!**");
message.channel.send(edeja);
}
}else{
const nuaiacces = new Discord.RichEmbed()
.setDescription(":no_entry_sign: **Nu ai acces la aceasta comanda!**");
message.channel.send(nuaiacces);
}
}
module.exports.help = {
name: "blacklist"
}
show full code
this is the full code
that code doesnt even have bot.users.get()
so your current code is now this?
yes
looks correct
i still got the error when i run /blacklist
did you save the file and restart your bot?
add a return in your if(!user)
how do i make my bot run 24/7?
keep the program running
How to make my bot check everytime if a user is in blacklist ban him?
so im running Array.filter(async d => blablabla) and want to execute something afterwards. is there any way to get rid of this race condition where whatever is after gets called before the filter finishes?
await Promise.all(array.filter())
or Promise.all().then()
actually no
since the filter wont return any of its logic immediately, it wont really filter anything
@quartz kindle so i need to put in MemberAdd event ```db.fetch(`blacklist_{message.guild.id}_{user.id})```` an then what?
so (await Promise.all(array.map(async item => {bla; return false or null if you want it filtered out}))).filter(Boolean)
problem is that im already chaining other stuff on before the filter
(await client.getMessages(message.channel_id, 10)).reduce((accumulator, curr) => {
if (
curr.author.username !== message.author.username &&
!curr.author.bot &&
!accumulator.some(item => curr.author.id === item.i)
)
accumulator.push({ u: curr.author.username, i: curr.author.id })
return accumulator
}, []).filter(async d => {
console.log('mm filtering')
const member = await client.getMember(message.guild_id, d.i)
console.log(member)
if (member.roles.includes('710208578413133834'))
return false
client.addGuildMemberRole(message.guild_id, d.i, '710208578413133834')
return true
})
console.log('sending msg')```
sending msg gets logged before member and that is uncool
change it to .map(), then use Promise.all() on it
change what to .map
the filter
let me test something
yeah
as i thought
you cant use async functions with filter
because the async function will always return a promise, which is truthy
so it doesnt actually filter out anything
oh yikes
so you have to use .map() to convert all items into a promise, then use Promise.all() on the array
then you can filter it out with .filter(Boolean)
to remove all the falsey results
but i cant do that because i need them afterwards
why cant you?
thats why you use Promise.all()
but then i still wont have the original objects, no?
but instead of async t => t i have async original => somethingcompletelydifferent
wait
member objects have the username and id too
okay nevermind i can do that thanks lmao
ah i understand what you're saying
yes the only way to filter the original array without modifying it would be a for loop
and rebuilding the array in another variable
yeah but i realized i can just use your approach
as a member object has the properties i need to use
and i can just grab them from that
π
thanks
code:
bot.on("guildMemberAdd", (member) => {
let user = member.mentions.users.first()
let blacklisted = db.get(`blacklist_${member.guild.id}_${user.id}`)
if(blacklisted === null) {
return;
}
let bReason = "blacklisted";
member.guild(blacklisted).ban(bReason);
Is this right to check if somenone join the server and is on blacklist get banned?
@quartz kindle
no
when a member joins, you get a member object
there is no member.mentions
its not a message
instead, you can directly access their id
uhm, how ? π
members have ids
ik this
i need to check if an user is on blacklist, but how ? ( i'm new at discord.js, sorry for dumb questions )
Yes, ty
@quartz kindle does async also not work in reduce?
tfw member.mentions pepehands
probably not
@amber fractal don't judge me =))

I mean it's nice to have documentation that explains it all in a really clear way
yeah ok ill just do it with your Promise.all lmao
@quartz kindlethe command would look something like ricaddress <input>
lmao tim
how does the input look like
@quartz kindle okay i need more help lmao i have no idea how to do this
so first i have an array of messages
then i need to filter out based on criteria and get all unique author objects
then fetch a member from the author id and construct an array based on whether or not the member has a certain role (if doesnt, add it but that doesnt need to be awaited)
is the criteria async?
no
i'd construct an object
let obj = {}
for(let message of array) {
if(!obj[message.author.id]) { // and whatever other criteria
let member = await guild.members.fetch(message.author.id)
if(bla) { // member has role
obj[message.author.id] = message
}
}
}
hmm yes i suppose that is also a solution
you dont need to use promise all if getMessages already returns the messages
unless it returns an array of 10 promises for some reason
ah lmao
(since for some 200 iq reason, messages from getMessages dont have member objects attached wtf discord)
alright its working, thank you
[c], anyone have any idea why it crushes at fgets(the end)?
#include <stdio.h>
#include <stdlib.h>
#define CHAR_SIZE 200
typedef struct list list;
struct list {
char* name;
char** reasons;
int num;
};
void print(list list);
int main(void)
{
char problem[CHAR_SIZE] = { 0 };
list pro = {"List PRO", 0, 0};
list con = {"List CON", 0, 0 };
int option = 0;
while (option != 4)
{
printf("Choose Option: \n1 - Add PRO reason \n2 - Add CON reason \n3 - Print reasons \n4 - Exit\n");
scanf("%d", &option);
getchar();
switch (option)
{
case(1):
pro.num++;
pro.reasons = (char**)realloc(pro.reasons, (pro.num) * sizeof(char*));
printf("please enter a reason: ");
pro.reasons[pro.num - 1] = (char*)malloc(CHAR_SIZE * sizeof(char));
fgets(*pro.reasons[pro.num - 1], CHAR_SIZE, stdin);
strtok(*pro.reasons[pro.num - 1], "\n");
break;
hey, im logging debug info bc of some issues im having, what does this mean? "429 hit on route /guilds/704452210813304925"
you got ratelimited
ratelimited
why is my bot being rate limited? its only launching and i have all commands disabled so theres no activity
is there some issue with that guild or is my bot spamming something?
getting rate limited on a guilds route means its something related to those rest endpoints
possibly fetching a member, fetching guild information, roles, emojis...
or doing stuff like updating roles
guys how do I update node.js? I know that I should do it in node.js.org but I host my bot on glitch.com and not on my computer, so I should update it via command I think
@crisp talon in your package.json there is an "engines" field
you change the version there, and glitch will do the rest
ahhhhh ok, i am retrieving a custom emoji on a shard and sending the info to all shards
how are you sending the info?
@crisp talon in your package.json there is an "engines" field
@quartz kindle uhm there isn't
if there isnt, create one yourself
like this:
"dependencies": {
...
...
...
},
"engines": {
"node":"12.x"
}
i used this guide to search for an emoji, then create a guildemoji that is then stored in each shard
https://github.com/discordjs/guide/blob/master/guide/sharding/extended.md
its like halfway-ish down the page
@quartz kindle and if I do this it automatically updates node?
uh so before updating node I got the error: fields.flat is not a function, but now I get TypeError: currentLevel.check is not a function
how can I fix it?
@near ether i see what that code is doing, however there is a better way to do it
one that doesnt require fetching the entire guild
will you teach me π
yep
client.shard.broadcastEval(`(${findEmoji}).call(this, '${args[0]}')`)
.then(emojiArray => {
const foundEmoji = emojiArray.find(emoji => emoji);
if (!foundEmoji) return message.reply('I could not find such an emoji.');
let fullEmoji = client.guilds.add({id:foundEmoji.guild_id}, false).emojis.add(foundEmoji,false)
// use fullEmoji
});
following the code from that guide
this will construct a guild partial with only the guild id and nothing else, instead of getting a full guild from the api
awesome ty!!
also theres one more thing im curious about
[WS => Shard 18] Shard did not receive any more guild packets in 15 seconds.
Unavailable guild count: 10
is this something i can fix?
nope
damn its preventing that shard from launching, which just ends up stopping the launch process entirely
it times out and then stops launching the other shards, and doesnt even try to relaunch
is this by default or is it an option to be enabled?
because when shards time out for me, they dont launch and the entire process just halts entirely
it should be by default
try running the shard without using the sharding manager
it should turn ready after 15 seconds anyway
one thing you can also do
is increase this value
because the 15 second time limit gets reset for every guild that the shard receives
so if a guild is broken for 10 seconds but then works again, the timer will reset and give you a total waiting time of 25 seconds now
make the spawnTimeout like 60 seconds
Hi I am tryna use discord.js Permissins like this and it keeps telling me Bitfield Invalid
Perms = 104188992 in this case. Thanks in advance!
userPerms: function(guilds){
const array = []
for (const guild in guilds) {
const perms = parseInt(guilds[guild].permissions)
console.log(perms)
const permissions = new Permissions(perms)
console.log(guild)
if(permissions.has("MANAGE_SERVER")) array.push(guilds[guild])
}
return array;
}```
Nvm
why not use permission objects?
I found why
I am stupid
I spent 30 mins tryna solve this issue please kill me
why not use permission objects?
@lyric mountain Making a dashboard and discord gives me data in that format
ah
I started making bots and am using Heroku to host them, but this seems rather expensive (I run out of free 'dynos' quickly). What would you guys suggest as a cheaper alternative?
a vps
^ facts
i'd recommend setting up a private server with another bot sending a message every 5 minutes to a certain channel
then set up an account on WayScript and create a new application with the discord trigger
make there no output for the discord trigger and turn off Ignore Bots
then add a python step
in the requirements put whatever you need. for example:
discord.py
random_word
then paste the code in scratch.py
if you don't want to use a vps then this is the next best thing
LOL
it's what i first used before switching 
what the actual fuck
the fuck
Ive seen people do quite the weird and wonderful shit touse a free host
but my god
i gave it a shot and all my shards launched correctly
thanks!
and one last question about some errors
"UnhandledPromiseRejectionWarning: Response: Internal Server Error"
what is screwing up here?
Well fuck you. All I asked for was suggestions and help to a legitimate question, but got trash instead. If you didn't wish to answer the question, then don't, instead of sending me garbage
calm down??
accept the fact that nothing is ever free and that you cannot use someone else's resources for free and still have them pay the electricity bills
@near ether nothing, internal server errors are server sided
i mean, i answered a vps, which is a cheap and good alternative
Exactly! Which is why I asked for a CHEAP alternative - NOT FREE ALTERNATIVE
you didnt say it had to be free
but... a vps is cheap
a vps is the best cheap non-free hosting solution
there's ones out for like 3β¬
that is big brain
"pay per year and get 1 month free. but we'll bill you every 11 months"
ngl ive pre paid one of my servers for the next year lol
Ok, thank you for that, but by VPS do you means Microsoft Azure VPS?
no
no, i mean any vps
vps is a general term for virtual private server
vps means Virtual Private Server, there are hundreds of companies that offer such service
prices typically start at 2-3 USD per month, and go up to hundreds of USD per month depending on how much memory, disk and cpu cores you want
yh
azure drained all of my student credits for simply having an account open
:feelssadman:
rip
i dont even bother using student credit
setting everything up to just burn through it in a month or less is just not wurth
i used google's vps for a year with those $300 credits, only used about 30 before they expired lmao
then created a new account to get more credits, but they patched the exploit where you can reuse the same debit card over and over again
if we had those in croatia
i forgot the name of the service but there was one i was looking forward to using only to find out it's region locked to US
slavic langs - you know one, you know them all (except polish what the fuck is polish)
how do i put a custom emoji in embed title
but i like the sound of russian more
^
i swear ive seen a bot do it
you sure it was a custom emoji?
you're probably confusing an author url and titles
because you can use unicode emojis
the x thing
discord send my message pls
discordjs
ik the images take forever to process
embed.setAuthor?
yeah its author
.setAuthor('url','text')?
wait until discord sends my image
can i get an example
and you'll see
ok
OH
Oh ok. Thank you.
00:13
How can i use a file in assets folder in Glitch?
It is a png file and i have to use it in a canvas-constructor item @true ravine
@modest maple yo, I managed to get that netdata thing running in a container and being hidden behind an nginx proxy. but it still seems to be inaccurate with the numbers its displaying. Is it possible I have to configure the settings more for number of cores i have and ram max limit and w.e?
you don't put new to require
^
you require the module and then call new on the thing you want to use from that module
or your module can return a new instance of that thing ~ less common and probably should be avoided tho
ehh
for netdata
i would run it as a uncontainered processes
or set docker to give it everything
you can still hide it using firewall and route it through nginx
you think that could be why its displaying things funkily? i mean, according to all the docs it supports docker/docker-compose
yeah but if your docker is limiting what it can access for itself it'll change
yea i was thinking that also
its as though its taking a single containers resource limits as the entire systems
however, considering the other approach with cadvisor/prometheus/alert managers etc had me using 7 containers ~ just for monitoring ~ compared to netdatas one... if i can configure it,. i'd rather do that π
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("You don't have enough permissions for this command!");
let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
if(!args[0] || args[0 === "help"]) return message.channel.send(`Usage: addrole user role`);
if(!rMember) return message.reply("Couldn't find that user.");
let role = args.join(" ").slice(22).toLowerCase();
if(!role) return message.reply("Please specify a person.");
let gRole = message.guild.roles.cache.find(r => r.name.toLowerCase() === role);
if(!gRole) return message.reply("Couldn't find that role.");
if(rMember.roles.cache.has(gRole.id)) return message.reply("That user has the role already.");
await(rMember.addRole(gRole.id));
try{
await rMember.send(`β
You have were given the role ${gRole.name}!`)
}catch(e){
message.channel.send(`β
<@${rMember.id} was given the role ${gRole.name}!`)
}
}
module.exports.help = {
name: "addrole"
}
i don't get terminal errors, but the bot can't find the role that iam trying to add,what's wrong?
ping me if you would help, thanks
Hello, I am running v11.5.1 discord.js and im getting
message.content is not a function
everytime i type
please help
idk where in my code its doing this as there is no console errors.
you're trying to use message.content() instead of message.content
thank you
yet for me, it's message is not defined.
can anyone help me with my problem above
@rough walrus add debug logs
the "Unknown Message" error only occurs when the message is deleted and is not in cache, right?
it occurs when editing or fetching a message that was deleted or from a guild/channel that your bot cant access
or reacting
I am working on music commands for my bot and when I use ?play (song link) it says that I am not in a voice channel even though I am. Here is my play.js file
function plya(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: 'audioonly'}))
server.queue.shift()
server.dispatcher.on('end', function() {
if (server.queue[0]) play(connection, message);
else connection.disconnect();
})
}
exports.run = (client, message, args) => {
if (args[1]) {
message.channel.send('Please provide a link');
return;
}
if (!message.member.voiceChannel) {
message.channel.send('You must be in a voice channel')
return;
}
if (!servers[message.guild.id]) sevrers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if (!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection) {
AnimationPlaybackEvent(connection, message);
})
}
I need some help regarding a problem. I have a function that sends a message, then reacts to its own message and does something when a user reacts to those emojis. However, sometimes (rarely), the bot does not react to its own message, or it reacts halfway then suddenly stops, and then it's just stuck there. There are no error messages or anything.
@acoustic thunder code
@earnest phoenix discord.js version?
v12
member.voice.channel
instead of member.voiceChannel?
yes
ok
I get this error when I try to use the command
if (!servers[message.guild.id]) sevrers[message.guild.id] = {
queue: []
}
whoops
thats my code the error is that servers is not defined
Something like this
msg = await channel.send(embed=embed) # some embed message
await msg.add_reaction('emoji')
await msg.add_reaction('emoji')
try:
r, u = await client.wait_for('reaction_add', check=check, timeout=120.0)
if r.emoji == 'emoji':
do something
elif r.emoji == 'emoji':
do something
except asyncio.TimeoutError:
print(something)
I got a reference error that says servers is not defined, here is my code
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
according to that small piece of code, servers isnt defined. pretty sure you are defining it somewhere?>
function plya(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: 'audioonly'}))
server.queue.shift()
server.dispatcher.on('end', function() {
if (server.queue[0]) play(connection, message);
else connection.disconnect();
})
}
exports.run = (client, message, args) => {
if (args[1]) {
message.channel.send('Please provide a link');
return;
}
if (!message.member.voice.channel) {
message.channel.send('You must be in a voice channel')
return;
}
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
AnimationPlaybackEvent(connection, message);
})
}
this is the file
well yea servers isnt defined there
server is
not servers
also, side note: you should use const or let instead of var in javascript moving forward. var is old syntax standards
ok
const is for constants, let is for a variable that will change
well not really, it just has different scope
no, yes really.
var has use cases
const vari= 5;
vari= 3 // thros error cause const cannot be changed.```
i got an error when I changed it
I tried const and let
ReferenceError: Cannot access 'server' before initialization
that means your trying to use the server variable before you have defined it
something like javascript server.doathing(); let server = "athing";
https://oliy.is-just-a.dev/oq9j3y_3923.png one use case of var
no, you shouldnt be doing that.
that is extremely poor use of scoping and defeats the entire point of scope
Got an error saying TypeError: Cannot read property '709397361453039718' of undefined. I used this command ?play https://www.youtube.com/watch?v=feA64wXhbjo and this is my code
function plya(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: 'audioonly'}))
server.queue.shift()
server.dispatcher.on('end', function() {
if (server.queue[0]) play(connection, message);
else connection.disconnect();
})
}
exports.run = (client, message, args) => {
if (args[1]) {
message.channel.send('Please provide a link');
return;
}
if (!message.member.voice.channel) {
message.channel.send('You must be in a voice channel')
return;
}
if (!server[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
AnimationPlaybackEvent(connection, message);
})
}
ill change var in a sec btw
is there a way to change status presence from "dnd" to "Do not disturb"?
@earnest phoenix, your still not defining servers anywhere, so it is undefined, so getting a message.guild.id of an undefined object wont work. what makes you think servers would be available there?
did you define servers anywhere?
in some other file out of the command or such
var server = servers at the top
servers doesnt exist tho
thats my point
your basically trying to get information from an object that doesnt exist
so change everything to just server?
like, it doesnt matter that you define server, because your trying to set server to servers[guild.id] when servers doesnt exist, thus, it will never have a guild.id property
no
take a step back
what are you trying to do? where did you get server or servers from?
like, what made you use/add that code?
i looked at a tutorial on youtube
and there in lies the issue.
did you learn from the tutorial? or copy and paste parts here and there?
basically just coded what I knew and took the rest from the video
ok. well the issue is that you are trying to use an object that was never defined. there should be some code somewhere that defines what servers actually is, for example:
const servers = Object.create(Object);``` (not to be copy/pasted)
then
after you have servers defined
there would be some code to setup a guilds defeault server configuration or options or w.e
then, after that ~ you can access the servers object
for example, 'your' code does server.queue.shift() but since servers isnt defined, the server object will not have any default data or property for 'queue' there will be no queue, nothing to shift.
i have a plain dumb question, how do you make an object from a classes properties
what do you mean? and which language do you use?
hi, does anyone know why i'm getting MongoError: Cannot create field 'user' in element {users: []} error?
code: guild.updateOne({$push: {'mute.users.user.id': 'i'}})
guild is the guild in the db, and the model looks like
mute: {
role: String,
users: [ { user: { id: String, reason: String, case: Number, mod: String, time: String } } ],
default: []
}
node.js, and ie
class Thing {
constructor() {
this.memes = 1;
}
}
new Object(Thing) // ???
/*
{
memes: 1
}
*/
ooohhh, you mean how to instantiate the class object?
const mythinginstance = new Thing()```
like that? π
the object is already an object with its class properties...
I have a client looking for different bots one of which being a subreddit feed bot pm me if you can do it
an instance of the object is
for (const key in object) {
if (object.hasOwnProperty(key)) {
const element = object[key];
}
}```
do share?
what the fuck?
I'm confused... if you're going to json, why would you be parsing
and why would you undo a stringify
it'll literally return this
they're inverse functions
thats useful to properly deep-clone an object
then the function name should be clone shouldn't it?
yup, probably
this function will have issues if you have circular structures
i want to take the class and just get an object of properties
then i can store it in the db
without instantiating?
this is annoying to do with raw js because nothing is typed
no property is guaranteed
its not proper oop
i dont see how u can ever have more control without any sort of regulation on class objects
with control i mean doing your own type checking and validation
^
i have enough headache already trying to figure out how to configure webpack
i dont wanna have to configure ts building too, let alone learn it
I like non typed langs better than typed langs as well
starting lang wars again? smh
its not even a debatable idea
im not tryna start an argument but u dont get any compiled language that isnt typed
i dunno how impressive this is but i built my own database schema handler
who fucking cares...?
that can also save missing values
even html is considered a programming language by wikipedia and by many experts
you can do basically the same shit in every lang, programming, scripting, etc
depends how far u wanna go with the term
id call it a markup language because its kinda in the name
but then again im not a frontend dev
name is just semantic
they all do a certain degree of programming, so they are all programming languages in one way or another
some are declarative, others imperative
some are compiled, others interpreted
i kinda wnna learn haskell
functional looks rlly cool but probably a pain to do well
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("You don't have enough permissions for this command!");
let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
if(!args[0] || args[0 === "help"]) return message.channel.send(`Usage: addrole user role`);
if(!rMember) return message.reply("Couldn't find that user.");
let role = args.join(" ").slice(22).toLowerCase();
if(!role) return message.reply("Please specify a person.");
let gRole = message.guild.roles.cache.find(r => r.name.toLowerCase() === role);
if(!gRole) return message.reply("Couldn't find that role.");
if(rMember.roles.cache.has(gRole.id)) return message.reply("That user has the role already.");
await(rMember.addRole(gRole.id));
try{
await rMember.send(`β
You have were given the role ${gRole.name}!`)
}catch(e){
message.channel.send(`β
<@${rMember.id} was given the role ${gRole.name}!`)
}
}
module.exports.help = {
name: "addrole"
}```
i don't get terminal errors, but the bot can't find the role that iam trying to add,what's wrong?
ping me if you would help, thanks
if(!args[0] || args[0 === "help"]) return message.channel.send(
Usage: addrole user role);
Why are you comparing a number to a string?
You should also avoid using .join(" ").slice(22). That's not a guaranteed length.
Helo guys,i dont know how to use HTML is there anyone have ready like template or something or how can i do ? Thanks
that'll be also helpful
with frameworks you dont have to write a lot of CSS code, and can help your site look better with minimal effort
i only wish use html for Detailed description of your bot section.Is there have a way to make simple like this tabs
ive tried making a special simplified version of my bot's site for the html description, because it was bugging out the site's css, but it was ugly and the site css made it worse so i just plopped an iframe and some as in a comment
worked nicely for my edge case
I get the error server is not defined when I use ?play (song link)
function plya(connection, message) {
var server = Object.create(Object);
server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: 'audioonly'}))
server.queue.shift()
server.dispatcher.on('end', function() {
if (server.queue[0]) play(connection, message);
else connection.disconnect();
})
}
exports.run = (client, message, args) => {
if (args[1]) {
message.channel.send('Please provide a link');
return;
}
if (!message.member.voice.channel) {
message.channel.send('You must be in a voice channel')
return;
}
if (!server[message.guild.id]) servers[message.guild.id] = {
queue: []
}
server.queue.push(args[1]);
if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
AnimationPlaybackEvent(connection, message);
})
}
i can tell that's js, so i might not understand, but why are you trying to create an Object object?
Someone told me that might work, turns out it dosen't
who told you that would work??
someone earlier on the server forgot the name
btw you misspelled play as plya
lmao
How can i make something like this,please help thanks.
that's a table
How would I get a list of caseNumbers into an embed in a list to show the case numbers per user in the db? here's what my code is: js } else { const user = await StateManager.connection.query(`SELECT * FROM warningamount WHERE guildId = ${message.guild.id} AND memberId = ${warned.id}`); const cases = await StateManager.connection.query(`SELECT caseNumber FROM warninglog WHERE guildId = ${message.guild.id} AND memberId = ${warned.id}`) console.log(cases); if (user[0][0] === undefined) { message.channel.send(`This member doesn't have any warnings`) } else { if (!args[1]) { const embed = new MessageEmbed() .setTitle(`${warned.username} warning cases`) .setDescription(cases[0][0].caseNumber) message.channel.send(embed) } else {
console says: https://prnt.sc/sghf8k
output in channel so far: https://prnt.sc/sghf1q
How can i make something like this,please help thanks.
@uncut sundial https://www.w3schools.com/html/html_tables.asp
@earnest phoenix no. i told you that the code i showed was not copy/paste. you copy/pasted it.
also also incorrectly π
@earnest phoenix Object.create(Object) is just a long way of doing {}.
ah
sorry im not really experienced in js development that much
im more focused on python
Β―_(γ)_/Β―
np, thats a thing that a lot of js devs arent sure about as well π
at least i dont have to be ashamed of that as much, i guess
no one should ever be ashamed of not knowing a thing; imo as long as your able to learn when someone explains things, thats reason enough to be proud π
yeah
i do know some JS but im not focused on learning d.js
thats why i was thrown off by Object.create(Object)
tbf, they arent exactly the same, but for most use cases they are interchangable π
Object.create(Object) and {} i mean
i have this if (message.content.startsWith('$start')) { score = client.getScore.get(message.author.id); if (!score) { if (!score) { score = { id: `${message.author.id}`, user: message.author.id, btc: 0, eth: 0, usd: 0, i3: 0, i5: 0, i7: 0, i9:0, level: 1} } const embed = new Discord.MessageEmbed() .setColor('#ff9933') .setTitle('Use $profile to see your newly created profile!') .setAuthor('Account Created', 'https://cdn.discordapp.com/emojis/710590499991322714.png?v=1') message.channel.send(embed) client.setScore.run(score); } else { const embed = new Discord.MessageEmbed() .setColor('#ff9933') .setTitle('You already have an account! Use $profile to see your account.') .setAuthor('Error', 'https://cdn.discordapp.com/emojis/710585568660291584.png?v=1') message.channel.send(embed) } }
i want it to send the error message if the user wasnt found in the sqlite but its not workin
if i run the $start command multiple times it keeps saying success
now this is working
if (message.content.startsWith('$start')||('$register')) {
score = client.getScore.get(message.author.id);
if (!score) {
if (!score) {
score = { id: `${message.author.id}`, user: message.author.id, btc: 0, eth: 0, usd: 0, i3: 0, i5: 0, i7: 0, i9:0}
}
const embed = new Discord.MessageEmbed()
.setColor('#ff9933')
.setTitle('Use $profile to see your newly created profile!')
.setAuthor('Account Created', 'https://cdn.discordapp.com/emojis/710590499991322714.png?v=1')
message.channel.send(embed)
client.setScore.run(score);
} else if (score && message.content.startsWith('$start')||('$register')) {
const embed2 = new Discord.MessageEmbed()
.setColor('#ff9933')
.setTitle('You already have an account! Use $profile to see your account.')
.setAuthor('Error', 'https://cdn.discordapp.com/emojis/710585568660291584.png?v=1')
message.channel.send(embed2)
}
}```
but it send the error whenever i type anything
what's the error
@halcyon ember
problem was my or statement wasnt proper fixed it
that isn't really needed
@wheat jolt it helps if it helps someone π it helps me no what is going on most of the time
it helps if it helps someone π it helps me no what is going on most of the time
that's what I'm trying to say
any bots go down just now?
nope

so I'm getting this error: Error: Incorrect datetime value: '1589521526720' for column 'createdOn' at row 1 when trying to put a date into mySql with this code Date.now() anyone have any idea?
try new Date()
even though it's in the middle of a line?
sure
didn't work
any new error?
same thing
what datatype did you specify for that column?
I've tried datetime...timestamp...date
what do you want your dates to look like?
I just need it to be entered into the database for a giveaway command
ok I'm getting an actual date and time but it's still giving me that error
did you change the datatype
yes...I've tried them all again and nothing changed except it's logging the actual date instead of just that string of numbers
yep
well in that case, just make it a bigint and store Date.now()
make sure you enable big numbers in your MySQL connection options
otherwise they would round them
I've tried that...nothing
yeah it's just you
so try to figure out what you did wrong
i can't help much
sorry
so try to figure out what you did wrong
@pale vessel please tell me that wasn't supposed to be read sacastically like a dickhead lmao
idk
Hello again, what could cause this.
at Client.<anonymous> (/home/container/bot/bot.js:431:23)
at Client.emit (events.js:323:22)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:311:20)```
Discord.ks version 11.5.1
let evaled = eval(text)
airbus.guilds.get("639122730389864458").channels.get("701823878292439120").send("Hide all the keys, and seal our windows
'Cause I'm going to war")});
remove } at the end
Ok
HE!airbus.guilds.get("639122730389864458").channels.get("701823878292439120").send("Hide all the keys, and seal our windows
'Cause I'm going to war");
That
SyntaxError: Invalid or unexpected token
at Client.<anonymous> (/home/container/bot/bot.js:431:23)
at Client.emit (events.js:323:22)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:311:20)
I'm doing it via another server
Explain
No. I'm in another server running eval
I think i know what it was
I'ma fix it
I fixed it
Thanks for helping
I just want to play never gonna give you up... (this is lavalink logs) https://cdn.lumap.me/axm64gym.png
only happens w<ith this song tho
nope, also happens wih other songs (seems random)
check if there are any LL/LP updates
anyone here familiar with twitch's api? I can't seem to get the new one to work properly. All I want to do is have my bot notify users when someone goes live
sounds like ifttt
that only lets you get notifications when your stream goes live. I need it to get pinged when a channel that is not my own goes live
i tried to implement something like that with the twitch api about a year ago
yeah its fucked
sometimes if a channel is live it says it isnt
and when its not live it says it is
its just cursed
well you can try with their new api
is there a way to "solve" this error https://cdn.lumap.me/b1dxbrie.png ?
catch
yeah its fucked
@mossy vine literally the WORST api I have ever seen. And their docs are not very helpful.
Anyway, I will try IFTTT again and see if anything changed since last time I used it
I found a bug with my bot and cant explain it: if the message content is a snowflake (like a message ID), this happens https://cdn.lumap.me/bk8q8sz8.png
wait
it happens for every message
ho
I use thee excact same code for my bot, and it works
wtffffff
find is a method for arrays, not maps
@tight ferry You need to poll their streams endpoint every ~2 minutes for reliable results. Don't use the webhooks
it still works with my other bot using the exact same lines of code tho
That's not possible, if you want to use find use a discord.js Collection instead
Which is basically Map with array methods
When bots get a message containing emojis, are the emojis actual unicode emojis or what are they?
I run a delivery bot and people can order with emojis but when I check the order info of an order containing emojis they just show up as ????. The orders are stored in a mysql database using default unicode (utf8 something I assume) and I don't really want the emojis to appear as ???? lol
yeah my mysql db does that too
I kinda wanna fix it now my bot is gaining traction
Do you think it is a mysql issue or something else?
just store the name and id of the emoji, not the emoji object?
But then I'd have to store each emoji from an order separately
Example
Storing the ids for all emojis in a message would be clunky af
It's food only atm because people abused it when they could order anything lol
Indeed
ooohhh, so you hook into an api to order from local takeaway places?
Nah, they get sent images lul
You never heard of DFF?
Discord Fast Food
ahhh lmao
I'm like the hip younger brother where you don't have to wait like 10 hours to get your stuff
I digress
Any ideas how I could fix the emoji issue?
other than storing the id/name not really. i guess you could maybe json stringify the object before storing it in sql database then json parse it when its coming back out? but it'd likely lose some data
is there even a way to store a Unicode id and name
string?
Err I dunno
like, i'd try to store it in the format discord uses <name: id> w.e it is (think thats backwords)
no
Oof
its <:name:id> btw
It's janky, but I might filter out custom emojis and store standard ones as discords :emoji: format
think about this: people use emoji in their discord username a lot
does your db have issue storing their names?
That's what it does
that's better than storing names individually which is not permanent
Yeah
Back to the emoji thing
You were saying I should store custom ones
Surely regular ones would be more useful as theyre more commonly used?
Just thinking aloud
ah i thought the users get to choose the emoji lol
i mean, idk about yall, but i also store usernames for my bot (its rpg and has leaderboard, leaderboard uses usernames) and i have no issue at all with people with strange usernames and emojis etc
What db you using?
mongodb
oof
Ah I use mysql
any idea why my mute command don't work ?
(I'm gonna go and tinker so you can help this person now)
No errors
because pastebin is hard to use and it's ugly
@earnest phoenix you should upgrade to v12 asap
v11 isn't going to last any longer
i want my bot to be accepted first, an then upgrade, because i have a risk that if i update to v12 now the bot will have errors and won't work normaly when testing π
can someone help me ? im searching for bot which, when u react, the bot will dm u
make your own
how
@pale vessel so do you have any idea?
could be the role
it's weird
maybe permissions
did your bot have the correct permissions and respect the role hierarchy
yes
just found a bug that lets you see any server's settings lol
maybe report it and get a bug hunter badge
let getLevelBoost;
let getBoost = message.guild.premiumSubscriptionCount;
if(getBoost < 2) getLevelBoost = "0"
if(getBoost = 2 || getBoost > 2 && getBoost < 15) getLevelBoost = "1";
if(getBoost = 15 || getBoost > 15 && getBoost < 30) getLevelBoost = "2";
if(getBoost = 30 || getBoost > 30) getLevelBoost = "3";```
I have do this but the bot send me level 3 but my server does not any boost imao
how can i do?
=== ?
yes
what's your code
let getBoost = message.guild.premiumSubscriptionCount;
if(getBoost < 2) getLevelBoost === 0
if(getBoost === 2 || getBoost > 2 && getBoost < 15) getLevelBoost === 1;
if(getBoost = 15 || getBoost > 15 && getBoost < 30) getLevelBoost === 2;
if(getBoost === 30 || getBoost > 30) getLevelBoost === 3;```
ok
still using =
you need = on some parts
and you're using === when setting ...
uh ok
yeah
so this :
learn js before making a bot
let getBoost = message.guild.premiumSubscriptionCount;
if(getBoost < 2) getLevelBoost = 0
if(getBoost === 2 || getBoost > 2 && getBoost < 15) getLevelBoost = 1;
if(getBoost === 15 || getBoost > 15 && getBoost < 30) getLevelBoost = 2;
if(getBoost === 30 || getBoost > 30) getLevelBoost = 3;```
i learn doc, u want to see my history!? @sick cloud
do you know what that code does
ok ty
I dont even do JS and ik how todo comparisons lol
Is anyone aware of why 'AbortError' would be spamming my logs or if there are any issues currently with DAPI?
probably
i mean looking at my logs i havent had anything
other than alot of fucking 401's holy fuck
how do you put links on footer (webhooks) like the github one
like this
I now realize that is the description
sorry
footer would have grey text
lmao
you can achieve that by using markdown, it works even in embeds
he meant links in footer
__
virus
why I have this error (too many carracter)
because the content reached over x characters
hm
bruh
but why I got this error (https://discordapp.com/channels/264445053596991498/272764566411149314/710813605150457877)
a mod removed the embed but left you on read
econnreset means your connection was reset and the shard disconnected
usually happens due to network issues
you can usually catch those by doing ```js
client.on("error", error => {
console.log(error) // or do other things with error
})
how i get the level of security of the guild?
sure, why not
@pale vessel so you know how I can do that in the actual code?
But if the gif is on my PC and not online anywhere I will have to upload it somewhere right?
yes
What's the best place for that?
depends
definitely not a sharex server
you can right click the image and get the link
after you upload the image
Cool, hopefully they have good servers because my gif is a bit heavy and I need it to load quick
Do I have to use discord.js to actually code a bot
no
Flazepe do you know about this?
Cool, hopefully they have good servers because my gif is a bit heavy and I need it to load quick
What's basic64?
base64
lol
its an encoding method
Uh ok
basically instead of the image being a separate file
you put the entire image code in the website
encoded in base64
Ok got it
Then it's the viewer PC that has to elaborate the gif
yes
it will read the image from the code, instead of from a file
the only problem is that base64 encoding makes the file size about 1.5x bigger
since its not as efficient as binary
sometimes convenience is better than performance as long as its not overly detrimental imo π
note: sometimes
you can usually catch those by doing ```js
client.on("error", error => {
console.log(error) // or do other things with error
})
@quartz kindle I use eris not discord.js
should be the same on eris
ok I gonna try
my lavalink node crashes if I try to play a yt livestream
why
(giving logs...)
song: https://www.youtube.com/watch?v=5qap5aO4i9A
bot's logs (using shoukaku & discordjs v12): https://cdn.lumap.me/hucgb0ei.png
lavalink logs: https://cdn.lumap.me/66ca9pgd.png
Thank you for listening, I hope you will have a good time here :)
πΌ Listen to the playlist on Spotify, Apple music and more
β https://bit.ly/chilledcow-playlists
π§‘ The Lofi Girl figure (limited edition)
β https://youtooz.com/products/lofi-girl
π Check out the ChilledCow me...
*lavalink node restarts automatically
i see you are a man/woman of culture as well
k
yes im a man of culture
I spent my first 14 years of life discovering things
(the 15th here)
update your lavalink lib
@lyric mountain which one? shoukaku? the lavalink.jar?
are you using maven/gradle?
erm no
https://github.com/Frederikam/Lavalink/releases/tag/3.3.1 I tried with this one, but it doesnt seems to be fixed
well gonna lock live streams for now
and gonna wait for a update
client.on('shardDisconnect', ()=>{})```
events are working on discord.js v11? I don't want to update v12 ..
it works
oh thanks so much >3
@earnest phoenix but won't soon
What do you mean
@wheat jolt
I had developed a music command and it didn't work
i
I delete the command because visual code studio does not work with errore
well i can't
You can't what
order music
stop using google translate pls
i no english
you're english?
I already knew this
i french
ok
this is lumap's job
@tight plinth Je Suis ne le pas fancias, baguette #development le fromage
hainn
oui oui
no comprendo
its not #memes-and-media here smh
I wonder what baguette means besides being a bread type
uhh nothing probably
non non
plase help order music
no spoon feeding
@earnest phoenix allons dans #memes-and-media (le channel ou on peut parler fr), j't'aide
oke
does anyone got an idea why this wont work? I have a Command that creates an Embed that i want to delete after a certain time. For this i send the message id and channel id into a mysql database. In a event i check in an interval if a Dataset in the Mysql database is older than x hours. If yes it retrives the data. Now i want to get the data sorted out but for some reason is my json invalid in the bot but valid in a json path finder
{"id":1,"lfg_message_id":"710517636752081007","timestamp":"2020-05-14T15:43:25.000Z","channelid":"660506975796461720"}
for (var i = 0; i < messages.length; i++) {
var p = messages[i];
let val = JSON.stringify(p)
console.log("Package: "+val.lfg_message_id)
}
This gives me this Console print
Package: undefined
the mysql query returns a json with 3 nested arrays this is why the loop
why don't you simply use setTimeout()?
still need to make something to restart the timeout if the bot restarts during an active timer
then instead of storing the timestamp in the db, get the message's own creation date
and store only the ids on the db
the timestamp is created while its inserted into the Database and is only used by Mysql for selecting the rows that are older than x hours
btw, the issue is that you used JSON.stringify
you can't val.lfg_message_id as string
when i run the console.log without .lfg_message_id i get this Package: {"id":1,"lfg_message_id":"710517636752081007","timestamp":"2020-05-14T15:43:25.000Z","channelid":"660506975796461720"}
read what I said
idk why but the serverinfo command doesnt work in this server, its something to do with the server owner line
you gotta pick the attribute BEFORE stringifying it
JSON.stringify(p.lfg_message_id)
ok thanks
you can actually do that
oh, i thought he was trying to stringify the whole object
why would he stringify it in the first place if he's going to pick a parameter
idk, buuuuut
bruh
let path = [__dirname + '../../../assets/Stats.png'];
let mage = new Canvas(1408, 1058)
.addImage(path, 0, 0, 1408, 1058)
.toBufferAsync();
let stats1Embed = new Discord.MessageEmbed()
.attachFiles([mage])
.setColor("BLUE")
.setImage('attachment://mage')
.setTimestamp()
.setFooter("Pagina 1");
embeds.push(stats1Embed);```
How can i set the mage files in the embed?
you forgot the extension
@lyric mountain Mage is a canvas object, so which is the extension?
is that canvas-consctrutor?
@quartz kindle Yes
path is supposed to be a string, not an array
also, from what i can see in their readme, you have to load the image yourself
addImage doesnt load it for you
Wait the addimage works, i asked to setImage in the embed
If i use message.channel.send({files: [mage]});, all work well
if it works then do this
.attachFiles([{attachment:mage,name:"mage.png"}])
.setImage("attachment://mage.png")
how i can put a video in embed?
you can't
oh ok
@quartz kindle Thanks, i'll try
@quartz kindle I'll get this error TypeError [REQ_RESOURCE_TYPE]: The resource must be a string, Buffer or a valid file stream.
@quartz kindle I get this: https://zws.im/ββββββββββββββββ
On/off? Like if your bot is running?
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("You don't have enough permissions for this command!");
let rMember = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
if(!args[0] || args[0 === "help"]) return message.channel.send(`Usage: addrole user role`);
if(!rMember) return message.reply("Couldn't find that user.");
let role = args.join(" ").slice(22).toLowerCase();
if(!role) return message.reply("Please specify a person.");
let gRole = message.guild.roles.cache.find(r => r.name.toLowerCase() === role);
if(!gRole) return message.reply("Couldn't find that role.");
if(rMember.roles.cache.has(gRole.id)) return message.reply("That user has the role already.");
await(rMember.addRole(gRole.id));
try{
await rMember.send(`β
You have were given the role ${gRole.name}!`)
}catch(e){
message.channel.send(`β
<@${rMember.id} was given the role ${gRole.name}!`)
}
}
module.exports.help = {
name: "addrole"
}```
i don't get terminal errors, but the bot can't find the role that iam trying to add,what's wrong?
ping me if you would help, thanks
@dusky hill many ways you can do that, use a shared database and have your bot push its status there, have an api endpoint in your bot program to retrieve its status, get its status from top.gg after your bot is listed there
@quartz kindle No, i can't understand
@rough walrus dont use .slice(22), its bad practice
use message.mentions.roles.first()
i replace that right?
you can also remove the entire roles.cache.find() line
because mentions.roles will give you the role alredy, no need to find it
if you want to use roles by ID, then you do the same thing as you did for member
use args[1] and use roles.cache.get() using args[1]
@balmy knoll
@quartz kindle Nothing work
