#development
1 messages · Page 1476 of 1
Excuse me?
can you read?
Did anyone asked for your opinion?
Hey, say for every level I want it to double by 2, for example: Level 1 requires 50 XP, Level 2 requires 100 XP, Level 3 requires 200 XP. How would I do that?
Right now, it would just goes like this: Level 1: 50 XP, Level 2: 100 XP, Level 3: 150 XP
did someone?
no one asked for your question either \0/
I Forgot To Laugh
sounds like you need a log scale
or exponent or soemthing
I dunno I'm super bad at math 😂
so grab your middle finger, put your hand on its back and shove it up right up ya arse!
So Childish
Get a better pfp, google pfp user
i want people to see my question so i only talk in bold characters
and you call me childish
i never said that
aren't you the guy that has this in his bio?
thousands of stolen accounts
childish
Arent You the guy who uses pic from google? "stolen"
Dude, I know it's possible because I've already tried to do that
even your frickin pfp is from google
But it's still illegal and against ToS
atleast i am not stealing accounts you dumbass.This is a well known meme, however the accounts you stated in your pastebin are not very public.
cRy
xp = 50 * level
Ah, wait
Yeah, log scale
sorry i actually changed my code
collector.on('collect', (reaction, user) => {
message.channel.send("Okay, the cart is being cleared!")
console.log(filtered)
var cleared = allItems.splice(filtered, ' ')
fs.appendFileSync("./cart.txt", cleared)
});````
and this is filtered
so it should indeed remove these from the allitems, but it's not.
xp = 50 * level ^ 2
This would work
array.splice accepts an index at which to start deleting elements and the amount of elements to get deleted
both of your arguments should be numbers - but your first is an array and your second is a string
is that the stupid dog? (your pfp)
hmm but i can't know the index of it
as it changes for everyone.
for one, it might be 3, for someone else it might be 12
like i told you use .indexOf() to get the index for .splice()
that would return me an amount?
and if you have the index you can use .splice() to remove the items
it's an array
Oiii
that is saved to a text file
i mean, it's only a couple of values
so i would have to do filtered.indexOf("what should be here"?)
i don't see a need of making a different type of DB for it
the item to remove
It's a couple of values right now...
I am going to put the base first, so i can later on migrate it to a database. I am purely doing this to learn.
aha okay!
mhm but if it's like "James", "Test" it's fine
.txt file can be corrupted if you edit it at the same time with two commands
i am making sure that it doesn't happen.
so all your users waiting for one command to finish? :3
Honestly - there are better ways to learn about arrays than this, lmao
I am not going to deploy it or whatsoever.
just making it for myself.
const cleared = allItems.indexOf(filtered)
console.log(cleared)```` this btw returned -1.
idk if that's supposed to happen
If it returns -1 then it doesn't exist
-1 means it doesnt exist
okay that's hot.
what is filtered?
this:
{$add: {b: {w: 1}}} would this valid (mongodb updateOne)
try and see if it works
this is final
well this is development in a nutshell
yes
this is allItems.
genshin dying
i was not expecting it to dip this fast after the update came out
or servers with 50+ Bots are forced to remove some
meanwhile my bot stuck at 300. even with advertising
anyone knows why that's happening?
as they are clearly there.
ucz its intended?
case insensitive?
use regex instead?
theres plenty of thing that could be happening
Is filtered the same array that is in allItems
yeah
Are you sure? Show me how you declare filtered
.indexOf() needs a string, like the name you search in your array
it doesn't need a string
highly recommend this btw https://code.visualstudio.com/docs/editor/debugging
it does in his case
regex can also be accepted
which is what i recommended, case insensitive is a better match
or toLowerCase() first then search
oaky hold on
though i doubt that'd be the issue
allItems = fs.readFileSync("./cart.txt", "utf8").split("\n").map(x => x.split(/ +/))
console.log(allItems)
let filtered = allItems.filter(x => x[0] === message.author.id)
let final = filtered.map(x => x[1]).join("\n") ```all the variables used.
filtered isn't really in allItems.
See the image. When you store an array of arrays, you are basically storing the "references" to those arrays.
owh okay i understand that
[1, 1] === [1, 1] is false.
arr === arr```
is true
This is why a text database is a mess, it's hard to write, it's hard to read, it's hard to update, it's hard to delete and it's prone to corruption. I don't know why you're torturing yourself, but imho you are wasting your time.
PostgreSQL
Is there a way to retrieve all PRIMARY_KEYS under a table?
yeah but i already started and am almost done with this code.
i can't just throw my progress of the day away
your 1 day wasted here will turn into 5 later on when you realise how bad a txt db is
Feud is right about that
yeah you guys are right about that
There's probably a solution to that, but idk it
Isn't there something like SELECT PRIMARY KEY FROM table?
did you google it
i did, though some of the queries are bound for a whole schema/db
im trying to fetch a specific table with the types + contraints
Anyway, why do you need to do such thing?
but JOIN also doesnt have the same shape, so i cant merge them into a query
What are u trying to achieve?
magik
well, i explained it anyway
Have you tried the one from stackoverflow?
wdym tried the one from stackoverflow?
Doesn't work
the query
WHICH query?
Why not?
Gives like 2 XP needed as the number
And apparently ^ in JavaScript isn't a thing for powers
Math.pow()
or **
I tried Math.pow() too but it seemed to give some messed up number
both work the same way
Math.ceil()
Alr I'll try **
https://stackoverflow.com/questions/1214576/how-do-i-get-the-primary-keys-of-a-table-from-postgres-via-plpgsql I tried it back then and it worked
Btw, define "messed up numbers"
Because pow will get u exactly the number to some power
this is not quite what im looking for
i need 2 JOIN queries
i tried this one before
the issue with is it is the types
the types?
Oh, that formulae won't work
@earnest phoenix
this should give an idea of what im trying to accomplish
i need a query that returns, per table, the collumn, the constraints, and the types of each collumn
i could do 2 queries and join them in code, but i'd much rather have a single database call instead
actually, i noticed a flaw in that query
still not quite what i expect
I tried 50 * level ** 2 but why does it go from 50 to 200? Why not 50 to 100?
.replace() ?
** goes first
50 * 1 ** 2
50 * 1
50
or put it in parenthesis
thats why i use math.pow
makes the order more clear
so you don't care with it being a primary key or not?
I have a reaction collector for a function on my bot, and a simple filter allowing only the message author to make the reactions do something, but how can I have it remove someone elses reaction if its not the msg author?
Then you'd have to get rid of the filter, and in the "collect" event check if the reaction is coming from the author, and if it's not, remove the reaction
10k 
thats what you are doing though
As I said, that formulae won't work
50 * level ** 2
You'll need a log scale
50 * 2 = (100)^^2 = 100 * 100 = 10k
That formulae will scale really quick
the math is right, your formula is wrong
Wait, no
Not the way you explained
50 * level ** 2 will be Level ** 2 = result
Then 50 * result
(50 * 2) ** 2 = (100) ** 2 = 100 * 100 = 10k
i explained it right
10k, as seen here
they are using this
Ah, yes, if you put it that way
i just used ^ intsead of ** to make more sense of it
God damn bruh why is this part of the code so difficult to even do 
It's not
You need to experiment different formulas
Anyone see this in the Discord update?
Postulated new slash commands for bots. Performing actions with bots is easier than ever. Now, developers can have a list of commands available for their bots accessible by the slash key (/). You won’t have to remember bot commands anymore and get laughed at when you get the command wrong 😦 !help…..!help….please
yes
allItems = fs.readFileSync("./cart.txt", "utf8").split("\n").map(x => x.split(/ +/))
console.log(allItems)
let filtered = allItems.filter(x => x[0] === message.author.id)
let final = filtered.map(x => x[1]).join("\n")
let d = allItems.filter(s => s.replace(/\s+/g, '').length !== 0)```` i am tying to remove the extra space i have in my text file.
s.replace is not a function
the outcome
why is this and how do i fix it?
If allItems is an array of arrays, then s would be an array, not a string
ffs ofc. So replace wouldn't work again
allItems = fs.readFileSync("./cart.txt", "utf8").split("\n").map(x => x.split(/ +/))``` isn't there any other way to remove a space from this array.
you should, at the VERY LEAST, keep the cart in memory rather than reading it everytime
its really sstupid to do it that way, regardless if you want a database or not
at LEAST keep it in memory
im aware, that doesnt change the fact
you said yourself you are doing this so you could learn, im teaching you NOT to corrupt your txt file
keep it memory and manipulate it inside
@opal plank primary key per table with its type, is this what you're trying to get?
hi! When I create a poll the bot adds reactions to my command, they should be added to the poll sent by my bot. Code: https://pastebin.com/xxpqFSbM Could you help me please?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
yes, though a bit more of that
not ONLY primary keys inside a table, but all types + primary
as a better example, i need something like this
const collector = message.author.dmChannel.createReactionCollector(filter, { time: 60000 });```uhh this ain't really working.
message.author.dmChannel.createReactionCollector is not a function
@earnest phoenix
table_name = foo
returns {
column_1 : {
type: 'int'
PRIMARY_KEY: true
}
column_2: {
type: 'charcter_varying'
PRIMARY_KEY:false
}
//all other collumns in table
}
the data that i need is;
input table name
retrieve type, collumn name, constraint PK and IS NULLABLE, for all collumns inside table name
which is what im struggling to retrieve
uhh
Use the message sent not the message received
Can you please explain a bit further? I don't understand :(
When you send the message, if you await it u get the message object
Use it to add reactions, not the message object passed to the command
@earnest phoenix i got what i needed, i just need to merge them inside a single query
i neeed to merge them by table_name
oh nice, I just messed around with what I found on stackoverflow
LEFT JOIN probably would be the best bet here
anyone that can tell me how i make my reaction collector work in dm
i already looked both in pg docs and stackoverflow, neither helped too much
there arent very use cases for this, its very rare for someoen to need to map a whole schema/table types
it joins tables basically, but its a bit complicated
I'm sorry, I'm a newbie. Now I understand a bit more, but not enough to do it. Could you please show me how?
i usually do function joins, which is a bit more complex
No, I recommend doing easier stuff before trying more complex commands
There's no shame in starting with Hello World
oh, so USING is the shorthand for ON if the column name is the same
Why is it not working?
Any error?
const filter = (reaction, user) => {
return reaction.emoji.name === '❌' && user.id === message.author.id;
};
const collector = cart1.createReactionCollector(filter, { time: 60000 });
collector.on('collect', (reaction, user) => {
message.channel.send("Okay, this process has been stopped!")
});```
i just don't know how to do it.
Check the docs then
It's the same thing
kinda, yes
But you can't get guild data because its not a guild
I am just trying to get the reaction.
no guild data or anything.
but i can't find on the web how to do it.
What's cart1? Where are u defining it?
const carts = new Discord.MessageEmbed()
.setColor('RANDOM')
.setTitle('**This is your checkout cart!**')
.addFields(
{ name: '**items**', value: `${final}`, inline: true },
{ name: '**Total price**', value: `${money}$`, inline: true },
)
.setDescription('**Click on the :x: if you want to stop. Click on the :white_check_mark: to proceed to checkout!**')
.setImage('https://media.giphy.com/media/3mfxyjHgjQptBZKyHX/giphy.gif')
.setTimestamp()
.setFooter('Command hosted for you!')
let cart1 = await message.author.send(carts);
await cart1.react(reactionEmoji2);
await cart1.react(reactionEmoji1);```
I see, so mine could've been
SELECT c.table_name,
c.data_type,
constraint_name,
constraint_type,
c.column_name as column
FROM information_schema.table_constraints JOIN information_schema.columns c USING (table_name)
WHERE c.table_schema not in ('pg_catalog', 'information_schema') AND c.table_schema not like 'pg_toast%'
"""
no errors*
looks about right
discord.User has no roles?
discord.User doesn't have roles attribute, Member does
let channel = Discord.DMChannel
const collector = channel.cart1cart1.createReactionCollector(filter, { time: 60000 });``` i tried this but it didn't work either
I'm afraid I can't answer your issue
Cannot read property 'createReactionCollector' of undefined
okay
that's alright!
Cart1cart1
what does discord use to turn the user/bot's ID into the first part of their token?
Base64
how would I do that?
?
Pretty sure it's base64 for the whole token except the key
maybe
It's because of "return"
but how would I turn a number into base64?
Use base64 encoders
hmm
Everything after that line would not be executed since "return" by default returns None
Every lang has at least one
yea
Don't ask me HOW to generate one from scratch tho, idk how tf base64 is calculated
Only know there's a lib for it
probably Buffer
Buffer?
🤔 oh you used discord.User
Yep
figured it out
Buffer.from(id).toString('base64')
${message.author}, you are ${Math.floor(Math.random() * 100)}% gay.
almost there
but you were mixing `` and ''
He used `` but ok
how can i send users with api. I tried to use postman for get that but i always get unauthorized message
the token is longer than in the pic
so i don't blur it
Ok so I have this array:
[{name: "user1", gold:100}, {name:"user2", gold:200}] and I need to sort it on gold high to low how would I do that?
use Array.sort
bruh, spoonfeed
k
idk if it'
s just postman but
when I send auth headers usually I have to prefix them with the type of token
Authorization: Bearer {token}
"name": "Discordbot",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.5.1",
"mongoose": "^5.11.3",
"ms": "^2.1.2"
},
"devDependencies": {
"nodemon": "^2.0.6",
"prettier": "^2.2.1"
},
"description": ""
}
I haven't been on VS Code for a bit and missed the update. Apparently there is now something wrong with this. It says that the "Discordbot" string in "name": "Discordbot", doesn't match this pattern. I'm using Java but this is a json file.
iirc the api token doesn't have any prefix
the package.json name must be lowercase
it has some other rules but thats whats wrong there
so it needs to be discordbot instead of Discordbot?
ok ty
np
Nice
hey how do i make an async command on if (message.content === 'command' etc
in discord.js
make your callback async
lol
am i dumb how do i cover links in embed fields? (discordjs)
you can only use them in field values and embed description
not sure what you mean by cover links though
nvm got it
just like basic markdown
thanks tho
confused me that users cannot do it in chat the same way
let o = {
'123': [
{
webhook: [Object],
user: [Object],
channel: 'XXX'
},
{
webhook: [Object],
user: [Object],
channel: 'XXX'
}
]
}
Object.keys(o).forEach(a => `${a} - ${o[a]}`)```
what is wrong? returns `undefined`
values?
same
Object.keys() returns string forms of the properties
You can't access their value like that
Object.values() return the same thing?
Well uhh, Object.entries() exist
you could do it with for and of
bruh
thats the way i like to do it
for..of is for iterating through an array, not object
you can iterate through objects as well
that's for in
works with of as well
nope
Simply no
for (let i of Object.keys(idkwhat)) {
console.log(idkwhat[i];
}```
pretty sure this works
Without the usage of Object.keys()
i have no idea what you are trying to say
Hey guys, I'm making a Discord server and i want to invite as many bots as posible. If you host a bot can you send me the invite to DMs?
i stand to my Object.keys <3
I use Object.keys also
yea same
Hello, im having a problem with quick.db installation
The command prompt gives me alot of errors when i type the command: npm install quick.db
did you follow the quickdb troubleshooting?
Thank you Whoo!
free source codes 
Hey,
i'm trying to send a DIscord Webhook. But somehow i always get a 400.
https://imagego.reeee.ee/bO2K51 this is my Code. Has anyone a idea why this happenss?
Its literally copied from another project where its working fine
Even postman says its good. But even there a 400
wtf is this Webhook stuff
Anyone have any sort of idea of how a bot would add multiple language support and have it respond with whatever language the user sets the bot as with a settings command?
fck finally
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
}
});
client.login('token');
umm
Ok what it is
🤔
how do I fetch for a message by ID?
let sEmbed = new Discord.MessageEmbed()
const channelStrikes = bot.channels.cache.get('791454242908012564')
Swap these
Anyone know how to send a discord attachment text file from a string without using the file system
channel.messages.fetch('791453903165194240').edit -> channel.messages.fetch(...).edit is not a function
fetch returns Promise
yes
yes
or can I just await fetch.edit
you can if you use (await channel.messages.fetch('791453903165194240')).edit()
if you want to await the edit use await (await channel.messages.fetch('791453903165194240')).edit()
is that a 1 (number)
?
it's probably lb
lbchannel or 1bchannel
Your code looks correct. Can you share more of it via hastebin
error: https://prnt.sc/w89c1i
code:```js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { ThemeProvider, CSSReset } from "@chakra-ui/react"
ReactDOM.render(
<React.StrictMode>
<ThemeProvider>
<CSSReset />
<App />
</ThemeProvider>
</React.StrictMode>,
document.getElementById('root')
);
reportWebVitals();
vigin ngl that's quite hard to read
I'm not entirely sure about react/chakra 😅
It's not async
oh
.then(async () => {})
how can i make my bot identify if a constant's value isn't a number?
use the is-number package
what
you need a package to check if a string is a number?
no

isNaN('not-a-number')
is this a joke
oh right
if you feel stupid, remember that i tried to change a constant's value in another line of the code.
You'll feel stupid when you spend 10 minutes trying to optimize something to then realize it shouldn't have been adjusted in the first place
uh
if you feel stupid, remember some idiot managed to get by with spamming Twitch's API with a test library and a shard spawner with 3000 shards within 12 seconds
Not pointing fingers though, but he's here in this channel
👀
is it me
i dont recall you ever touching Twitch API (which no human being should, its trash)
You should see Hypixel's API
hey
how can i make my bot identify if the ID of a channel provided is from the same server?
find the channel in the guild channels cache by id
Which is as easy as this if you're using Discord.js: js <Guild>.channels.cache.has(id)
thx!
Is there a way to use discord OAUTH-2 to write an activity to a user
wdym write an activity?
yes if you request the right scopes
friends how do I delete these null values.
i want it to look like this:
Yardım
Bilgilendirme
How would I go about doing so?
What did you send to get the values... is it an array?
Hmm...
possibly just use the built in respectable classes (as MessageEmbed or RichEmbed) and make a check to see if it has a title / description and if so set the title and description.
for(const prop of obj){
if(obj[prop] === null) delete obj[prop]
}
Then you can just convert the object to an array and send the array joined by '\n'
What would be the function for doing so?
well using oauth, you pass the scope and once they accept it you will have their access token and do x if you have privileges.
Is there a way to do it using passport-discord?
Yeah, just do all of the normal stuff then pass in the extra scope.
these are the scopes
I know the scopes
I just don't know the code to change the activity
const DiscordStrategy = require('passport-discord').Strategy;
const passport = require('passport')
passport.use(new DiscordStrategy({
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
//callbackURL: process.env.CLIENT_REDIRECT,
scope: ['identify', 'email', 'guilds', 'activities.write'],
}, (accessToken, refreshToken, profile, cb) => {
console.log(profile.username);
console.log(profile.id);
console.log(profile.guilds.length)
cb();
}))
//discordstrategy.js
This is my discord strategy file
What would I add to make it update the activity... Looking through the docs all of the discord examples are written in python
whats your question?
j
how to get oauth2 link to make a bot login to ur account
ex. like this
its kind of a long process
ye
oh
check on youtube
but can i connect it on my index.js
main file?
the bot's main file?
uhhh wdym?
nvm
test
how do i destroy this
I just want it to appear as "Sıraya Girin".
it only show the link of what server to add ur bot
it needs to match the url you had in developer portal
and you must properly encode it
please tell me you're not evaling that
how would i delete only the bots messages without going over any other messages in discord.py?
Nai wa
how are you parsing that?
cuz depending on ur answer it might be a big flaw
I'm just using a .replace
oh, okay, i thought it was js for a second and things could be sketchy with that
for example ${process.exit()}
Oh, the localization
I just use .replace for that too
just making sure you're actually replacing the string rather than running it with the user inside
Lol
@opal plank My brain couldn't think of hacky code if it tried lol
The snippit I use for levelling looks like this
I'm actually not using my localization code here, but I should
Just that I don't have a handle to a Locale instance here, which complicates everything
Normal commands have access to an instance of that, but this is a hook, not a normal command
Except for levelling, this is the code that I usually use when localizing
(For the V4 Alpha version of my bot, not the stable V3 version)
oof
though because of js i understand quite a bit of it
the methods are similar, but both the syntax and the structure are different
Yea
it is weird that you're using json though
how do i destroy this
I just want it to appear as "Sıraya Girin".
where is that in?
embed
The previous version of my bot, I just used an Enum and hardcoded the values in a giant switch-case statement
So you gotta admit this is much better
which field?
embed.fields.value
hmmm if its only reading it should be fine, but avoid writing too much as json is prone to corruption
I took the embed as a message.
fields.value ?
yeah
fields is an array not an objcet
That doesn't look like an embed
@opal plank I stopped that, like, over a half year ago
At first, I just swapped to a multi-folder system to minimize corruption
But now, I now use a DB for anything that can be modified
Speaking of, it's been a month or two since my last DB backup
then its even better. Though if you're using a DB, why not keep it in memory and only read/write on from db on change? im unsure why you persists with Json
cant you just use something like JDBC and call it mid way?
@opal plank I don't even cache the DB lol (and performance is just fine!)
The json is only for configuration and resources. It doesn't mutate at all.
though when the user changes the message it should write on it right?
That writes to the DB, not JSON
say, someone were to poorly time it and the admin of the server does !edit and a user talks (or even the admin messag) both trigger a write and a read, wouldnt that be an issue?
then whats the purpose of the json?
they would de-sync then, no?
Afk
Hello
The snippet with the JSON is how I generally handle messages
The other snippit is how I am specifically handling levelling messages
I plan to change to just using the same code for both
The problem with that is here:
I'm using levelling as a hook, which does not have access to a Locale (the snippit of code with the JSON)
Therefore I can't use that part
Anyways, if I did have access to a Locale grip in that area, my code would look like this
Configurations and resources
The json is stored locally or in memory?
It's initially stored in disk, but we then parse it into memory
@lyric mountain
We don't modify it at all
Still, you could unload the json into a hashmap
Since we use a DB for things that get modified
It's more optimized
If you use the official json lib you can directly convert from one to another
This is my largest JSON file
And it loads just fine
I don't think I really need optimization
This is my second largest JSON file
Wait, is that a localization file?
Yea, why?
Why are u using a json?
Why not?
Locale files can get really big
And jsons inflate a lot when in memory
@opal plank you were the one that said nano bad right?
Eh, not too bad
I'm pretty sure that the library is caching every single member, anyways
Which has got to be a lot worse than JSON
Let me boot up VisualVM
yeah, cuz tis shit
it does what its meant to do
@lyric mountain So as long as it's not this random byte array, I should be fine...
Wait
I think that byte array might actually be a memory leak
Because it keeps increasing
Nm
So right now I am doing
let name = arr[i].slice(0, -5)
let user = await msg.guild.members.fetch({ query: name, limit: 1 })
but as you can see I am slicing off the tag because it won't work if I don't, so does anyone know a method where I don't have to slice off the tag.
I mean this works, but I would have to check it with arr[i] again in case they have same username but different tag
dev advice if someone kicks or bans the bot should the guilds data still be there
keep in mind if the guilds data is gone so is the user's (for that guild)
@earnest phoenix if you're asking for help with coding a bot I think this is the channel
I used to but now I don't. I'm using repl.it rn
hm well if you delete it and then the bot gets reinvited then that would be a problem
It depends on which library you are using
Different libraries handle cache differently
I'm going to assume you are using Discord.py, since your status shows you use python
yes
I mean from a database
so if one user from x guild collected 100 coins
then that bot got yeeted from x guild
Oh
If you are storing data to a database manually, you would have to delete the data yourself, else no
those 100 coins are gone
well which bot language do you want to use?
it's 1 line to delete the data
await Guild.filter(discord_id=guild).delete()```
all of it
would go in that 1 line
but I don't know if they add the bot back
and see everything is gone
and get upset or something
so looking for advice
You can add a time cooldown, maybe?
elaborate...
A piece of advice
I assume you are running that on a guild delete event
Make sure that the reason for the event was not that the guild was "unavailable" (aka an outage)
I dunno how Discord.py handles this, so you'll have to check
But I digress
Anyway, you can delay the action to be, say, 2 days later. After that 2 days, if the bot still has not been re-added to the guild, you can delete the data. If it has been re-added, then don't delete the data
Let me check the documentation real fast, I need to see if Discord.py triggers that when a guild is unavailable, too
Since I know some libraries do so
Sorry I'm busy helping somebody else
Also I don't use VS
That sounds nice
I'll look into it some more
since like nothing is global
should probably start making them but whateves
Ok, I checked the docs, you are fine
Some libraries merge the guild_unavailable and guild_remove events, which can be disastrous
But Discord.py does not, luckily, so you are fine
@pale vessel elp
fuc
message objects don't tell if the author is a bot, do i have to request that or something
<Message id=791518241092141056 channel=<TextChannel id=783731792389603340 name='main' position=15 nsfw=False news=False category_id=770887335629291524> type=<MessageType.default: 0> author=<Member id=784132540587704320 name='Why r u gey' discriminator='7336' bot=True nick=None guild=<Guild id=770887335629291520 name='Tabi' shard_id=None chunked=True member_count=16>> flags=<MessageFlags value=0>>```
they do
but you can check that tho
oh
there should be the author/member object
unless they're partials
idk what your payload looks like

@trim saddle Why you be writing your own lib? Discord has plenty of libraries
I mean, I wrote a library for a different chat client, but at least it didn't have a million libraries already
Making your own Library is a good way to expand your knowledge in a specific language
Ah, the only new language I've started learning lately is Haskell
Which I am really, really bad at
I glanced at Python, it was easy, so I figured no point learning it until I need it.
I'm slowly slithering into typescript/js through adding features to the top.gg premid presence
It's quite fun to work with, i gotta admit
JS was my first language
Surprising that I ever managed to get interested in programming lol
Ghost is best character
prebuild-install || npm run build-release
sh: 1: prebuild-install: Permission denied
/tmp/build_c5542ad3_/node_modules/.bin/node: 1: /tmp/build_c5542ad3_/node_modules/.bin/node: MZ����@H��: not found
/tmp/build_c5542ad3_/node_modules/.bin/node: 1: /tmp/build_c5542ad3_/node_modules/.bin/node: Syntax error: Unterminated quoted string
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! better-sqlite3@7.1.1 install: `prebuild-install || npm run build-release`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the better-sqlite3@7.1.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! /tmp/npmcache.7uTMh/_logs/2020-12-24T05_21_23_383Z-debug.log
- Node version not specified in package.json ```
How do i fix this
use codeblock
Can you be more specific? What do you mean?
im trying to connect my bot in a website but idk how
how would i make a bot delete a certain users messages without going over other messages, just that specific users in discord.py.
@quaint peak I once did this in D4J (yes, it's a different library, but same concept)
You need to get all messages within the last 2 weeks (you cannot go past that)
Filter by ones with a matching ID
And bulk delete the ones that remain
what
they seem to be partial
yes i am
You can loop through channel.history and use a lamdba to check if the author is a certain person
I'm just giving you the basic concept
You'll need to
for the exact methods you will need
Limit yourself to 2 weeks (the max) though
And also bulk delete, not normal delete
how do i ban and unban user in js
after getting user name
The limit can be anything
insane can you show us your package.json file
Its a kwarg anyway
Anything less than 2 weeks
Otherwise, you are uselessly looping over messages that cannot be bulk deleted
(A huge time waste, I've made that mistake before)
And using normal delete would just a) be API spam b) take an eternity
Then the user can specify the limit in an arg
And you can then add a check if that arg is over some nimber raise ValueError
Or something like that whatever floats your boat
Yes
But you should also stop deleting messages older than 2 weeks
There is an entire thread about this limitation
https://support.discord.com/hc/en-us/community/posts/360040900231-Allow-bots-to-bulk-delete-messages-over-two-weeks-old
Messages just won't delete if you go older than that
If you specify a custom limit, you can delete less messages, but you cannot delete more, so there's no point in even trying
(Assuming you use bulk delete, which you should be, as otherwise you would be spamming the api)
🤔
so i got a question
if i want something to happen in a specific time, i use setTimeout
hellow
Anyways, goodnight, we kind of derailed from the initial question asked
something
}, 5000)```
now, how to make something happen every 5 seconds for example?
kind of true lmfaooo yea goodnight
setInterval
But if you shut down your bot, that repeated action won't persist, just a note
Yea
It won't persist though
You'd have to use a DB to make it persist
how can i unban user in js
message.guild.members.unban(member, reason)

TypeError: error is not defined.
@earnest phoenix when asking for hep, you should be clear and concise. Right now, I can't understand a single thing you said.
What error?
console.log(ms(5s)) // returns 5000
// how to do it the other way round, like make 5s out of 5000?```
it is saying Couldn't resolve the user ID to unban
show ur script
mes.guild.members.unban(mem, 'hi')
ms (s) {
return s * 1000
}
no like
?
the full script
is your command just that?
if(mes.content.startsWith('eme')){ let ful = mes.content.substr(3) let sp = ful.split(" ") let arg = sp.slice(1) let ss = arg.toString() let mem = mes.mentions.users.first() if(mes.member.hasPermission('BAN_MEMBERS')){ mes.guild.members.unban(mem, 'hi') }else{ mes.reply('You dont have permission for baning user') } }
which language is this ? PHP ?
ms(ms(...))
bad joke my m8
You want to convert from ms to some time
bdfd or something
bruh
Oh brother
lemme Google for BDFD
what the hell fucking library is this
why would anyone need this
lots of guys need it
and make your own function
what to do @tribal siren
Why do that when a library already does it for you? :^)
It's more than what you think it is.
because you don't need bloat packages
can't we use new Date(/*ms*/);
Please see the package before criticizing it, because there's more to it than you probably see.
mes.guild.members.unban(mem.id, 'hi')
i guess
i will try
true and it probably does exactly what its supposed to for the people who use it
but imo its kinda just bloat
like come on
ms is like everything about time
@sudden geyser what package is that
ms
ofcourse
@tribal siren it shows Cannot read property 'id' of undefined
if there is fs, surely there is ms
do you mention a member tho
milliseconds system
tho?
do you guys use 60000 as your 1 minute constant or 60 * 1000?
doesn't matter which one you choose, but you can add underscores for readability (60_000)
damn you scum
TIL
I know it but always forget to use it
no hate for that
foo?.bar || "n/a" or foo ? foo.bar : "n/a"
i used to use the latter but now that i upgraded my node
it's useful but can be harder to understand for larger numbers: 86_400_000 vs. 60_000 * 60 * 24
first one seems cleaner
depends for me
if im writing code for me probably the first one
tho?
though
how
read this then
did you mention a member
that's the user id
you can get it through multiple ways like mentioned users or just using the id argument from your unban command
@pale vessel i'll foo your bar if you don't bare with me and help
what does the object look like
hey flaze, do u know ts well?
client.on('guildMemberAdd', async member => {
if (message.content.startsWith(prefix + "wl")) {
const channel = member.guild.channels.cache.find(ch => ch.name === '💠bot-commands');
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
// Since the image takes time to load, you should await it
const background = await Canvas.loadImage('./Untitled-3.png');
// This uses the canvas dimensions to stretch the image onto the entire canvas
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
// Use helpful Attachment class structure to process the file for you
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'Untitled-3.png');
message.channel.send(`Welcome to the server, ${member}!`, attachment);
}
});
it not working
it wil not send it
do you have the guild members intent
you need it for the event to trigger
sfsd;lfoijsfd
{ type: 0,
tts: false,
timestamp: '2020-12-24T06:04:15.269000+00:00',
referenced_message: null,
pinned: false,
nonce: '791546753089273856',
mentions: [],
mention_roles: [],
mention_everyone: false,
id: '791546766113767454',
flags: 0,
embeds: [],
edited_timestamp: null,
content: 'e',
channel_id: '791500215009935371',
author:
{ username: 'Skullbite',
public_flags: 131840,
id: '158750488563679232',
discriminator: '5245',
avatar: 'f5e9fddf28b6856a64415b5431014a5f' },
attachments: [] }
this is for a fucking dm message
you need to fetch it then
since other libs have structures + caching
so the author object is guaranteed to have the bot property
slow downeeeeeeeee
i made it to a command for testing
yes
What is better? Storing just channel ID123456789 in database or storing like this [#123456789](/guild/264445053596991498/channel/123456789/) in db
Just the ID
Why not [#123](/guild/264445053596991498/channel/123/)
Because you can easily add those
if i do id is that only going to work for my server

im not smart to do that
Lang and lib?
i am trying to get the id of user i have meansed in message but it shows id is undifined
.js
NodeJs
?
is there anything called embed.title.content
message.guild.bans is not a thing
@tribal siren
how to do it properly then
use message.guild.fetchBan(args[0])
;-;
idek myself so ye look at that instead
ok
how do i put server count of my bot in the web?
okay
BTW it should be on #topgg-api
do i need to change dbl.on to client.on?
reh?
eh?
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
That shouldn't post server count
wrong place'
use async
just run a setTimeout and pass dbl.postStats(client.guilds.size)
Oops! Error: 401 Unauthorized
someone warned me about spoonfeeding
;-;
if(message.content.toLowerCase().includes('cyber'))
message.channel.send("Key Word Detected ");
else {
for(var i = 0; i < message.embeds.length; i++) {
if(message.embeds[i].title.includes("cyber") || message.embeds[i].title.includes("cyber")) {
message.channel.send("Detected");
break;
}
}
```
what we are using i variable for in this code
i is the loop variable isn't it
its also used in embed[i]
you can't run a for loop without it
catch (error) {
console.error('Error trying to send: ', error);
}
});
function catchErr (error, message) {
client.users.get("390690088348024843").send () ("There was an error at channel" + message.channel + "in guild" + message.guild);
client.users.get("390690088348024843").send ("ERROR" + error)
}
why is it not working
Do you know how for loop works ?
why it is in message.embed[i]
i get the loop and i am not asking for loop
probably it's an array
Do you know how you can loop through an array with for loop ?
@pulsar bone for your concern
let a = [1,2,3,4,5,6]
for(let i = 0; i <a.length ; i++){
console.log(a[i]);
}
lol i am so confused
you did understand my question
how do i authorize my self -_-]
it gets the last element
with a token you get from the api doc
Recycle Bin and Git : Are we jokes to you ?









