#development
1 messages Β· Page 872 of 1
do you have 2 bots in the same file?
yes
show code
but bot b not have eval command
const fs = require('fs');
const Discord = require('discord.js');
exports.run = (client, message) => {
if (message.author.id !== '699962233974816838') {
return message.channel.send(`\`π\` ${message.author} You don't have permissions to execute that command.`);
}
function clean(text) {
if (typeof (text) === 'string') {
return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
}
return text;
}
let args = message.content.split(' ').slice(1);
let cont = message.content.split(' ').slice(1).join(' ');
message.channel.send('Evaluating...').then(msg => {
try {
let code = args.join(' ');
let evaled = eval(code);
if (typeof evaled !== 'string') {
evaled = require('util').inspect(evaled);
}
if (evaled.length > 2000) {
try {
let evalcode1 = new Discord.RichEmbed()
.setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
.setDescription(`**Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
.addField(`\u200b`, `**Output:**\n\n\`\`\`Output too long, logged to ${__dirname}\\eval.txt\`\`\``, true)
.setColor(0x00FF00)
.setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} ms`, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
msg.edit({
embed: evalcode1
});
return fs.writeFile(`eval.txt`, `${clean(evaled)}`);
} catch (err) {
let errorcode1 = new Discord.RichEmbed()
.setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
.setDescription(`**Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
.addField(`\u200b`, `**Output:**\n\n\`\`\`js\nOutput too long, logged to ${__dirname}\\eval.txt\`\`\``, true)
.setColor(0xFF0000)
.setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} ms `, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
msg.edit({
embed: errorcode1
});
return fs.writeFile(`eval.txt`, `${clean(err)}`);
}
}
let evalcode = new Discord.RichEmbed()
.setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
.setDescription(`**:rofl: Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
.addField(`\u200b`, `** :rofl: Output:**\n\n\`\`\`js\n${clean(evaled)}\`\`\``, true)
.setColor(0x00FF00)
.setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} ms`, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
msg.edit({
embed: evalcode
}).catch(e => logger.error(e));
} catch (err) {
let errorcode = new Discord.RichEmbed()
.setAuthor(`Eval by ${message.author.tag}`, `https://cdn.discordapp.com/emojis/314405560701419520.png`)
.setDescription(`**:rofl: Input:**\n\n\`\`\`js\n${cont}\`\`\``, true)
.addField(`\u200b`, `**:rofl:Output:**\`\`\`js\n${clean(err)}\`\`\``, true)
.setColor(0xFF0000)
.setFooter(`Node.js - Time taken: ${Date.now() - message.createdTimestamp} `, `https://images-ext-2.discordapp.net/eyJ1cmwiOiJodHRwczovL2Euc2FmZS5tb2UvVUJFVWwucG5nIn0.LbWCXwiUul3udoS7s20IJYW8xus`);
msg.edit({
embed: errorcode
}).catch(e => logger.error(e));
}
});
};
@quartz kindle
shiro is a stupid and a cancer girl
@knotty steeple that' not problem
dude
normal mode π
your code
where ? you mean my PC
your message event
what
just show your full main file
client.on('message', message => {
let args = message.content.slice(prefix.length).trim().split(' ');
let cmd = args.shift().toLowerCase();
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
try {
delete require.cache[require.resolve(`./commands/${cmd}.js`)];
let ops = {
ownerID: ownerID,
active: active
}
let commandFile = require(`./commands/${cmd}.js`);
commandFile.run(client, message, args, ops);
} catch (e) {
}
});
just show your full main file
@quartz kindle all index.js
@quartz kindle your welcome xD
2 bot is same 95% so i will show only 1
oml
but its two different bots?
yes
or is the same bot?
different
different tokens?
Hi, I need help with doing two API calls in one discord.py command
@quartz kindle hmm but i have prove that my bot connect in a moment
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
"""[Info] Search for albums and tracks on Spotify."""
async with aiohttp.ClientSession() as session:
async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
if r.status == 200:
js = await r.json()
print('Obtained Spotify Token.')
spottoke = (js['access_token'])
print('Spottoke variable defined.')
async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r:
if r.status == 200:
js = await r.json()
print('Printing JSON.')
await ctx.send(js['artists']['items']['external_urls']['spotify'])```
it gets up to printing Spottoke variable defined. but doesn't do the second API call.
@tight plinth did you try this if(!message.channel) { console.log(message) }
I tried
it gets up to printing Spottoke variable defined. but doesn't do the second API call.
I'm making it search an artist on spotify and print out their URL from a JSON object.
it just logs message fine
Tim look in DM's please
lol tim
@earnest phoenix you said you put those checks in a message event, and that makes 0 sense
do you have a idea
it logs smth
Yeah but why saying it this way?
so sometimes there is no message.channel at all
Deleted it already btw, I got that its wrong myself
interesting
@cerulean pebble you either have a a weird conflict somewhere, a broken prefix, or you forgot old bot code in the new bot. i cant help you without seeing the full code
@quartz kindle sad
but the error gone
when i delete command
i just want to know
what happen and why god want to kill me
@earnest phoenix i said it that way because that will either error if you put it in the global scope, or will destroy your bot with an infinite loop of creating events if you put it inside the command
Well its okay
https://corynth.xyz/lumap/x2DjdBLk.png woah okay
As I said, I saw it was not good and deleted it
interesting
interesting
Does anybody know how to run an asyncio API call directly after another in one command?
are you accidentally passing a null message from your index file?
Tim, will using the thing you told me where I can hold huge numbers lag my bot?
m exists because closing embeds of playlist counts as messageUpdate, and the playlist function re adds the same playlist twice but thats not the problem here
@tight plinth
message is the first parameter, oldMessage is the second (at least according to this)
oh lol
Tim, will using the thing you told me where I can hold huge numbers lag my bot?
most likely not
how is it called ?
you can use bigInt, which is native javascript
or you can use a library, there are many libraries in npm
like bignumber.js
and what do i do? just install it ?
or do i need to change anything in the code too ?
you need to change everything
for example, if you use bigInt, you need to add n to all numbers
500n
oh
if you use a library, you need to use whatever the library tells you to do
cant i make anything else instead?
you can't have await inside a synchronous method
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
"""[Info] Search for albums and tracks on Spotify."""
async with aiohttp.ClientSession() as session:
async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
if r.status == 200:
js = await r.json()
print('Obtained Spotify Token.')
spottoke = (js['access_token'])
print('Spottoke variable defined.')
async with aiohttp.ClientSession() as session:
async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r1:
if r1.status == 200:
js = await r1.json()
print('Printing JSON.')
await ctx.send(js['artists'])```
i'm trying to get two api calls in one command but it only gets up to defining the spotify token
@stuck scaffold you need to broadcastEval an async function
boradcastEval("(async function(){ await bla() })()")
I see creating another session inside a session
https://corynth.xyz/lumap/jdTJFz4X.png google is trash
yes looks fine
thx Tim
I see creating another session inside a session
@slender thistle i don't know what to do rn can you help me :P
I just want to know where a member voice channel is stored, and how to get it
https://corynth.xyz/lumap/jdTJFz4X.png google is trash
@tight plinth that's no google
true, thats duckduckgo
duckduckgo detected [ninja'd]
but still
Just put the second async with stuff outside of the very first async with
and no, I'll never use google
ok thank you
then say "duckduckgo is trash"
Or
buuuu~~
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
"""[Info] Search for albums and tracks on Spotify."""
async with aiohttp.ClientSession() as session:
async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
if r.status == 200:
js = await r.json()
print('Obtained Spotify Token.')
spottoke = (js['access_token'])
print('Spottoke variable defined.')
async with aiohttp.ClientSession() as session:
async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r1:
if r1.status == 200:
js = await r1.json()
print('Printing JSON.')
await ctx.send(js['artists'])```
i put my code as that
same result
just gets up to print('Spottoke variable defined.')
hmm?
Just use one client session
kk
@bot.command(pass_context=True,hidden=True)
async def spotify(ctx, *, arg):
"""[Info] Search for albums and tracks on Spotify."""
async with aiohttp.ClientSession() as session:
async with session.post('https://accounts.spotify.com/api/token', headers={'Authorization': 'Basic '+ config.spotifyapikey}, data={"grant_type": "client_credentials"}) as r:
if r.status == 200:
js = await r.json()
print('Obtained Spotify Token.')
spottoke = (js['access_token'])
print('Spottoke variable defined.')
async with session.post('https://api.spotify.com/v1/search?q={arg}&type=artists&limit=1', headers={'Authorization': 'Bearer '+ spottoke}) as r1:
if r1.status == 200:
js = await r1.json()
print('Printing JSON.')
await ctx.send(js['artists'])```
what about now
Try it
ok
@quartz kindle
what if i use parseInt(args[1])
where do i put the n
@earnest phoenix you use BigInt(args[1]) instead
and when you save them into your database, you need to save it as a string
for example 93475938n.toString()
and when you load the number from your database, you also need to load it with BigInt(fetchedNumber)
either change this to client or change function() to () =>
Error: Cannot find module './build/Release/bigint'
if(x[xchance === "a"]){
await msg.edit(`congrats <@${message.author.id}> you won the race! as a reward i give u ${random}$`)
res.money = res.money + random
res.save().catch(err => console.log(err))
do i have to use .then() in order to match the randoms?
Error: Cannot find module './build/Release/bigint'
help
fixed π
pls help
have you tried reading the error
you're so funny
hello gays
yeah, eris docs is not that good
I'd say it's you
hmm
that would be to mention the channel, i think they want to find channel mentions in a message
Sorry about my stupid question, I just plugged the API call for an error code and got a 405 error. Thanks for your help anyway.
OHH
I WAS USING POST INSTEAD OF GET
STUPID
in which case
Does anyone know how to use async to do multiple things at once?
in javascript yes
don't mix async with threading
@stuck scaffold what is if(newUser.username.includes(a)) {
its not in the code you showed
I mean in python
let b = "${newUser.username}"
if(b.includes(a))
is it just me or is the shard broadcastEval kinda annoying
wouldnt it be easier to pass a function
and each shard would just do the function
like a callback
omg i dont understand this
Can't cast database type bigint[] to Decimal[]
even when my variable is a ulong[]
or it could be that variable that is double[], but that isnt bigint[]
@crimson vapor would be very inefficient and buggy as processes communicate via an ipc/child process connection, which you cannot send things like classes
oh
quite a lot of limitations
man why does postgres not support ulongs...
the best way would be to define the function in the shards themselves
yup
and call the function from broadcastEval
the evals get access to this.client right
so you could define this.functions as your functions then just call them with the information you need
this is the client itself of that shard
please i need help
let dmGuild = message.guild
let memberarray = dmGuild.members.array();
holy shit i cant believe i fixed it, it did not work before
@earnest phoenix what version?
how i can put that do not message.guild and do message.channels.get(channel id)
let dmGuild = message.guild
let memberarray = dmGuild.members.array();
when i put it
it says me
i need to do it but with a guild id
That's if you're using V12
v11
client.guilds.get(id)
i remove .cache
Yeah
dont work
dmGuild?
Same error?
what is that?
yep
Try console logging client
wait no
ok
we are tryting
let dmGuild = message.guild
let memberarray = dmGuild.members.array();
this
but with a guild id
and this dont work
A channel id?
can you use cods blocks?
are you using this in a dm?
client.guilds.fetch(guildID).members.array();
no
i dont using in in a dm
im using it in a guild
client.guilds.fetch(guildID).members.array();
@warm marsh this dont work
console.log client
ok
it sys a lot of things
since when could you fetch guilds lmfao
ok
Speedy one moment please
@split hazel but props.conf is true
what i was about to say lol
let dmGuild = message.guild
let memberarray = dmGuild.members.array();
@earnest phoenix so?
look up please
you should add an empty object if one does not have a config
@quartz kindle yes
actually no the command shouldnt load regardless
Right?
ah yes, d.js-commando
so?
nothing
ok
and most likely copy pasted code
you should switch off because its still on d.js 11 or even lower
:/
@earnest phoenix send the code that is causing the error in code blocks and send the important part of the error
let dmGuild = message.guild
let role = message.mentions.roles.first();
var msg = message.content;
try {
msg = msg.substring(msg.indexOf("dmall") + 5);
} catch(error) {
console.log(error);
return;
}
if(!msg || msg.length <= 1) {
const embed = new Discord.RichEmbed()
.addField("β Failed to send", "Message not specified")
.addField("π Listen up!", "Every character past the command will be sent,\nand apparently there was nothing to send.");
message.channel.send({ embed: embed });
return;
}
console.log(client)
let memberarray = dmGuild.members.array();
let membercount = memberarray.length;```
this is error part
it dont have error
i want to do that let memberarray work with a guild id
@stuck scaffold I think I know your problem
you used ${x.guild} when if wasnt needed
:/
@stuck scaffold the code outside the eval function is one thing, the code inside the eval function is a completely separate thing, they cannot see each other
:/
you can import things from outside the eval function into it, by using ${}
so when you use ${x.guild} you try to get x.guild from outside the eval, not from inside it
there is no x outside the eval
can you help me Tim?
what is it?
are you using discord.js v11?
that means the guild was not found
but the bot was in the guild
show the code
guild IDs are too big for js numbers, you need to use a string, that could be a problem
guild IDs are too big for js numbers, you need to use a string, that could be a problem
there is no Schema inside the eval
how i fix it?
`${id}`
ok
server id
it was `there id
show how you define id
i dont define it, i put server id
how do you put it?
but with ``
like this id = 29385987580?
no
or like this id = "3485735"
id = `server id`
```?
client.guilds.get(`there id`)
that the actual code?
yep
like this .get(83475387450) or like this .get("39745937593")
""
last
and you're sure the id is correct and your bot is inside the guild?
yep
I am trying to connect to a cpanel mysql db and I am not sure how to use mysql (with queries and that) and how to connect, could someone help me out or send a guide or something. Thanks in advance (btw i us node.js and discord.js v12)
console.log(client.guilds.get(id))
@golden condor follow a tutorial on youtube
ok
I am tryna find one but I can't
If someone could walk me through it or help me out with it that would be greag
Updated MySQL Crash Course - https://www.youtube.com/watch?v=9ylj9NR0Lcg
In this course we will cover all of the fundamentals of the SQL (Structured Query Language). This course is great for beginners and also intermediates. We will cover the following...
Overview of SQL
Cre...
yes it will be greag
In this quick guide I will show you how to use MySQL along with Node.js. This is something I am constantly asked by LAMP stack devs wanting to learn Node.js. We will be using the MySQL JavaScript client along with Express and Node.
CODE: Code for this video
http://www.travers...
mind deleting the embeds?
can I see a screenshot of your code @earnest phoenix
the entire function
no, a screenshot if possible
?
exactly why I like screenshots
wait what
but still, this should work
but he says it returns undefined
so the id being wrong or the guild not being in the bot is the only possible explanation
i change the id
but nothing
i put 2 differents ids that the bot are in
but it says undefined
?
i change that
@stuck scaffold the path is wrong
@quartz kindle if i put let dmGuild = message.guild work
I am not sure the structure of your folders but it needs to be different
@earnest phoenix yes
but i need it with a id
I see
ok
yes I know
the path is wrong
can I see a screenshot of all of your files and folders?
you have the wrong ID most likely
the problem is that your file is not in ./models/tags relative to this.client
you could say client.Schema = require("X") and use this.Schema and not define it
i put this server id
console.log(client.guilds.get("264445053596991498"))
why
dont worry about m its a placeholder
ok
const Discord = require('discord.js');
const client = new Discord.Client();
oh....
yes
im using commando
yes
and what i do?
console.log(this.client.guilds.map(m => m.id)
and replace client with this.client everywhere else iirc
np
no
here paste the code here again
no
wrong in a few ways
you dont need to redefine client
you can use this.client
client would be a string using "${client}" not an object
^
and "./models/tags" does not exist relative to this path
try const Schema = ${Schema}
you cant pass classes and complex data through broadcastEval
wait why not?
because it uses IPC
so strings but no objects?
inter-process communication only supports simple data, just like network requests
stringified objects yes
but not classes
what should I do 
@stuck scaffold for some reason, the other shards have a different path structure, so you have to try a different path
try console.log(process.cwd()) both outside and inside the eval
what is process.cwd()?
current working directory
oh
yes
what is the structure of all of the folders?
It said there's an error.
And this repeats infinitely
Basically my error;
/rbd/pnpm-volume/11354043-98a0-45d1-a8e3-a5382aaa7f46/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/client/Client.js:41
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/rbd/pnpm-volume/11354043-98a0-45d1-a8e3-a5382aaa7f46/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/index.js:8:11)
discord.js v12 requires node.js v12 or higher
update your node.js
if you're using glitch, set it in your package.json under engines
you need to show more, I assume you have a ) or } in the wrong place
up a few lines, you have an if statment?
try changing the else () to else {}
I think this is a mistyping btw
idk
tim u are a god
tim is the only god
vsc literally shows lines
build me a temple and send me donations
jesus is my only son (#offtopic)
i wanted to say something relevant here but i forgot lol
How can i get the channel id from category.children function? discord.js
I haven't done bot dev in a while but I need to write a small bot now, and idk why this is happening.
I'm using Eris with JavaScript
import { CustomClient } from "./structures/CustomClient";
new CustomClient().connect();```
Here's how I've defined **CustomClient**: <https://gist.github.com/SinistreCyborg/96fb3af2a38d00775e06a2a6a03807ea>
If I attach a .then() after CustomClient.connect() and make it console.log() something, it does log it
but the process ends right after it connects
$ node -r esm main
connected!
β¨ Done in 1.53s.```
connected! is from the .then() i tried to attach
For a bot to add a role to a user, does the bot need Manager Role permission?
Yes, unless it has the Administrator permission.
No, I'll show you why
This is all the things that are selected with .page .container
.longdescription?
https://www.youtube.com/watch?v=EN6Dx22cPRI
@trim nexus thanks man
@earnest phoenix you only want the parent container, not the children?
@trim nexus thanks man
@golden condor you're welcome
:)
always look for the class names/id in the css block below the element one
@quartz kindle yessir, I want to give the background an RGBA colour (I'll edit in inspect so you know what I mean)
there is one parent container (arrow), and many children containers (square)
to get only the parent container, use .page > .container
It didn't do anything π€
.page > .container {
background-color:red;
}
Using red as a test.
does anyone know where i could look up info on the way djs caches messages and other things?
i have a memory leak that i originally thought was because of my code, but it seems like its actually djs caching a ridiculous amount of data
v12
Thank you @quartz kindle
v12 stores caches in client.users.cache, client.guilds.cache client.channels.cache guild.channels.cache guild.members.cache guild.roles.cache guild.voicestates.cache and guild.presences.cache
Is there any way to make a collapsible header on my bot page?
thanks tim
border-collapse: collapse if using divs and regular borders
do those caches grow infinitely?
or is there a cap on how many messages it will store?
channel.messages.cache can be controlled from the client options
so it only grows as defined there (default being max 200 messages per channel)
all others grow infinitely, except guild.cache.presences, which caps at 25k i think
thanks so much
ive been trying to fix a leak for like a month now
and i decided to disable all commands and just let my bot run
it was consuming memory at the same rate
yeah, you should probably start looking into caching solutions
there are two main solutions: regular cache sweeping and modifying discord.js
cache sweeping is easy to implement, but is not as effective and may cost quite a bit of cpu
modifying discord.js can be done in a variety of ways, i tried my own hand at it and released a library that does it, but it doesnt support all discord.js features, so it might not suit your use case
i see
i can definitely afford the cpu usage
its basically unused
thanks for the help tim
im assuming this method still applies?
https://discordapp.com/channels/264445053596991498/272764566411149314/685609266488410112
yes
How can I remove the white line on the side of the image?
SOLVED:
.columns .bot-img {
box-shadow: none !important;
}
How can I make command disable code...... Any example ??
What do you mean? @robust moth
@earnest phoenix I mean
Then command run..
Otherwise command run stop```
let enabled = false
if(enabled) {
// code
} else { return }
How do you use mysql
@golden condor https://www.w3schools.com/nodejs/nodejs_mysql.asp
or you don't know how to use MySQL itself?
I am tryna connect to a db using cpanel
I could use the guide thanks for I can't connect
Did something about timings with certain client events change in v12? My bot acts weird now ... π’
I am tryna connect to a db using cpanel
@golden condor read this then https://www.tutorialspoint.com/cpanel/cpanel_mysql_databases.htm
cPanel - MySQL Databases - MySQL is the most popular Open Source SQL Database management system. To manage a huge volume of data efficiently, we store the data in tables, a group of many
lol
I needed wildcard
What kind of database is recommended for guild chat logs?
Why would you store them?
Isn't that how moderating bots keep track of deleted messages?
if you store all messages in your db your host is gonna explode
Isn't that how moderating bots keep track of deleted messages?
@earnest phoenix no
that's caching
you store last N messages sent in servers in an array/collection, then recover it if you need
but it's gone when you kill your app
I have so many questions rn
and if you set the limit to be, say, 50 messages, the 51th message will become the 50th and the 1st will be uncached
- recover a deleted message?
this kind of thing needs a message cache
also snipe commands
like the one Dank Memer have
Can't read the text in your screenshot
What is it ?
Oh are those embeds in a channel
it's a "a message was deleted in X channel"
and it contains the message content
it's a mod log
the bot tracks messages edited/deleted in that guild
each server owner can opt to enable this
what I'm trying to say is that if you need to get a message that was deleted you gotta make a cache
else you'll get a null object
discord.js stores the last 200 messages per channel by default
What if a user wish to view all the deleted msg warns etc. Of a specific member?
How would I disable the hover effect?
heya
im stuck on my website and with oauth2
discord.js stores the last 200 messages per channel by default
@quartz kindle yeah, in my case I had to manually make a cache π«
Problem: okay I have a website which is mainly built in HTML. However, I use Javascript for a different page of my website as well as CSS. In my website, I'm trying to add an Oauth2, but sadly doesn't work. It does authorise you but I'm stuck on how to make the website get to show your profile and username. π«
Math.floor(Math.random() * (max - min) ) + min;
``` should give a value between the max value and min value right?
@earnest phoenix the problem is, you should not store user content without their permission, so in order to create a massive database of messages, you need to get their permission first, which means, the bot needs to ask the guild owners for permission to collect messages, and then the guild must ask all its users permissions to have their messages collected
which doesnt really work for a public bot
so you're stuck with caching recent messages only
tim
also very, VERY rarely you'll need to get a message older than 2-3 days
ok im just waiting for someone to respond to me
why do you manually cache if you rarely need messages older than 2-3 days
I'll shorten your waiting time: post a log or code here
log?
@ kuuhaku
why do you manually cache if you rarely need messages older than 2-3 days
@trim nexus I'm not using discord.js, JDA doesn't automatically cache stuff
@earnest phoenix that is not enough information
ok so
one sec
@quartz kindle can i talk to you in DMs?
Problem: okay I have a website which is mainly built in HTML. However, I use Javascript for a different page of my website as well as CSS. In my website, I'm trying to add an Oauth2, but sadly doesn't work. It does authorise you but I'm stuck on how to make the website get to show your profile and username. π«
@earnest phoenix
you cannot use oauth2 by using plain vanilla js, html & css
you need a backend server
wdym by backend
oh jesus
oh yes
glitch
then you do have a backend
can u answer my small question real quick?
probably express.js
but it doesnt work python well
so i use repl.it
but that wont work cuz
repl.it isnt controlling the website
consider reading https://github.com/kamranahmedse/developer-roadmap
cry
Math.floor(Math.random() * (max - min) ) + min;
should give a value between the max value and min value right?
i don't know i don't do js
@finite bough it should
got a negative number
else if(res.carsowned === 'RENAULT 2CV') random = Math.floor(Math.random() * 100 - 25 ) + 25
how would i make a backend server? and wouldnt there be an alternative?
theres server templates, but just simply log the guild object, i think it works like that
mysql keeps randomly ending the connection
@restive furnace me?
yes
wait
can u talk to my friend, he knows more coding
he isnt in this server cuz hes baned
mysql keeps randomly ending the connection
I am tryna set it up and it's really annoying
i really cant right now help, sorry.. try google something "make clone of a server d.js" or something
d.js?
@earnest phoenix damn thanks for posting that link its a great guide
You can map all the channels
why would i clone..- im so confused
discord.js or what ever you're using, oopsie i forgot that theres more than only discord.js, change "d.js" to your library
im making a website, not a bot
yeah cyber it came up on my explore page and i bookmarked it cause i thought it's really useful
Tryna use mysql db and it keeps randomly terminating the connection
is it successfully connecting in the first place?
mysql keeps randomly ending the connection
@golden condor use a pooling library to keep the connection active
mysql kills the connection after 11400 seconds
iirc
@lyric mountain how
use a pooling library
which is
ah, sure then
@golden condor https://www.npmjs.com/search?q=mysql pool
there's a huge list of libraries that offer pooling and connection management for the mysql library
just pick one, and look at their docs
Or do I just install it
mysql or mongo?
whatever you prefer
I could use either
But mongo seems easier
But I also dunno how to use that
And mysql comes with my cpanel
let msg = await message.channel.send("Generating...");
let tar = message.mentions.users.first();
let user = tar
if (!tar) tar = message.author
let profilepic = tar.avatarURL;
let url = `https://eclyssia-api.tk/api/v1/triggered?url=${profilepic}`;
fetch(url, {
headers: {
}
}).then(async res => {
await message.channel.send({
files: [{
attachment: res.body,
name: `${tar.tag}-triggered.gif`
}]
}).then(() => message.channel.stopTyping());
}).catch(e => console.error(e));
msg.delete();
it justs seding a link to nothing
Hm
so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?
Hm
@slow cape check whether that file is a valid image file
so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?
@wheat jolt.filter(entry => entry.pos >= 15 && entry.pos <= 30)
Is there a way in Discord.js v12 to check if the bot has the power to assign a role to a user? Or do i have to get that info based on the positions of the role?
Is there a way in Discord.js v12 to check if the bot has the power to assign a role to a user? Or do i have to get that info based on the positions of the role?
@blazing portal check whether the bot has MANAGE_ROLES permission
that's all? doesn't it have to be below the bot user role too or smth?
yes, that too
ok, thanks π
thanks @lyric mountain
Is it prohibited to use Heroku for adding the bot? What if I'm offline for a moment, and I can't keep up my bot(s)?
Is it prohibited to use Heroku for adding the bot? What if I'm offline for a moment, and I can't keep up my bot(s)?
@leaden rover with heroku you can keep your bot 20/7 without reaching the quota
Ok
Ok
so either register a credit card to get extended quota or buy a vps
vps?
virtual private server
a VPS is the best way to host a bot and others
obviously
VPS is paid
Ok
but cheap tho
Looks like I have to wait until I'm a fully fledged dev. and get into College xD
Sorry for being off-topic
I'm 14
you......really said your age didn't u?
It doesn't really matter much how old you are unless you are under 13
ik
I have a VPS and not 18
again, ik
ok
Yes...
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
Your bot info
Ohhh
Hi, I'm bot blablabla, and I do nice things in your server.
My features involve....blablabla...
etc
etc
etc
just describe your bot
TUB use??
What
just talk about your bot
You write about your bot in the long description. 300 characters minimum. It's not difficult.
Space can use??
What
should this not return false (js)
Number.isInteger(parseInt("2.1")) ?
i want the exact behaviour of isInteger but my var is a string like "2"(expect to be true) or "2.1" (expect to be false)
Can you not tag me
Also idk
parseInt("2.1") becomes 2
I can use space?
@gentle arch you can use any kind of digit
does it return true on "2.1" ?
It returns false.
Russian here??
@gentle arch message shivaco#0001 , they know Russian.
but "2.1" becomes 2 when run through parseInt?
Thanks
You can also use parseFloat
hmm okay, just to be clear i want a function that returns false on "2.1" and true on for example "2"
But Number.isInteger(2.1) returns false
Okay then do Number.isInteger(Number(value))
He is don't answer me((
okay that seems like what i am looking for
bot.on("message", message => {
let args = message.content.substring(PREFIX.length).split(" ");
let bal = coins[message.author.id].coins;
switch (args[0]) {
case "give":
coins[args[2]] = {
coins: coins[args[2]].coins + args[1]
};
if(args[1] > bal){
message.channel.send("You are trying to give more then you have")
}
message.channel.send(message.author + ' gave' + args[2] + args[1] + 'coins')
fs.writeFile("./coins.json", JSON.stringify(coins), err => {
if (err) console.error(err);
});
break;
}
});``` could anyone help me with my give command it doesn't work
do you get an error
@gentle arch be patient
Cinnamon role, you should safeguard your code. What is each argument supposed to be (args[1] = user? args[2] = coin give amount?)
Also, you should avoid using JSON as a database.
until it breaks 
json db best
you either brake or break
you know how big json db if you are going to store user data
worst case scenario all memory gone
where can you store bot information that only requires one row of the table, on a database?
instead of a table
or do you have to have a table?
in a table
a table is just an entity in the database
like, you can't have characteristics floating around without an entity
you need a body to have eyes
Sorry
yeah args 1 should be the person and args 2 should be the amount of coins
But you're doing this in your code: js coins[args[2]] = { coins: coins[args[2]].coins + args[1] };
Should it not be args[1] as the user? How are you going to safeguard your code to make sure args[1] is an existing user ID? Why are you adding the user to the coin count?
@queen needle have you thought about using sqlite rather than json?
if you're storing on drive anyway
for right now im using json
but if i can figure out how to use sqlite on another bot and get it to work ill switch to that
there's a node module called enmap you can use. it uses 2 main functions, enmap.get() and enmap.set(). its very simple
but it should check to see the args1 the coins how much that is and args2 the user then it should see if i have enough coins if i do then subtract that amount from my coins and gadd it to the other users coins amount and send a message saying that
ill try on my other bot
as for your issue with your code
coins[args[2]] = {
coins: coins[args[2]].coins + args[1]
};
i can't figure out what is happening here
neither can i
i just took a piece of code from another command hoping it woulf work
but another thing i would suggest doing, args[2] is a number count, yes?
my bad, i meant 1
but if i can figure out how to use sqlite on another bot and get it to work ill switch to that
You could even use an ORM like Sequelize to make working with databases easier.
i would suggest parsing args[1] as an int
parseInt(args[1])
will return an integer if args[1] is a number, or NaN if it is a string
to make sure people don't pass in an argument that isn't a number
but i do not think i can help with your main problem with the command
like ^give fish or something
yeah
ill follow a coin system video on enmap
and if it works ill switch that to my main bot
if you'd like, i can make an example of the command you're trying to make using enmap
sure
@indigo folio
Saw what you wrote
Just wanted to say that using (Number(args[1])) will also work
ParseInt will too so just use your way
how do you delete an object in a json file using fs. ?
my current approach is to load the json file into a var, delete the objects inside that var, then replace the json file with the var
but perhaps there is a method to delete an object directly?
you want to replace the whole json file with an another object?
or a part of the json file?
no, just delete an object in the json file, which consist of several objects
javascript right?
so i guess delete part of the json file, and yes node.js
uh, you dont need to "delete a part" of the json file
if you are actually deleting text
you could probably try to assign undefined to that variable when you turn it into a json object
not sure how converting it back to json text will appear as
or you could override the variable
using JSON.parse() and JSON.stringify()
@indigo folio if i wanted to edit the coins myself would i be able too
@lyric mountain how do I check if itβs a valid image
What arw you trying to do @queen needle
await server.create_role(name="Name", permissions=discord.Permissions(manage_guild=True), reason="Reason") < Hey, I don't understand how to create a permissions object to feed create_role() in discord.py, it returns unexpected keyword
@queen needle there is an sqlite browser for windows, so yes
you mean change the counts in the file, right?
you can also create commands to modify counts as well
you could try downloading the image and check the file headers if its an image.
not sure what exactly "valid image" is
yes like if i wanted to change the amount of coins i had
Hi
Help me pls
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.6.1 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@2.6.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aspectra\AppData\Roaming\npm-cache_logs\2020-04-15T20_35_18_924Z-debug.log
Δ° download canvas modules
And error
install node gyp 1st
@earnest phoenix the actual reason for the error is logged before that part
but most likely you're missing required system dependencies, check https://github.com/Automattic/node-canvas/wiki/Installation:-Windows
Alright so my user need to select a server , and the server will be listed as reaction from
0οΈβ£ to π in reaction
For reaction 0 id 0000001
For reaction 1 id 77777777
For reaction 3 id 85858585
Does anyone have a trick ? Couldn't find any good way to do that
on node, try setTimeout(function(){if(msg.content == "bla bla bla)}, length)
@wise quartz
he said he already found it lol
Its okay i found it also its python
ok
@earnest phoenix reactionCollector or awaitReactions
I know about reactionCollector
but like how to connect Reaction1 to SERVERID1
Reaction2 to SERVERID2
ik that but i don't have any idea so im asking for some informations, someone talked to me about discordjs server mapping
Yeah and how can i know that id1 is reaction 1 ?
because you code it to be id1
How am i suposed ? I don't know how much servers the user will have
I don't know if the user have 12 servers or two
What language?
NodeJS
what servers?
Yeah cant help u
Bot servers
so you dont want to show a predefined list? what do you want to show?
Its hard to explain
On discord.py what do i put in to add a reaction?
You want to see how many servers every user of your bot has?
reaction1 for a server
reaction2 for another
when he react i select the server related to the reaction but, how to define by advance because it won't be the same server every time
then you need to scan your guilds for this person
@static trench await message.add_reaction('emoji uni code')
Define your await with message
Hope it works lol
let guildsThisPersonHas = client.guilds.cache.filter(guild => guild.members.cache.has(userID)).map(guild => guild.id)
this will give you a list like this [id1,id2,id3,id4] etc
then you can do if(reaction === 1) { guildsThisPersonHas[0] }
@lyric mountain how do I check if itβs a valid image
@slow cape download the file and try to open it
If it doesn't open then it's likely being messed somewhere in your code
I mean its abuse but if you are on d.js 11 it would work similar to that
Why if message content?
Are you trying that if the user is banned it will unban him once theres a message?
How can I make the text not get pushed to the left... it's been annoying me for a while
what do you mean by that?
like. how can i make it so there are only 2 fields per line so it's not so pushed together
or make the embed bigger to fit the data better
inline = false
will make the field go to the other row
then the ones you want to be in the same row, inline = true
but wouldn't that make the entire row for 1 field.. is there not a way to have only 2 fields per row
well, you can do that
you just swap between
inline = false, for the first one
inline = true, for the second one
then inline = false for the third one which will be a new row
i think
then continue
hmm, lemme try
but since you have alot of information, you might want to combine some of the fields
nope
