#development
1 messages · Page 629 of 1
Provide an example of the json you have and how you want it to be
{"id":{"coins":100},"id2":{"coins":200}}
``` I want to sort the pattern so the person with the higher coins (id2) will be showed above (id1) when displayed in an embed.
Object.entries(yourjson).sort((a,b) => a[1].coins - b[1].coins)
``` something like that. Im on the phone so i cant test
ok thanks
That should get you a sorted array like this:
[[id,{coins:100}],...]
@bot.command(name="name", pass_context=True)
async def edit_role_name(self, ctx, role: discord.Role, name: str):
if name == "":
await self.bot.say("Name cannot be empty.")
return
try:
author = ctx.message.author
old_name = role.name
await self.bot.edit_role(ctx.message.server, role, name=name)
logger.info("{}({}) changed the name of role '{}' to '{}'".format(
author.name, author.id, old_name, name))
await self.bot.say("Done.")
except discord.Forbidden:
await self.bot.say("I need permissions to manage roles first.")
except Exception as e:
print(e)
await self.bot.say("Something went wrong.") i get error at logger says what is undefined
I use the module discord-anti-spam
So I added her without my index.js
tools(client, {
warnBuffer: 3,
maxBuffer: 5,
interval: 1000,
warningMessage: "**❌ Le spam n'est pas autorisé.**",
banMessage: "a été banni pour __spam__.",
maxDuplicatesWarning : 5,
maxDuplicatesBan: 8,
deleteMessagesAfterBanForPastDays: 7
});```
but when a person spam, the bot does not react
bots can use animated emojis
yes @earnest phoenix
ouh
\:emoji:
for uploading anim emojis for bots i need nitro
No

why
@earnest phoenix i think a bot can do that
the \:emoji:
And then you got something like this 🅰519277299277

yes
Put that in your code
ok
@earnest phoenix I just do ``:emote:``
Ah yeah

depends
Xig isn't the only one
but yeah he does the most
it's probably like 50/50
50% xig
50% divided onto everyone else
yup
403 = bot still in approval queue and you aren't logged in as the owner or a mod
you dont need DBL to invite your bot to a server 
you just need tonkku
https://luca.is-inside.me/ilWhhc5i.png you can also generate the same invite link in Discord's Developer Portal
@modern sable 51% chance xig checked your bot if it was checked last week
51% xig
49% rest of the web mods
How To Host Bot with vps?
Put the bot files on the vps and run it
get a vps, remote in, copy files, run
like a norm al?
Norm al yes
ok ty
Polo
if you'd stop asking about it for one day, it'd be instant
lol
there are other ways when bot crashes will restart automatically?
that will never work lol
if the bot crashes, the program quits. your .then() will never work. if the bot doesnt crash, it wont disconnect in a way that you need to login again
Hi system clicker with reaction is not advised ?
?
Make a clicker game with system clicker on reaction is not advised ?
whats advised mean?
"is it API abuse?"
Thx zzzz
no
The answer is probably yes
?
Its not a api abuse
Because when too many messages are modified etc the bot ram
I wouldn't recommend because you users will probably hit the 0.25s reaction ratelimit very quickly
You can set a interval, 6 second
Oh ok :///
Per reaction
Yes i go make a cooldown in my commands of 5 seconds
Yes
And my bot ram for editing messages lmao
you need to install discord.js
how
npm install discord.js
npm i discord.js
thx
no problem
what
i'm trying to figure out discord.py's Guild.kick() function and i got stuck here
help
@somber verge
Your bot is missing the necessary perms to do it
it has administrator perms
You can't kick the server owner or anyone who is above the bot in role hierarchy
^
wait a second
ok it works now
the dm's stopped working but i think i can fix that myself
/shrug

lol

im making bot thats can make emojis from images and gifs (all bots can do this XD)
i need help to remove the text decoration
text-decoration: none doesnt seem to do anything
current css is here
Try adding !important
where exactly
did nothing
try adding !very very important
you need to add it to the text, not the class itself
well lets try
select the child from the linkbutton
it worked... it removed the italic but not that much more
i need to format it properly
remove text decoration and set a color
Well apparently it was due to <a href> which caused it to have format
so i had to clear both to be able to make it work
yes, you apply the css to the a not to the box

yes but
im mildly confused
current goal is to just make the button itself have the link
this wont work
ohohhoohhhh
@earnest phoenix sorry i think i understand now
ill replace button with a href
switch eachother
cause then the <a> class will take over the link for the <button> class
nope :c
now it works
owo
buttons cant have links
There's actually a way to make a button in HTML?
you have to either wrap the button in an a or give it a link via javascript function
Like, other than a <div> with an <a> around it or PHP hell?
you can:
- style the
aitself to make it look like a button - use a button inside an
a - use a button inside a
form - use a button with a javascript link in
onclick
yes
I just use a <div> if I'm making a fancy button. Come to think of it, that's kind of a bad idea lol
<a><button>
its not a bad idea, it just depends on what you need
its not a bad idea, it just depends on what you need/want
need?
its just so you can hit the button properly
instead of targeting just the text itself
it is simpler yes
as for stylish, it doesnt really matter, you can achieve the same result in a gazillion ways
indeed
also how was it you made it able to hover
nvm thats correct, now for some ease in
lmao
so basically
I putin my custom html and css
ans
this is what happene
d
that previous pic might be an answer as to why it's borken 
lol
how do you disallow bots to run commands?
@shy turret if(message.author.bot) return;

setTimeout
... no functions
Anyone here ever used the Oxford Dictionaries API? For some reason while I was testing, lemmas returned 2 values for "testing", being the adjective & the verb, when then querying the definition for "testing" and "test", the first returned a 500 int server error & the latter returned a perfectly good json 🤔
i attempted to but its kind of a mess when i last looked v2 api
Lol yup
how do you make a ping command...
On master or stable
i just write everything in bot.js
discord.js
Version
version..
(lol I'm dumb) how do you find the version?
i just npm install discord.js
k
1 sec Im on phone
ok
client.ping?
Yep
That'll be the websocket ping
If you want bot ping too, you can send a message then edit and compare the send time from the edit time
ok
so like
if (message.content.startsWith('s!ping')) {
message.channel.send(client.ping)
}
That would be the websocket ping yeah
My websocket ping is 148ms. is that pretty good?
if (message.content.startsWith('s!ping')) {
message.channel.send('My websocket ping is ' + client.ping + 'ms.')
}
yeah that looks pretty good. it might be better to use backticks in your string expect binding strings with '+'
if(message.content.startsWith('s!ping')) {
message.channel.send(`My websocket ping is ${client.ping} ms`)
}
@shy turret use that

^^^yeah use that lol
and you can put client.pings for getting all pings
yeah go ahead and code however you want. thats the beauty about coding, no two people's code will ever look alike. but using "`" is just more human readable
(Not sure if this is the right place to ask people for some insight)
Anyone who uses Discord.js
Would there be any explanation for a bot with only 5 Active servers and a >300 Mbps connection would experience intermittent inexplicable failures of performing
message.member.voiceChannel.join().then(voiceConnection => {
voiceConnection.playStream("<VALIDATED_INPUT>"); //Note VALIDATED_INPUT is just a placeholder
});
the stream may have a problem
if(message.content.startsWith(prefix + "addxp")) {
let xpid = message.author
if (message.mentions.users.first()) xpid = message.mentions.users.first()
let addxp = args[1];
let currentExp = xp[xpid.id].xp;
xp[xpid.id].xp = currentExp + addxp;
}``` cannot read property 'id' of null
ypeError: Cannot read property 'id' of null"
Try message.member
in message.mentions..
and wait
let xpid = message.mentions.member.first() ? message.mentions.member.first() : message.author
mentions.members not mention.member

And .members is not guarenteed
so if you do mentions.members.first() you'd get an error
if no user is mentioned
nvm it's just undefined
@wicked pivot with put a s at the end of member
I am not English so I do not understand everything I have to do what?
what languages do u speak
if(message.content.startsWith(prefix + "addxp")) {
let xpid = message.mentions.members.first() ? message.mentions.members.first() : message.author
let addxp = args[1];
let currentExp = xp[xpid.id].xp;
xp[xpid.id].xp = currentExp + addxp;
}```
french
go dm
I thought trying to do .first() on something that didnt exist didnt work, or at least I thought it errored for me once
let xpid = message.guild.member(message.mentions.users.first()) ? message.guild.member(message.mentions.users.first()) : message.author
80% sure its working
@wicked pivot
dacc dacc
unhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
yes
same error
wth
let user = message.guild.member(message.mentions.users.first()) || bot.users.get(args[0]); i have that for my blacklist command and its working
with id and mention
same error :/
show your code
const xp = JSON.parse(fs.readFileSync("./exp.json", "utf8"))
function write(){
fs.writeFile("./exp.json", JSON.stringify(xp), (err) => {
if (err) console.log(err)
})
}
if(message.content.startsWith(prefix + "addxp")) {
let xpid = message.guild.member(message.mentions.users.first()) || bot.users.get(args[0]);
let addxp = args[1];
let currentExp = xp[xpid.user.id].xp;
xp[xpid.user.id].xp = currentExp + addxp;
}```
same error
message.guild.members.get(message.mentions.users.first().id)
wtf how turn off the bot?
xpid.user.id would need a guild member object
xpid.id work
also @wicked pivot what build are you using?
@wicked pivot its working?
nop
how to turn off bot wtf
@low wasp the last
@digital sparrow process.exit()
or close the terminal
ok
or client.destroy() logs it off...
kk thx you 💌
i know
process.exit() down the bot after 2
seconds
client.destroy() down the bot after 60 seconds
In C#, will the bot also trigger this if it gets kicked?
Client.LeftGuild += Client_LeftGuild;
Or only if it leaves on its own?
if it gets kicked, it will also trigger
the leave event for any library is called if the bot leaves on its own, or gets kicked or banned
(there is no way to detect how it left either-- discord doesn't provide this to the websocket)
if you're relying on it for clearing the db, just remember that those entities will not get cleared if for some reason your bot is offline and in that time leaves a server
Yeah was thinking that too, which is why I'm just adding a manual check on a timer too :p
(which just grabs all the guilds in the db & checks them against the list of guilds)
Not like it would really matter tho, as there's only like 20 bytes of data being stored for each guild, just wanted it to be clean
Discord.js help needed
I have a member count command and I want to tell what percentage of users are bots and what percentage are humans. How would I do this? I already have variables set for the amount of humans and bots.
bots / humans * 100 works... when there are less bots than humans.
@pale ether yeah you shouldn't worry about that tbh. I have over 100k guild data saved (most of it is from old servers) and it uses hardly anything
@floral bloom divide by the total member count, which includes bots and humans
Ah, thanks. So humans / (humans + bots) * 100 and vice versa?
the library doesn't have a total member count property? most libraries I've seen have it. but, if it doesn't, then yes
Oh, it does.
maybe wrap humans/ (humans+bots) behind another parentheses
so you know the multiplication will affect the result of the entire thing
i meant (bots/total) * 100, but if it works yw lol
Yeah it's
BotsPercentage = (bots/total) * 100 HumansPercentage = 100-BotsPercentage In case you want to show both
Ok, thanks both of you!
Make sure you use 100f in the humansperc in case you want decimals tho, unless js doesn't care about int vs float for that calculation
Cuz I know in some languages they like to see
(int)10 / (int) 100
as being (int) 0 instead of (float) 0.1
yeah you don't have to worry about that in js
same with python, lua, and other dynamicaly typed languages
Wasn't sure, so thought I'd add the warning about it :p
I've had many a headache because I've forgotten about it
Quick repeat of an earlier question as nobody seemed to know back then & other ppl are online now:
When calling the oxford dictionary API, querying the lemmas for "testing" results in this Json (img)
When then calling for the definition of the verb "test", it works fine & outputs the correct result, however when querying for the adjective "testing", it returns a 500 internal server error, any ideas on the cause and/or a fix?
@ me on a response or pm; as I'll be afk for a while & don't want to miss responses
I need a small help
Why there's N/A ?
And that ???
What do they mean
And how can I change it
?
first
Okay
is the bot approved?
Yep
Okay
and that ??? means that the bot isn't on the server
If it is
then restart it or idk
I'll try, thanks for the help
np
Hello friends
Discord.js
Ok... so, I have a setTimeout function. How would I reset it with a command?
Ping with response please 😃
show the code you attempted
@floral bloom show the code
doesn't reply
Let's wait
lmfao
Lmao 😂
5 hours later
9 endgames later
Update for my earlier question (https://discordapp.com/channels/264445053596991498/272764566411149314/586036103086211073), when doing the same with "working", I get an adjective, noun & verb from lemmas, but when searching the entry for definitions, both "working" and "work" work just fine, as opposed to "testing" not working while "test" works
Code ==const background = await loadImage('./IDcard.png')
Err==parsing error: Can not use keywork 'await' outside an async function
Do you need full code ??
The calling function has to be async as well @pallid zinc
Ah good, only just now noticed the timestamp 😂
You are playing dbm. Are you sure its a friend 
its really easy actually
all you need to do is burn your code to a floppy
and then put it into the robot
well, does your friend want to actually program a bot?
if so, does he know any programming language? or has any language preferences?
then he should start setting up an environment for javascript development
install node.js then install discord.js
yes but not anymore lol
do you have node.js installed?
just google node.js
^
and then?
install it and restart your computer
i have it downloaded, do i place it somewhere?
no... you install it
No.. Just run the installer
th
How experienced are you with javascript anyways?
Yeah.. Please learn js more before jumping into bot development
hes professional
anyways, once its installed, restart your computer (this is important)
lol
HTML canvas? Pretty sure it supports png as well, would have to check tho
Oh, no clue then
As I was sending a PNG
It was not waorking
Then I can it to jpg and it work
Btw thanks
yes it does support png
@jaunty drum you really shouldn't trust random people into your teamviewer
thank
How to make mysql listener for discord. js to invite bot to guild then added row in database?
client.on("guildCreate", guild => {
// add guild to your database
})```
But how to add bot to guild by mysql add row event?
Or by website (php, js) button click
Like Luca does
You click "add my bot to website database", and Luca invites bot
Hi the limit of emoji and edit message is how much ?
Thank you. But how when we get bot icon and name when sending website form? I know only method with secret token, but it seems form dont use it. How can i get with php script bot name and icon when only know client id?
im pretty sure you can scrap a bot's name and profile picture from its invite link
else you need to use oauth2 to get access to an account information by id
Thanks
I found restcord library, it can get guild info with bot token
@earnest phoenix i have this on my bot i can send u the code if you want
yes
spoonfeed bad
waveboye

@earnest phoenix ```let serv = bot.guilds.get('supportserverid')
let guildmem = serv.members.get(message.author.id)
let memberhasrole = guildmem && guildmem.roles.has('roleid')
if(memberhasrole) {
console.log(${message.author} has the premium role.)
}```
no spoonfeed
why not
they wont learn that way
i have sent my code, if he understand js he can modify the code

spoonfeed is against the rules lmfao

Spoonfeed doesn't teach
^
Question: is there a limit to how many times a message can be edited by a bot?
@waxen meteor yes
No, but you have to consider the timing between each edit
@waxen meteor you can do that with a json files
count a edit on a message, and if the edit size are highter than "5" return
Ok, good to know
@earnest phoenix Wdym with 5 times ?
@waxen meteor You can edit an message as often as you want
Unlimited edits but let's follow ratelimits as well
I mean, I know there's probably a ratelimit. Discord has those everywhere.
"probably"
But the thing with 5 edit size is just straight up made up
shrug
@waxen meteor put a 6 seconds limit per edit
if your bot edited message too fast
Understandable, have a good day.
Quick q, in Discord.NET, is there a way to get to your commandservice inside a command module, or would I need to add another check in my messagerecieved to use it/throw in a DI into my execution?
i cant install better-sqlite3
i hardly installed quick.db but it depends better-sqlite3 so i also need to install it
but i cant
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '../build/better_sqlite3.node'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Users\Win7\Desktop\Klasörler\JavaScript\Test\index.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Do you have any errors above that message
why cant you?
ima send install err
You might aswell https://hasteb.in/
Try installing windows build tools npm install --global windows-build-tools
Run npm i windows-build-tools --production --vs2015 --add-python-to-PATH --global as admin, and restart terminal.
Restarting machine can also be required.
i did
Did u do mine?
doin
Ok
------------------- Python --------------------
Python 2.7.15 is already installed, not installing again.
its been 3 times since i install these
Do the other flags will do their work
did you also try to restart your PC
All done!
- windows-build-tools@5.1.0
updated 1 package in 95.939s
Windows is sometimes really weired
Yea if ur using windows id just say don’t even bother with gyp
literally nothing has changed
Have you restarted?
K
then find another sqlite library
Hey, isn't Eris more lightweight than discord.js?
it is
yes
good to switch to?
depends
sure
Just because its lightweigth doenst mean its good
wdym xyber
@split lantern eris implements the entire discord api, so it's good
i mean discord.js does too pretty sure
if you dont need it, its simpler to use something youre already familiar with
yeah; I really only need role management but ya know not doing api calls myself
@split lantern but it's also a memory whore
yeah, I am sending this out to multiple people to run on their servers and want to save them some memory
thank y'all, I'll switch over my code rq
do you have node-gyp installed?
I remember I had an issue with better-sqlite3 when I used it, but node-gyp fixed it
my node-gyp is broken either
it tries to find a file in \node-modules\node-modules
which doesnt exit
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\node_modules\node-gyp\bin\node-gyp.js'
have you tried rebuilding?
try npm i package@latest
npm*
have you tried googleing Failed to locate: "CL.exe"?
i've seen answers that include installing vc++ redists or using specific versions for visual studio
it might also be as simple as adding CL.exe to your path
i love how you completely disregard all of the unwritten rules of asking for help
You should actually explain what you need help with
TF
are you trolling?
judging by previous messages, yes

HI DEVELOAPERS sry for caps
need help?
ive finnally made a bot named Pgoldy[BOT] I MADE IT ON ANOTHER ACCOUNT so i cant show you guys
but i have a problem
and what is it?
i tried to find my bot on the inter net i couldnot find it on any were
another problem is

every 2 or 1 munits the bot goes offline
Use a process manager
Is it your bot
yup
@bright meadow read above messages lmfao
Right, sorry forgot it after laughing
there's your first problem, you can't find it anywhere on the internet because nobody knows about it
Also you'll need to list it if you want to find it, but that's only if you want it to be public
second, use a vps
And that

100101#*%#$
Is this a troll
how old are you?
8 ?
14
Oof
sending the codes
Lmao
the first code i ve write is
{
“name”: “Pgoldy-bot”,
“version”: “1.0.0”,
“description”: “hello games im Pgoldy the bot i will teach you a lesson plz follow my rules to become a god gamer”,
“main”: “bot.js”,
“author”: “PureGOLDS,Pgoldy”,
“dependencies”: {10}
}
that is not code
ik
please use google and learn how to code.... we do not understand anything you're trying to say
that looks like it belongs in a packagelock.json
i got this from internet
var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with !
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch(cmd) {
// !ping
case 'ping':
bot.sendMessage({
to: channelID,
message: 'Pong!'
});
break;
// Just add any case commands if you want to..
}
}
})
so you dont actually know what youre doing
we're not helping you with code you copied online
it similior to java
so you 100% have no idea what youre doing
justin u said get help from internet
getting help from the internet doesn't mean copy code
which are
yes, the problem is that you have no clue what youre doing
script kiddie
if you want to learn discord.js go here https://discord.js.org/#/
Hi, how i can sort for example : all of my userInfo[message.author.id}.level ?
With quick.db
var video1 = await youtube.searchVideos(args.join(" "), 1);
const videoIndex = parseInt(1)
var video = await youtube.getVideoByID(video1[videoIndex - 1].id);
const ul = `https://www.youtube.com/watch?v=${video.id}`
let data = ops.active.get(message.guild.id) || {};
if (!data.connection) data.connection = await message.member.voiceChannel.join();
if (!data.queue) data.queue = [];
data.guildID = message.guild.id;
data.queue.push({
songTitle: video.title,
requester: message.author.tag,
url: ul,
announceChannel: message.channel.id
});
if (!data.dispatcher) play(bot, ops, data);
else {
message.channel.send(`Добавлено в очередь : ${video.title} | Добавил : ${message.author.tag}`);
}
ops.active.set(message.guild.id, data)
}
async function play(bot, ops, data) {
bot.channels.get(data.queue[0].announceChannel).send(`Сейчас играет :${data.queue[0].songTitle} | Добавил : ${data.queue[0].requester}`)
data.dispatcher = await data.connection.play(ytdl(data.queue[0].url, { volume: 1 , filter: 'audioonly' }));
data.dispatcher.guildID = data.guildID;
data.dispatcher.once('finish', function() {
finish(bot, ops, this);
});
}
function finish(bot, ops, dispatcher) {
let fetched = ops.active.get(dispatcher.guildID);
fetched.queue.shift();
if (fetched.queue.length > 0) {
ops.active.set(dispatcher.guildID, fetched);
play(bot, ops, fetched)
} else {
ops.active.delete(dispatcher.guildID);
let vc = bot.guilds.get(dispatcher.guildID).me.voiceChannel;
if (vc) vc.leave();
what's the error
error :
lientUser#setActivity instead
(node:27037) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'calculatedPosition' of undefined```
code :
const Discord = require('discord.js');
exports.run = (bot, message, args, guild) => {
let user = message.mentions.users.first();
if(user.highestRole.calculatedPosition >= message.member.highestRole.calculatedPosition && message.author.id !== message.guild.owner.id) return message.channel.send("**❌ Vous ne pouvez pas warn cet utilisateur.**");
if (message.mentions.users.size < 1) return message.reply("**❌ Vous devez mentionner l'utilisateur à avertir.**").catch(console.error);
let reason = args.slice(1).join(' ');
if (reason.length < 1) return message.channel.send("**❌ Veuillez insérer une raison.**");
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("**❌ Vous n'avez pas la permission d'utiliser cette commande.**");
message.channel.send("**✅ L'utilisateur a été averti avec succès.**");
let mpEmbed = new Discord.RichEmbed()
.setColor("RED")
.setDescription(`Vous avez été averti dans le serveur ${message.guild.name} par ${message.author.username} pour la raison suivante : ${reason}`)
try{
user.send(mpEmbed)
} catch(e) {
console.log(`Avertissement en message privé échoué.`)
}
}
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: 2
};
module.exports.help = {
name: 'warn',
};```
How can i do ?
@earnest phoenix is not function
Yet on the command ban its works
user.highestRole.calculatedPosition is not function, lol .
message.member ?
owh, ok
owh no
uWhat do I put instead? @earnest phoenix
is not string
Hi, how i can sort for example : all of my userInfo{message.author.id}.level ?
With quick.db
idk
Oof
oof
@gaunt blade sorry but this falls under rule 4
this isn't really the discord for it, except #434058442764714002 but that would be paid
oh ok
I mean you can aways try #memes-and-media, but dont expect much for free
ok
I am in discord.py rewrite
Is it possible to purge messages from a specific person?
For example: G-purge @Peter2469#5460 100 would delete 100 messages sent by me and excludes everyone else
Hi, how i can sort for example : all of my userInfo{message.author.id}.level ?
https://www.w3schools.com/jsref/jsref_sort.asp @lofty hamlet
?
also is userInfo{message.author.id} valid syntax?
Ok thx
@slender thistle I tried doing
amount2 = int(amount) + 1
await ctx.channel.purge(limit=amount2, check=author)
embed = discord.Embed(title= "", description= f'**{amount}** messages by {author.name}' + " was deleted successfully!", color = 0xFFFFF)
yeet = await ctx.send(embed=embed)
await asyncio.sleep(2)
await yeet.delete()
however it gave a TypeError: ClientUser object is not callable (author is the person who got pinged)
check is a function. When that returns True, action is done, else go to next message
ok
@mossy vine i can't
I can't sort with this my userInfo{message.author.id}.level
My userInfo_ and .level is
:
db.set(`userInfo_${message.author.id}`, { name: `${pseudo}`, class: `${choice}`, rune: `${choice2}`, runelvl: 1, armor: `${basearmure}`, weapon: `${baseweapon}`, pendentif: `${basependentif}`, money: 0, life: baselife, damage: basedamage, lifeactual: baselife, badge: ["🎮"], reputation: 0, energie: 500, energiemax: 500, inventaire: [], bucheron: 1, bucheronxp: 0, chasseur: 1, chasseurxp: 0, mineur: 1, mineurxp: 0, paysan: 1, paysanxp: 0, pecheur: 1, pecheurxp: 0, compagnonbdd: [], compagnon: "Aucun", all: [], niveau: 1, niveauxp: 0, niveaumaxp: 5000, biographie: "Aucune", farmer: 0, myguild: "Aucune", fer: 0, bronze: 0, argent: 0, obsi: 0, chene: 0, erable: 0, merisier: 0, acajou: 0, crevette: 0, truite: 0, anguille: 0, requin: 0, ble: 0, malt: 0, millet: 0, quisnoa: 0, cochon: 0, mouton: 0, vache: 0, canard: 0, bucheronmaxp: 1000, paysanmaxp: 1000, pecheurmaxp: 1000, mineurmaxp: 1000, chasseurmaxp: 1000, potionhp: 0, potionstamina: 0, vip: false })
does anyone know if discord allows you to make a command, where you can buy emoji's in a guild.
With points what you earn by typing etc, (example levels)
uh thats literally impossible
Whats impossible?
that could be easily abused as well 
thats why we have moderators right 😉
but can i add this to my bot
or isn't this allowed
i dont see why it wouldnt be
Okey thanks 😄
inb4 30 dick emojis
What an interesting first message for me to see
hey guys, i tried to do this new help command but i get this error that rich embed field values cannot be empty and that happens because it cant find my files but i gave it a place to search
someone help?
when does it happen? With just help or help with a command/module
when I type z.help it says that error
its tryna send scan text from my js files and send the text in the field but it can't cause of some error ??? and then it sends empty/nothing/blank embed lol except for the name and icon and etc ofc.
try logging dir
does it get the correct commands in that category or get any at all?
how about categories?
wait when i do a command like prefix help jwrij or well a command that doesnt exist in my js files the invalid command does come up for sure
its problem with the categories i realized
from line 28 to 37
yeah
when i privated the try catch i didnt get error
so obv it doesnt get my files but idk how to fix
that's why I asked if dir was empty
do i type console.log(dir)?
RangeError: RichEmbed field values may not be empty.```
thats what i get when i do prefix help
oh, nothing. empty
Wait
after the description the code should look something like this but cleaner.
are the categories in your help objects is the first letter capital?
or in the module exports?
category: "Miscellaneous", //copy paste this in all commands.``` in the help object for the help command
Are the first letters in all capped?
@vital nest basically you wanna check if msg.channel.permissionsFor(msg.member).has("SEND_MESSAGES") is true when a message is sent and if not just return
ok, thanks for the help! ill give it a shot
but that doesnt fix my bot responding to other peoples help commands
Also do you check whether or not the person sending is a bot?
prefix?
but it got muted
replying to bots
if (message.author.bot) return;
if (!command.startsWith(prefix)) return;
do you have the second line
@vital nest have you got a testing server?
@smoky mica his code could be different to yours
yeah my personal one
@vital nest send me an invite and i'll help test this issue
could be yeah but just could kinda refer ya know.
so that it can be unmuted here
sent!
@amber fractal don't wanna trouble you with the ping but if you could help me rn, that would be greatly appreciated
"dont wanna trouble you with a ping but im gonna trouble you and ping you anyway"
ah yes expected that lol
whats your problem anyway? maybe someone else can help
you dont need to harass the same person every time xd
not everytime, just encountered a problem after some months when updating my help command
scroll up, too much to re explain and idk how to explain properly but i tried my best
Hi, how i can sort for example : all of my userInfo{message.author.id}.level ?
I have been on it since hours
well that should be easy to debug
just console log those variables
and see which one is missing
i've been trying but idk
@lofty hamlet provide an example of what you have, and how you want it to be
sometimes i get stuck on the easiest problems ._.
well, console.log(dir.map(c => \${c.help.name}``).join(" "))
@quartz kindle example of ?
the way it looks like and the way you want to be after sorting
My heal command for example
let reputa = await db.fetch(`heal-timer_${message.author.id}`)
let time = ms(timeout - (Date.now() - reputa))
if (db.get(`userInfo_${message.author.id}.name`) == null) return message.channel.send("Vous devez vous enregistrer, pour ce faire tapez `?register`")
if (db.get(`userInfo_${message.author.id}.vip`) == false) return message.channel.send("Vous devez être VIP `?vip`")
if (reputa !== null && timeout - (Date.now() - reputa) > 0) return message.channel.send(`Revenez dans : **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
db.set(`heal-timer_${message.author.id}`, Date.now())
db.set(`userInfo_${message.author.id}.lifeactual`, db.get(`userInfo_${message.author.id}.life`))
db.set(`userInfo_${message.author.id}.energie`, db.get(`userInfo_${message.author.id}.energiemax`))
let embed = new Discord.RichEmbed()
.addField(`Régénéré`, `HP : ${db.get(`userInfo_${message.author.id}.lifeactual`)}/${db.get(`userInfo_${message.author.id}.life`)}\nStamina : ${db.get(`userInfo_${message.author.id}.energie`)}/${db.get(`userInfo_${message.author.id}.energiemax`)}`)
.setColor("RANDOM")
message.channel.send(embed)```
I want make a ranking of 10 best level in my bot
So if i make a command where the player can see her level i do make this dunction db.get(`userInfo_${message.author.id}.niveau`)
@quartz kindle
imagine getting 3 chances to win $50,000 as bonus money
@lofty hamlet which db are you using? you need to get all data from the db, or check if your db has a way to query data by properties
hey tim
could you recommend me some good websites or places to search for to learn about databases in java script or well for discord?
theres a gazillion databases out there, its more about the database itself than javascript
javascript libaries will just give you an interface, most likely the database's native commands are going to be used anyway
so you just gotta chose a database and learn it
@quartz kindle it's quick.db
what about quick db or like mongodb
basically there are many types of databases, but most of them fall into two categories: nosql and sql, and two types: embedded and server
quickdb is embedded nosql, mongo is server nosql
oh god
quickdb is actually just a front
they use sqlite behind the scenes
which is an sql embedded database
wait did you forget the \ in js console.log(dir.map(c => `\`${c.help.name}\``).join(" "))
I just added it after c.help.name
sql is based on tables and gives you the ability to run advanced queries
thanks for the heads up btw
i just copied it from the code you gave me lol
It was there in my code already
anyway, nosql usually runs on documents or key->value stores, which is a lot more similar to javascript objects
so nosql is usually easier to learn
then the issue of server vs embedded. a server database accepts multiple connections from multiple processes and also connections over the internet. which is useful if you run your database in another server for example
there's clearly a lot i didn't know about
an embedded database can only be used for processes in the same machine, and sometimes its also limited to one process at a time
damn. thanks dude.
mongo is probably the most popular nosql server database
mysql and postgre are probably the most popular sql server databases
sqlite is probably the most popular sql embedded database
oh btw i console logged it but its not there in the console log
then theres your problem, your field is being filled with nothingness
double check your filter function before it
RangeError: RichEmbed field values may not be empty.
yeahh ik this but how the code is setup is its supposed to look into your folder and take the things from there
like import and export into the field i wanna know why its doing that even though i gave it a place to look
Tim so how i can make my ranking ?
I forgot what u do to get this args.join(" ").slice(args[0])
i mean i know that wont work but i forgot which one it is supposed to be
XD
@lofty hamlet https://quickdb.js.org/docs.html#all-method
@quartz kindle so i updated this command handler and now it sends the help files like all the files in my directory /folderand there's no empty message but still it says
RangeError: RichEmbed field values may not be empty.
let member = message.mentions.users.first() || message.author;
let textimage = args.join(" ")
if(textimage.length > 30) return message.channel.send("Seulement 30 caractères sont admis.")```the mentions are counted as character how to deny this
slice the mention
that would do?
help
just moved to a raspberry pi to host the bot, and now it throws this error
it was working fine when i was hosting it on my windows desktop
it defines richembed with const { RichEmbed } = require("discord.js") and constructs it with new RichEmbed()
nevermind, got it working by using discord.js 11 instead of 12
ayyy do u get paid if i make a api for rapid api
cuz its easy i can make millions of em
@hoary helm for the future when you update, its MessageEmbed on master
ok
I'm bit confused with adding a feature that the bot depends on Google Translate and translates French words to English, But I couldn't figure out how to do it
Do you have anyway? ( JavaScript)
use the google translate api
Is it possible for to share me a code? sorry I'm confused with it
const os = require('os')
function delta() {
const cpus = os.cpus()
return cpus.map(cpu => {
const times = cpu.times
return {
tick: Object.keys(times).filter(time => time !== 'idle').reduce((tick, time) => { tick+=times[time]; return tick }, 0),
idle: times.idle,
}
})
}
let startMeasures = delta()
setInterval(() => {
const endMeasures = delta()
const percentageCPU = endMeasures.map((end, i) => {
return ((end.tick - startMeasures[i].tick) / (end.idle - startMeasures[i].idle) * 100).toFixed(3) + '%'
})
client.on('message', msg => {
if (msg.content === 'show cpu') {
msg.reply(percentageCPU.join(' '), '\n')
}
});
// reset
startMeasures = delta()
}, 1000)
ERROR: percentageCPU is not defined
make an account with them, get your API key, read their docs and make a GET request @undone carbon
@restive light then define it
I'll do that way, thanks Justin👍
When i paste this code in the loop
client.on('message', msg => {
if (msg.content === 'show cpu') {
msg.reply(percentageCPU.join(' '), '\n')
bot spams cpu usage every seconds
if i paste "show cpu" code different place, "percentageCPU is not defined"
I need to see the new code, and please use codeblocks
how to use it?
triple ` at the beginning and end
1 more and that makes the code block
well my keyboard doesnt have that
do you have a QWERTY keyboard
just copy and paste it 3 times then on both sides
percentageCPU is not defined
how can i define it in java?
javascript?
this is basic programming fundamentals. where you have percentageCPU defined in one scope cannot be seen in a completely different scope
hmm i have second solution but need help
"show cpu" works in loop but spams as i sad
if i can do something like
"send (cpuusage)
->>Send command 1 time but dont stop loop
{
int x = 0;
}
{
// different scope
System.out.println(x); // ERROR
}
again, I need to see the updated code
but please dont shitty " ' " or what was it
doesnt works with me
const os = require('os')
function delta() {
const cpus = os.cpus()
return cpus.map(cpu => {
const times = cpu.times
return {
tick: Object.keys(times).filter(time => time !== 'idle').reduce((tick, time) => { tick+=times[time]; return tick }, 0),
idle: times.idle,
}
})
}
let startMeasures = delta()
setInterval(() => {
const endMeasures = delta()
const percentageCPU = endMeasures.map((end, i) => {
return ((end.tick - startMeasures[i].tick) / (end.idle - startMeasures[i].idle) * 100).toFixed(3) + '%'
})
client.on('message', msg => {
if (msg.content === 'show cpu') {
msg.reply(percentageCPU.join(' '), '\n')
}
});
// reset
startMeasures = delta()
}, 1000)
now this code shows the cpu usage but spams
something like "Stop sending message but dont stop loop" i mean
if i do that, "percentageCPU is not defined"
how
you declare it in your message event callback
Bot#invite()
can you show me an example on code?
no, I don't code in javascript
thats gonna being complicated
How can invite bot
@cyan goblet #general
define the percentageCPU stuff either in another function and return the value, or do the processing in your message event
this is basic programming involving scopes. this is not complicated. if it's complicated to you, then you need to learn more programming
client.on('message', msg => {
var x = 5;
if (msg.content === 'show cpu') {
msg.reply(percentageCPU.join(' '), '\n')
}
});```
I have defined x to be 5
do the same for percentageCPU
I'm not writing your code for you if you're implying that
I already dont want that
just wrote here for help
also define which you wrote fucked bot now
78 errors
then fix it
js started showing interesting errors
you're struggling so much with basic programming scopes
" % " is not defined
etc..
pff
anyone here for really helping me?
now bot fucked from A to Z
debug your code and fix it
then post your code
👍
i destroyed bot
and deleted everything
i just tried to do "If i type cpu then write cpu usage" about 19 hours
theres a lot of example about cpu usage, I even made my own promised based cpu usage calculator
you just need to read
^
Im already vb6 and c# programmer dont say me "learn how to code"
but java is really complicated for me
^
I know java and javascript, yet js is so easy
^
you just need to put your scoping right
Js is easier than java imo
CONST is a block scoped variable
a simple
let percentageCPU
let startMeasures = delta()
setInterval(() => {
const endMeasures = delta()
percentageCPU = endMeasures.map((end, i) => {
return ((end.tick - startMeasures[i].tick) / (end.idle - startMeasures[i].idle) * 100).toFixed(3) + '%'
})
will fix your scoping issues
a little reading about how JS scoping works will let you learn that
I never see the bullshit langs like java and js
really complicated and annoying languages

javascript is designed for beginners
its so easy that it doesnt even need you to specify the type of variable
like in langs like Java or whatever
you just need to read about it or learn how it works
or if you do C# then why not do a bot in C#
Also Java is not Javascript
they are completely different languages
remember that
Java is fun
just good for android developing
you are saying its bullshit because you dont get the flow or gist of how Java works
true Java is primitive in lot of ways
but its fun to code in Java once you get the gist of it
- theres a lot of help from google and stackoverflow
I wrote a clientless game program with java for android
even an IDE from jetbrains
