#development
1 messages ยท Page 796 of 1
but it's not bad for the reasons builderb said because they're entirely false, it's bad because it's messing up the references to the embed
oki thank you
welp
Make sure you put that in a message event client.on("message"
Trying to call embed.build() at the start like the red line will lead to an empty embed
thats exactly what i told him
yea i changed thawt
changed it to what?
so you're sending 3 messages?
no?
no?
1 in server and 1 in dms
The first one gets deleted after a delay
its still 3 messages
then i am sending 3 messages
Yeah if he wants one in channel one in DMs shouldn't the ReplyAsync on the last one be irrelevant
Seems like he's purposely sending it 3 times.
@hoary elm this fixed the dms embed
Ahh
im assuming i did this wrong?
Yes
But i cant seem to get the code that @earnest phoenix sent to work
if(!message.content.startsWith('prefixHere')) return
});```
And if you are going to define the prefix above it then it would be if(!message.content.startsWith(PREFIX)) return
And yeah if you use bot then client won't work
Change it to bot.on
hmm i keep getting an error when i do this, when i add the prefix without the '' around it all the code lost its colors, then i went down the the errors and removed the prefixes from other areas meant to be sent in a message and the code got its color back
like this
yea?
Lol
cause i thought it had to be a variable
So instead of ` with no " just put PREFIX
Also that ^^
oh
Put it under where you call the client
lemme re order and do as chu guys said
also dont use .on("message") multiple times
Yeah that's my bad Tim he only showed me so much of the code so I didn't know he was calling that event already untill now
@lavish seal add the if(!message.content line to this message event and delete the other one is what he means
so remove the line in orange right?
oh
Remove the one I made you make I didn't know you were already calling the message event
And then add the if(!message.content stuff I gave you to the one in orange
like this?
dont just tell him what to add or remove, tell him to think about it logically and explain the reason
Yeah like that
i see, i didnt even realize
Also remove the ' around prefix @lavish seal
Should be like this
If you have it as 'PREFIX' then it's gonna think the word PREFIX is what you are trying to ignore.
i see
if(!message.content.startsWith(PREFIX)) return
had another error due to my own mistake of copying the }); down with the line but fixed and it seems to be working now
thanks guys
No problem ๐
now to attempt to make the bot more fun(?)
and break it 100 times in the process xD
this is kinda fun though ngl
broke it before i even added anything xD
LMFAO
now my embeds arent working
๐ฌ what is the error?
are you still using multiple message events?
Hmm I've honestly never seen that before ๐คท๐ปโโ๏ธ ๐คฆ๐ปโโ๏ธ guess I'm just behind lol
i told you not to use multiple. they dont interfere with each other and make your bot work twice as hard: ```js
client.on("message", message => {
// code 1
})
client.on("message", message => {
// code 2
})
"code 1 cannot see or access code 2, and code 2 cannot see or access code 1. they are invisible to each other, and both will be executed at the same time"```
He deleted the multiple events..... I think?
from the code you posted before, you were trying to do the prefix logic in one event, and have the commands in another
post your full code
except the token
Token should be safe tim he used process.env
pastebin
Yeah your good then it can't be leaked unless you show us the .env
remove those two message events at the bottom
also, whatever guide you're following is very outdated
sendMessage and sendEmbed are both deprecated
I thought so
you should use message.channel.send for everything
oh i see 6 month old youtube guides rn
so basically just delete the stuff after bot.login
And yes
thats fine
that was totally wrong xD
its the current stable version
alright ill change all those
My phone really doesn't like that name ๐๐
huh?
lul
Everytime I try and type Tims name it auto corrects to time lol
i should change it to Timo
ohh
Lol
so this server has another Timo
๐๐
in fact, people call me Timo irl
discord is the only place i started using Tim instead and idk why
What's the issue @earnest phoenix
talking in vc
i was woundering if mongodb had an atomic operator to pause the writing for a certain time
instead of having it in a timeout
since if the process crashes
it wont write
Yeah
ebcause atomicity just describes the operators
how come when i change one of the .addFields to .addTitle or .Title the embed stops sending?
@lavish seal show what you mean
same for descriptions and etc
you want to pause writing to the entire db? or you just want to delay a write?
well if i have it like this the message still sends
but if i change it to .addTitle
it no longer sends
read the documentation
yea thats where i was looking, how did i miss that xD
i really must not have been paying attention
@quartz kindle in regards to the other guy yes from what I'm gathering he is trying to pause writing completely
I'm not that in depth with Mongo yet
He said he wanted to pause writing for a set time frame instead of using a timeout function
his code suggests hes trying to save the writing operation outside the process to ensure the writing gets done after a delay even if the process crashes
to which there is no build-in function, the only way would be to write a pending status to the db, and have the process resolve past pending statuses on the next read/write
Hello.
I'm trying to host my bot into heroku, I did the normal commands in git bash of
"git add ."
"git commit -am "random""
"git push heroku master"
but, I get this error. I don't know why.
If someone can read it for me, please do.
Can I ask about coding problems here?
so, i added a mute function and it seems to respond to it a bit like below but it doesnt seem to mute them when the command is used
case 'mute':
let person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]))
if(!person) return message.reply("Could not find mentions user");
let mainrole = message.guild.roles.find(role => role.name === "Readers");
let muterole = message.guild.roles.find(role => role.name === "Muted");
if(!muterole) return message.reply("No mute role");
let time = args[2];
if(!time){
return message.reply("You didnt Specify a time!");
}
person.removerolle(mainrole.id);
person.addrole(muterole.id);
message.channel.send(`@${person.user.tag} has now been muted for ${ms(ms(time))}`);
setTimeout(function(){
person.addrole(mainrole.id)
person.removerole(muterole.id);
message.channel.send(`@${person.user.tag} Has now been unmuted`)
}, ms(time));
im confused why its not adding the mute role and removing readers like it should
Any errors?
i dont think addrole and removerolle are functions
nope no errors
I honestly didn't notice that but you are right
no? hmm
Lol
lol
@astral yoke You setted heroku to you remote app?heroku git:remote -a your-app-name
mhm
And you need to specify your NODE JS version in runtime.txt. I use Python, but this must be
similar to you
like, in my folder?
in the project's root folder.
Discord.js would be package.json
^
It's also added something like this I think ```"engines": {
"node": "11"
},```
Could be wrong haven't touched that stuff in a while
What have i done wrong now? i keep getting an error at the very end of the line
request(options, function(error, response, responseBody) {
if (error) {
return;
}
$ = cheerio.load(responseBody);
var links = $(".image a.link");
var urls = new Array(links.length).fill(0).map((v, i) => links.eq(i).attr("href"));
console.log(urls);
if (!urls.length) {
return;
}
//Send result
message.channel.send( urls[Math.floor(Math.random() * urls.length)]);
});
go to line and give the code
what? im not understanding
its literally this, "});"

im not understanding again...
like ```client.on("ready", () => {
})```
the end is })
and the start is client.on("ready", () => {
try to go to the line where the code starts
of })
wait...
i think u need delete the file and restart
it affect me too
is when refresh the page this will ocurr
You also have two open brackets on request(options, function(error, response, responseBody) {
So the end I'm pretty sure should be
);``` or
```});
});```
Or if that doesn't work then after responseBody put )) instead of one bracket to close the extra. Like this
request(options, function(error, response, responseBody)) {
Np, let me know if that helps feel free to ping me if you need to ๐
oh damn, didnt realize you responded the second time, thought it was still miguel
Lol
I keep getting an error for this
client.on(`messageReactionAdd`, reaction, member => {
if (!member.guild.channels.find(channel => channel.name === "server-roles")) {
return;
} else {
if (reaction.channel.name === `server-roles`) {
if (reaction === `๐`) {
reaction.author.addRole(`Male`);
}
}
}
});
would you mind telling us what the error is
So it's having a issue finding the channel
client.on(`messageReactionAdd`, reaction => {
if (!reaction.guild.channels.find(channel => channel.name === "server-roles")) {
return;
} else {
if (reaction.channel.name === `server-roles`) {
if (reaction === `๐`) {
reaction.author.addRole(`Male`);
}
}
}
});
yes
Does the bot have access to it?
What permissions exactly does it have for that channel
It has admin
Okay so that shouldnt be the issue
is reaction.guild a property even?
Good question actually
should i console.log(reaction); ?
sure
I think it is actually I think it's specifying a reaction in that guild.
Cause I have a starboard that uses reaction.message and works fine that way
it has all the properties
You can try doing what he suggested and do just guild.channels.find(rest of function here or client.guild.channels.find or even message.guild
I don't see that being the issue but it could be
Message.guild is what I would recommend cause it's already a fucntion the fetches reactions to messages
If that makes sense I know I probably could have explained that better
k, lemme try
I want my bot to update message count everytime a new message is sent how would I do this.
Python
on_message event with some bot variable
I have that part
I also have a variable messages = 0 it should update it everytime but idk how
messages += 1? 
Send your code
hooray
im honestly confused why im getting this error, i installed the packages cheerio and request
Parsing error unexpected token
@lavish seal probably because of the trailing colon lol
now i get
yeah the case one was right thats my bad
Oooof
?
You mean on your DBL bot page?
now i have math is not defined, and im, again not exactly sure what i did wrong, followed the guide to the tee as it said (i think atleast) installed the correct packages and all
Math
^ what he/she said
wait math is a package?
No
hurm
Uppercase M
it is Math
There are packages named math although the methods you're using are part of a default module 'Math'.
You'll get the hang of it as you do it more
When did you learn js or are you yet to learn?
Ah well, Good luck!
Just realized that anyone can use the commands mute n stuff in the sever
glad i didnt add kick/ban xD
@lavish seal in the switch statement
After case 'something' use : not ;
And you gotta be careful with indentation
And also add a break; at the end of each case statement
Like so
let flower = 'dandelion';
switch(flower) {
case 'dandelion':
console.log('ah, such a good flower');
break;
default:
console.log('shitty ass flower eww');
break;
}
how can I get the cpu usage in percent in node.js?
I want to implement it in my stats command
I use cpu-stat
There is also net-stat, mem-stat and disk-stat if you're interested
All from npm
whats wrong with me else here?
im trying to finish my kick/ban commands and then im gonna finally sleep xD
@lavish seal you have need to put the else after the if user
also you can just remove the else after the if member because the first one is already enough
so just remove this whole second bit?
@lavish seal You are missing a } , insert it at the start of line 171 so it'll be } }
is it possible in node.js to set the table name for a mysql database dynamic? -> want the serverid to be the table name
i have found that you can send a embed a local image and then when you send you can do file=file https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image - is it possible to do this for multiple files e.g. image, thumbnail, author image etc?
if you do it right maybe
let embed = new Discord.RichEmbed()
embed.attachFile(attachment);
embed.setImage("attachment://image.png");``` i do it in this way in one of my commands (its probably more than you want to do) but if you got the image local in a folder you can use a local link
He's asking for python not JS.
ohh nvm my bad
all good.
@vagrant tree gonna be better asking there^^
As far as I'm aware you can only attach one file per message
I would say the same thing as you haari-san, one attachment per message, even those including or excluding embeds, which is why when you upload multiple image local files it will send multiple messages instead of just one.
@modest maple thanks
how would you handle reporting and things like that when using shards?
i mean, i assume not all shards should be sending report information to any api endpoint that might be waiting. would you collect the shard information and then send it from your main file instead?
@modest maple you can actually still include multiple attachments in one message
it's just that most libs don't support it
how do i set my bot to have a custom status
i have found that you can send a embed a local image and then when you send you can do file=file https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image - is it possible to do this for multiple files e.g. image, thumbnail, author image etc?
@vagrant tree
to answer this question - yes it is
https://hastebin.com/tebumameyu.cs reference code
how do i set my bot to have a custom status
bots can't have custom status
i meant like
a status
that tells them what they are doing
like
"playing in 30 servers"
discord.js
there's a discord.js event name called ready (I think).
ok
so i do this?
client.user.setPresence({ game: { name: 'with discord.js' }, status: 'idle' })
.then(console.log)
.catch(console.error);
^
client.on('ready', () => {
client.user.setPreference({ game: { name: 'with discord.js' }, status: 'idle' });
});```
name: 'with discord.js'```
client is like your bot thing
don't spoonfeed code
what do i do if it says client not defined
define your client
Read the Discord.js docs.
https://discord.js.org/
const client = ........
?
^
@bitter lark we can't just spoonfeed you some code. We need things like language, etc.
This is not the first time you want spoonfeed
^
@bitter lark this isn't a learning ground for Discord.js or javascript as a whole, for that you need to read the Discord.js documentations and learn javascript.
it is setPresence @lilac wharf
I was copying his code on that...
lmao
I know what the proper one is I was just leaving it in there, you wouldn't think I would just give out the correct code would you?
they're smart, NMW03
lmaoยฒ
they know what they're doing
with latest djs v12, how can I detect if a user avatar is a gif or not
message.author.avatarURL({format: 'gif'})
```returns a url, how can I check if this url is 'valid'
yes?
wdym by dynamic: true
message.author.avatarURL({dynamic: true})
oh
message.author.avatarURL() returning as .webp. But dynamic:true gives you a correct format
@summer torrent bro
stop pinging people for help, its annoying
if you want help, post your problem and wait
okii
lul
When i open terminal and i write "node ." the powershell just resets:
it says:
PS C:\Users\NOPE\Desktop\Super Bot> node .
PS C:\Users\NOPE\Desktop\Super Bot>
Can someone help me?
help plz
?
muta unmuta
IM italian O K
youre italian OK
ok
I'am Turk. OK?
Run node index.js
ok
imagine not having a shard.js
Oof
same thing
I have one
Weird
like this
PS C:\Users\NOPE\Desktop\Super Bot> node .
PS C:\Users\NOPE\Desktop\Super Bot>
._.
but whit node index.js
I don't need to imagine it since I already have a shard handler when I'm like 900 servers away @marble juniper 
without showing the token
@lilac wharf I made one incase I will ever reach the 2k my bot is on 108 servers rn
Gonna be a long road
@solemn quartz romanian?
v12.14.1
Damn we think so much alike Link...
@earnest phoenix i live in naples
oK
Wait a min i need to see a thing..
@solemn quartz what's in the index.js file (like the contents of it) without leaking the token
^
do you have any log lines
What ้ said
^-^
Well ion see any index.js files here
a weeb!
:D?
We want to see
code
thats all we need
we don't need to know if there are commands inside
Copy and paste the code of index.js
How the fuck can i show u?
if i copy paste it is toolong
my god
ooF
go to hastebin and paste it in there
then click save (top right)
then copy the link and send it here
and copy the url
or use pastebin
yeah
or use pastebin
@marble juniper i was thinking it
whatever
hastebin has a better formatting system though...
genius
and it doesn't even matter
send the c o d e
the highlighting is visual anyways
yeah
it's not like seeing the word function in purple or red (like my pee) matters
I can just copy paste it in visual studio code for the visual effects
I see you're a man of culture aswell
@solemn quartz if you expect us to help we need to see the code that is inside index.js.
Why do you have a random } on the bot login?
Oh wait nvm that's just my eyes being blind
That's your issue
You are trying to login the bot on the event message
you need to do that outside
Take the bot#login(token) outside of that event and just leave it on the outside
?
}
})
bot.login(token)
like this
yes.
The reason it wasn't working for you is because you were trying to login the bot after registering the message event which requires the bot to be logged in hence it wouldn't work.
lmaoo
and one line off.
^

I love how I just instantly spotted it by accident because of the random } 
XD
Anyway guess that your issue is now resolved.
I spotted it after I scrolled down
YAAAAAAA
I had to copy the code to a hastebin to view it since visuals is a big thing for me
now: cOmManD iS nOt dEfInEd
nut for me
lol
visual is only to make it cleaner for my eyes
to make it look better
but this code wasn't so long so yeah
I mean but to me I have a big issue with white backgrounds (and reading on them) anyway so I guess that also contributes to it.
Mine's just in a medium dark theme
its the normal one
ik.
second problem now?
ah shit here we go again
the second is that i fucking need to do a currency system so i will die
use a database
quick.db?
use anything EXCEPT JSON
everyone talks about it
you can use quick.db sure
I'd suggest MySQL or Mongo.
quick.db is basically sqlite for babys@lilac wharf
In my experience I'd suggest using an external storage method which isn't attached to the main server to prevent it from being taken down if you forget to pay for VPS Hosting etc... such as mongo's free 512MB hosting
It's happened to a previous bot of mine...
in short form: store the data somewhere else execpt your main host
yes. ^
In my experience I'd suggest using an external storage method which isn't attached to the main server to prevent it from being taken down if you forget to pay for VPS Hosting etc... such as mongo's free 512MB hosting
@lilac wharf google translating
^
what hosting do you use
me?
node.js
VSC
do you run it on your pc
ya
or where
lol
ok
ouch
you should probably get a vps
as its better than selfhosting in thousands of ways
you should probably get a vps.
its the short form for Virtual Private Server
its a server where you can run your programms on
like your bot
so it gets my bot on and i dont do anything?
well you have to set up the server first
once you did it tho it stays on 24/7
your pc doesn't have to be on
its only a few bucks a month
im poor
you can selfhost but that requires a good connection and your pc to be online 24/7
and that would be like I said the worst option
Just be thankful you aren't doing something like me, Paying $120/year for one vps which hosts the site, backend api and the bot itself on 4gb ram.
I think I might have gotten the price wrong, let me check
i can just close the PC but not turn it off
as long as your process stays running
$90/year not $120
and your internet doesn't die
wattttttttttttttttttta
and your pc doesn't crash
and your cpu doesn't die if it is bad
and you disk doesn't get filled
and your ram is enough
i pay $33 a year
sure
is 1/3 of what i spended on fortnite!!!
thats bad
if you really don't have any choice execpt to selfhost you can try using glitch
i payed 270 eur...
but glitch is really bad
270 for what?
on the other hand its free
Tim he said on fortnite so cosmetic in-game currencies
270 for what?
@quartz kindle spended on fortnite
I pay 360 euro a year right now
oh lol
I pay something like a total of $110/year with all the added extensions like domains, protection etc...
i spent about $30 on videogames in my entire life
crazy
Tim you have to be lying... right?
100% lying
nope
do you live in Europe?
i do live in europe yes
Alright, this conversation doesnโt relate to development anymore, might want to move to #memes-and-media
well like I said
Haha lol
either selfhost
or use glitch
but you would rather selfhost than use glitch trust me
or pay $2.50 for vultr
also, for what, why do you not like glitch, it runs pretty well
it has bad stats
when you look at memory and disk space
even more memory than disk space
But, it runs very well. The only thing is that you would have to get a db somewhere else in the cloud
with?
How do you
@solemn quartz not possible :^)
@earnest phoenix honestly have no idea what your question means so
What
so if i add id to DBL it automatically comes in this server?
how do i fix this?
re-read your code and study it, you clearly missed some sort of declaration and have unnecessary brackets
it says "declaration or statement expected", click on it: is it a (,[ or {
@earnest phoenix Are you not an English speaker because I have no idea what you mean
u need to know whats wrong
@solemn quartz No, when it gets ACCEPTED into DBL, it comes in.
automatically or someone need to invite it
@solemn quartz the thing that i need to fix are the brackets in rule 38
dont go around blindly adding or removing things. format your code correctly and count your brackets, and you should easily see it
you dont know why because you dont know the language
lol
learn the language
this is what happens when you only copy paste but don't understand
@earnest phoenix hey, I noticed you are doing it in on_message, I would suggest getting the commands extension. Makes it way cleaner and easier ๐
Oh wait, its Javascript. Thought it was python for a sec. Not sure if js has a commands extension
Oof commando ๐คฎ
just write your own command handler at that point
making your own command handler is better than using commando
100%
Never heard of commando, I use the python commands extension :)
Well to give you an example it hasn't been updated in like 2 years
That I know of anyways... Atleast not on the npm page
anything is better than using discord.js-commando
How 2 host
@static trench /\ . You could learn some python but it's best with a laptop as you can have proper text editors etc
How can a ytdl-based music bot support yt playlists
how can i make a shard?
what is a shard?
btw im really annoyed rn so can someone suggest me a cmd to add to my bot?
Each shard gets a different set of guilds it's more for bigger more popular (1000+guilds) bots, Makes the load easier in a way keeps the bot running fast responding fast ect
I hate trying to explain how shards work and what they are lol but ๐คท๐ปโโ๏ธ
lol
I'm sure you get the just
btw im really annoyed rn so can someone suggest me a cmd to add to my bot?
@hoary elm u could too just respond to this ._.
๐ค what kind of commands do you have now
@hoary elm u could too just respond to this ._.
@solemn quartz make a gamble function, more basic commands etc
Ban, kick, Add bot to server link, Profile, server info, help
@solemn quartz make a gamble function, more basic commands etc
@earnest phoenix i should do a currency system to do that
and that would take a loooong time
But your bored soooo... lol
Lol
Currency system is my suggestion
@solemn quartz
They are always fun to do. Still have to make a shop command for mine
U guys are too good at this lol xD
Mines SQL linked
100% SQL database (Default Prefix, mod logs channel, currency, ect)
But gets denied for the bot list because I forgot to add a NSFW Channel lock or filter to my urban search command ๐คฆ๐ปโโ๏ธ lol sometimes you wonder why you are even doing this when you forget the simplest things
Where do you guys recommend me to learn the language
The guides is a start
For discord.js outside of the official docs their is the anidiotsguide name aside it is a decent guide but as always make sure you reference the official guide/and or docs to make sure fucntions ect are up to date
JS is honestly pretty simple to learn for the most part even outside of discord
Yea i kind of know now what most simple lines of code do
But i still know very little
@earnest phoenix look at this youtuber
i started with him
Outside of discord I also make Websites and Scripts/Mods for games and I use JS for most of that stuff.. on top of the normal HTML ect of course
Yes i am watchin this dude lool
lol
Im now making the ban command
Yes please
okii
I am too lazy to type lmao
wait a little
Sure
case 'Ban':
const banned = message.mentions.members.first();
if(!message.author.roles.find(r => r.name === "Super Bot Master")) return message.reply('No perms message')
message.reply('Succesfully banned message')
banned.ban('User Banned By A Staff Member By BOT NAME ')
break;
i did like this
u need to customize it
if ur not an idiot u will edit it
can you pls send the kick command aswell? ;-;
...
wait a sec
BUT
U NEED TO PROMISE ME A THING
U will fucking learn how to do this FUCKING commands by U
ok?
how would one make a simple mp3 player using the voice chat?
idk
@solemn quartz so i need to code it on my own?
hmm
i hope i have enough braincells
He's saying it's not going to be production ready you have to edit before it will work ๐
alr
case 'Kick':
const kicked = message.mentions.members.first();
if(!message.author.roles.find(r => r.name === "Something like admin or bot master idk")) return message.reply('No perms')
message.reply('User Kicked Succesfully')
kicked.kick('User Kicked by a staff member by BOT NAME')
break;
Wait
i ve messed up
OK now good
lol
oh gawd
it doesnt work?
like 2 errors

lemme see
im helping u instead of playing wit my new spypeely skin on fortnite >:c
its just a pixel image
visual studio said ;
ive thinked that was cuz he didnt say break; at the end of the last cmd
@earnest phoenix btw change "Super Bot Master To like Admin or bot master idk
yeah
that means that who havethat role can use mod commands
okay
copy paste that line in every mod cmd
ive did like that
@earnest phoenix btw when u need my help ping me cuz im lazy
i miss something here but idk what.
let sql = `SELECT `+table+` FROM Serverconfig."`+database+`"`
connection.query(sql, function (err, result, fields) {
if (err) throw err;
console.log(result)
return result
});
}``` i try to get the result but its always empty
the console log in the function contains the data i wanted
what are you trying to do with ```js
return result
i want to use the data i get out of the function in a command
its for a per server configuration and currently i want to set the prefix from the config. got it already with enmap working but want now switch to mysql in case i need sharding
sorry for that most of my knowledge is from error and trial and reading docs
getData(result => {
// result is available here
// returning here does nothing because the result is not returned in time
})
// result is NOT available here
// the function exits and returns undefined
// the getData part does not wait
}```
so making it async could help? or did i get this part wrong?
this is how it works:
you call getData, and the code sends it to a temporary place until the result is available
meanwhile the code continues
once the result is availabole, the part inside the return scope continues, at this point, it is completelty independent from the function which already returned
there are two solutions
- put all the code that depends on the result inside the block where result is returned
- wrap the getData function inside a Promise, and then await the promise
here's an example of how to wrap a function in a Promise:
function something() {
return new Promise(resolve => {
getData(result => {
resolve(result)
})
})
}```
then you can use it in an async function like await something()
ok thank you
@solemn quartz i got it working !
np
feels like an achievement lmao
lol
I did a thing
Bash script for hst.sh. Contribute to Nekiono/hst.sh development by creating an account on GitHub.
:o
Does anyone know how to sort this list in java by the first number only?
Unsorted: [0i218970213574508555, 1i425357961196470292, 0i201850930121932801, 0i466966675183370268, 0i668827593591750675, 0i330117785776685068, 7i509279793926111242]
note: the value of the list are strings
java or javascript?
Java
do you know how i have to do this. Because i need a working leaderboard for my idle bot. The first number is the level of the user. The i is just for seperating the 2 values later on. and all after the i is the memberid.
@earnest phoenix You forgot a switch statement and it's not in an event oof
i dont use java so idk, but there should be a sorter function
yeah but it sorts the list as string so 0 to 9 is perfect but all above 9 is sorted beyond 1
yeah what i mean is a sorter function where you can pass your own parameters and comparators
for example, javascript has this: js array.sort((a,b) => a.split("i")[0] - b.split("i")[0])
Tรผrk varmฤฑ
it sorts by splitting the items by the i and comparing the first part
star eval silent message.author.send("string"[0])
oh yeah true actually
who wants to make a discord bot with me?
wich coding languagew
discord.js @tranquil copper
ima hell out haha
@tranquil copper i can do another language
im only coding bots in java with bungeecord interface
@tranquil copper i can do java
wich type of bot and what for features?
does anyone knows how to split a string every 4 characters with an i ?
or - like an uuid in java?
Hello i need help with phpmyadmin/MariaDB witch i use for my discord bot
So i had error:
#1932 - Table 'dominik_modbot.blacklist' doesn't exist in engine
And i found out that its mysql corrupted file called ibdata1
And could someone could help me how can i fix this i got rly important data that are in the db but cant access by this error
how can i customize my bot page for example like this i forgot...
i need that template
overwrite the css classes in your bot description
@modest pendant write css for html tags on the page.
thank you for saying the exact same thing
My connection or discord problem.
Messages come late.
And suddenly
I think my connection
What is the best way to get rid of dependencies I'm no longer dependant on?
Do I just remove them with npm and delete them from my package.json?
sure
go to the node modules folder and delete the folder with the module you don't want anymore
Alright thank you very much
and remove it from the package.json
Yeah thank you
you can use npm uninstall lib -s
the -s makes it save the removal and update your package.json
otherwise it will be uninstalled but not removed from package.json
@quartz kindle I remember you saying that you've written a node.js discord library without caching? May I have a link to the github page?
thanks
hi, when using wait_for (I am using python) i am really struggling to make sure i only wait_for the last wait_for entered by a user. how can i make sure it stops wait_for previous wait_fors?
your gonna need to send le code xD
ok... but its pretty ugly
def check(m, u):
try:
print(m,u,ctx.message.author,m.message.channel,m.content)
return u == ctx.message.author and m.message.channel == ctx.message.channel and int(m.content) > 0 and int(m.content) < 11
except:
print('failed...',m.content)
False
try:
if ctx.message.author in pending_tasks:
pending_tasks[ctx.message.author].close()
pending_tasks[ctx.message.author] = bot.wait_for('message', timeout=300.0, check=check)
message, user = await pending_tasks[ctx.message.author]
except asyncio.TimeoutError:
await ctx.send('Timeout')
else:
await ctx.send('Cool, thanks!')
some of this code is based on a stackoverflow answer
woops that should be return False
the error im currently getting is TypeError: check() missing 1 required positional argument: 'u' which is in my check i think
however i feel i might be barking up the wrong tree here
cuz you only getting the message object
you dont get anything else
the 'message' event is exact same as on_message
you only get the same stuff as you do the normal avent
can i drop the u,m and just use ctx.message. ? i am a little lost
you just get passed message
so drop the u
keep the m
you get the user object from message object
which is message.author
is m.message.author the same as ctx.message.author?
no
m is the same as message
so message.author would be m.author
youre just changing the var name
what is ctx.message.author?
ctx is just context
its just a context object
it just saves you having todo message.send, with ctx you just do ctx.send
thanks, i dont think i fully get it but i think i have enough to make some changes and continue
ok i have gotten through the check, but now i am getting this error: py message, user = await pending_tasks[ctx.message.author] RuntimeError: cannot reuse already awaited coroutine
although im unsure whether it is meant to throw that error
that gets thrown if the thing its calling has already been awaited
meaning its already been sent off as a future task
so the except except asyncio.TimeoutError: await ctx.send('Timeout') is intended for that error?
no
that only catches the Wait_for() function raising a timeout exeption
what happens if u remove the await from await pending_tasks[ctx.message.author]
so if i execute the initial command twice i get this error message, user = pending_tasks[ctx.message.author] TypeError: cannot unpack non-iterable coroutine object
now after removing the await
what is pending_tasks
its a dictpending_tasks[ctx.message.author] = bot.wait_for('message', timeout=300.0, check=check)
show full code again
also use author IDs not objects
cuz somtimes causing caching issues
def check(m):
try:
return m.author == ctx.message.author and m.channel == ctx.message.channel and int(m.content) > 0 and int(m.content) < 11
except:
print('failed...',m.content)
return False
try:
if ctx.message.author in pending_tasks:
pending_tasks[ctx.message.author].close()
print(pending_tasks)
pending_tasks[ctx.message.author] = bot.wait_for('message', timeout=300.0, check=check)
print('completed check!!!')
message, user = pending_tasks[ctx.message.author]
except asyncio.TimeoutError:
await ctx.send('Timeout')
else:
await ctx.send('Cool, thanks!')
ah
ah okay
i get this now
right
-
pending_tasks[ctx.message.author] = bot.wait_for('message', timeout=300.0, check=check)will work but you cant call a coro without awaiting it unless your saving the future object to a var to be awaited later which causes blocking and ahhhhhhhhhhhhhhh -
Check is only called on the message event, The message event will only happen when the wait for is awaited so you cant assign a coro object then try to unpack it after
if ctx.message.author in pending_tasks:
pending_tasks[ctx.message.author].close()
print(pending_tasks)
pending_tasks[ctx.message.author] = bot.wait_for('message', timeout=300.0, check=check)
print('completed check!!!')
message, user = pending_tasks[ctx.message.author]```
seems a little unessesairy
like
message = bot.wait_for('message', timeout=300.0, check=check)
would be enough
its litterally doing the same thing according to that check
Set up a ban command but im getting
if (user) {
^
ReferenceError: Cannot access 'user' before initialization
What did i do wrong?
case "ban":
const user2 = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member.ban({reason: 'You were misbehaving!'}).then(() =>{
message.reply("user has been banned!")
})
} else {
message.reply("That user isn\'t in this guild")
}
} else {
message.reply("You must Specify a User!")
}
break;
what is "user"
