#development
1 messages ยท Page 1025 of 1
but with member
websocket receives a request from Discord with certain data -> data gets processed internally by the library -> library calls a function that's set as an event
Windows XP shutdown noise<
lol
Okay show ban and mute
make ur own websocket and library for your api and then you'll know how it works 
Looks like your event is inside something grizz
I'm gonna do that with my esolang at some point
@pure lion i changed them
After I learn cpp
lol
nice dot
dt
not being modular 
basically my api
That's very
oh god
I put my code above all the ones in the event
the code is not in a while True loop
it still spams
@weary ridge THAT IS EPIC GAMER CODER MOMENT
modular code is much more manageable
000..000
Lul
i have another file called keep_alive that keeps my bot alive 24/7
message.guild.members.get is not a function
should i add cache?
@solemn latch i see i done it thanks tohttps://discordjs.guide/additional-info/changes-in-v12.html#roles
he is using djs
not python
my bot spams when i never told it to in the code
i think i didnt fuc it up
if you have a loop with no ending condition it starts to spam
or you loop a timeout (idk how the py equivalent is) with a really short delay it spamms
ok
@cobalt spruce how many lines?
@placid iron 485
didnt you say you got rid of the while true @elfin flower
i managed to get it down to around 800 now
wdym handlers. do you mean those @bot.event things
and yeah i do like my whitespace
XD
0.0
Anyone know how I can make my djs v12 bot take a user ID instead of a mention?
use args
well of course
find a member with that id
aaaa
you might wanna check if its the right format to be an id
which i think regex would do
alright, I just figured it out, thanks :)
I figured it out. Basically what I did is since all of my commands extend the same base class, I can use Class.forName("CLASSNAME") and then use class.newInstance() with a default constructor that just writes an object containing the help information and then use the BaseCommand's getHelp method (that every command has overwritten) to retrieve it
^My question from earlier in case anyone else had a similar problem
@client.event
async def on_message(message):
if message.author.id != 612900626799788042:
if "AHHHHHHHHHHH" in message.content:
await message.channel.send("ok")
it spams ok fsr
help
What's that ID
my id
can anyone help me
UnhandledPromiseRejectionWarning: TypeError: client.users.has is not a function
i get thus
when using unban comman
tried restarting code?
yes
if(command === "unban"){
if(!msg.member.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, You do not have perms to unban someone`)
}
if(!msg.guild.me.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, I do not have perms to unban someone`)
}
let userID = args[1]
let reason = args[2]
msg.guild.fetchBans().then(bans=> {
if(bans.size == 0) return
let bUser = bans.find(b => b.user.id == userID)
if(!bUser) return
if (!client.users.has(args[1])) return msg.reply("Couldn't find user")
msg.guild.members.unban(bUser.user)
let bruhgggg = msg.author
const unban = new Discord.MessageEmbed()
.setDescription("Member Unbanned")
.addField(`Member id : ${userID}` ,`By: ${bruhgggg}`)
.addField(`Reason` ,`${reason}`)
.setFooter(`s!help For Commands`)
msg.channel.send(unban);
})
console.log(args)
};
```
your on 12 correct @delicate shore ?
yes
you know, phones also have browsers
but
i look at docs all the time on my phone
it's diffuclt on mobile
What
moreover my phone is 5 percent
ahh fine link me to docs smh
client.users.cache?
@delicate shore yes
Look them up
ok
https://nmw03.is-inside.me/HG1AR1zL.png
how can I remove this white line
rip
[ 's!unban', '432533456807919639', 'test' ]
args are fine
because it's logging this
so
@summer torrent #bot-details-page #details .container -> border-top: none
Show code where you're unbanning
i see
one min
i ama send agai
if(command === "unban"){
if(!msg.member.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, You do not have perms to unban someone`)
}
if(!msg.guild.me.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, I do not have perms to unban someone`)
}
let userID = args[1]
let reason = args[2]
msg.guild.fetchBans().then(bans=> {
if(bans.size == 0) return
let bUser = bans.find(b => b.user.id == userID)
if(!bUser) return
if (!client.users.cache.has(args[1])) return msg.reply("Couldn't find user")
msg.guild.members.unban(bUser.user)
let bruhgggg = msg.author
const unban = new Discord.MessageEmbed()
.setDescription("Member Unbanned")
.addField(`Member id : ${userID}` ,`By: ${bruhgggg}`)
.addField(`Reason` ,`${reason}`)
.setFooter(`s!help For Commands`)
msg.channel.send(unban);
})
console.log();
};
```
@strange trout i checked thrice it keeps on syaing member not found
@slender thistle thanks
but it's there
i was doing try hard coding and here what i gothttps://gyazo.com/8e3902008981ac822e9d2bacc858605d
@solemn latch is it good man?
nice @cobalt spruce
thanks bro
cache does not have to have a user
@solemn latch ???
wait then what should come there
like
if i do (!user)
then it just looks for arg
but i wanna see if the user is in the server
lol
tbh, ive never worked on a moderation bot, im not sure
why u using then?
.
hey guys i just wondered if anyone here is good with evals ive worked with a bit of evals before but i seem to be getting unexpected identifier on this part of it
client.shard.broadcastEval(`
const guild = this.guilds.cache.get('${result[0].guildid}');
if (guild) {
const adEmbed = createEmbed(guild, ${result[0]}, ${msg});
const adChannel = this.channels.cache.get('71154296197132810');
adChannel.messages.fetch().then((adMessages) => {
adMessages.forEach((adMessage) => {
if (adMessage.author.bot) adMessage.delete();
});
});```
@earnest phoenix i am?
yes u
I've never done moderation. But by the looks of it I'd use the fetchBan() method instead since it returns a user
So you don't have to filter
Look at the docs
lol
Not going to spoon feed
oof
if(command === "unban"){
if(!msg.member.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, You do not have perms to unban someone`)
}
if(!msg.guild.me.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, I do not have perms to unban someone`)
}
let userID = args[0]
msg.guild.fetchBans().then(bans=> {
if(bans.size == 0) return
let bUser = bans.find(b => b.user.id == userID)
if(!bUser) return
msg.guild.members.unban(bUser.user)
})
};```
learn it
this code works
is this
anyone good with evals here?
@earnest phoenix I don't think so
the correct
try
oooh
// Permission logic [x]
const [id, ...reason] = args
// check the ID with regex to see if it's valid
//fetch the ban
await <Guild>.fetchBan(id)
// rest of logic here
No, just a little destructuring
https://gyazo.com/c96b7b8bf0452f435d819adc9fe353c0
TRY HARD BABY
it tells the code acc to your search python and discord.js
lol
@delicate shore bro thats old
its actually really nice for small basic things you sometimes forget
anything more than that its useless
That's why docs exist lol
You can refer to them if you forget something
https://gyazo.com/c96b7b8bf0452f435d819adc9fe353c0
TRY HARD BABY
@solemn latch am try hard rn lol
docs don't spoon feed either
docs mention everything, you just need to understand it
It doesn't give you the exact code
like not understanding also
careful with changing like that.
too fast and its considered api abuse @cobalt spruce
fetchBan
right there
oh
And yes <Manager>.fetch is on there
@solemn latch what is the best time for that
Oh he meant that
i searched and got this
returns a promise with ban info
soo i dont get api blocked
ok
lol
And takes a user resolvable as the param
Yeah all .fetch is await as it grabs from the api
mine changes at a min of 20 minutes inbetween changes, and only changes when my server count changes.
since you want it to change, 2 minutes maybe?
@cobalt spruce the max you can do is 6 times per minute. I change the status every 20 secs
@golden condor ok
It's once every 10 seconds that is the max
anyone know about evals tho
difference between fetch ban and fetch bans?
@earnest phoenix search up the eval() fucntion
broadcast eval just runs code
Did you read the docs
๐ค
@solemn latch i know how to use them.....
just im having trouble with one part
You didn't say that you knew
yes i am readin that
Can you be more specific than "one part"?
i did in till this channel got spammed with pointless questions lol
their questions are just as valid as any
Can you quote the message or smth
๐ค
basically im having issues with this part
client.shard.broadcastEval(`
const guild = this.guilds.cache.get('${result[0].guildid}');
if (guild) {
const adEmbed = createEmbed(guild, ${result[0]}, ${msg});
const adChannel = this.channels.cache.get('712397868576800779');
adChannel.messages.fetch().then((adMessages) => {
adMessages.forEach((adMessage) => {
if (adMessage.author.bot) adMessage.delete();
});
});```
unexpected identifer
guys can anyone take some time out of their busy schedule
@golden condor nope theres a whole other part
yeah
Dude we already told you@delicate shore
and help me in making understand fetch bans
i am not getting it
like i got the code
You don't even need to fetch the ban
but i wanna understand
Read. The. Docs.
fetchbans returns a promise, of a collection
i. am. reading.
fetchban returns a promise of a BanInfo
It shows you what it returns
what is it's usage
20,000 means 20 seconds
20000 means 2 min
@cobalt spruce 20 sec
what is 2 min
@solemn latch 20000 means 2 min
@cobalt spruce Bots usually use MS iirc 1000 ms I second
WHAT IS THE NAME OF THAT TIME THING
60 x 2 x 1000
@earnest phoenix which line is it on
wait
miliseconds
ok
try {
<GuildMemberManager>.unban(user)
} catch (err) {
// handle error
}
If the user isn't banned it'll return an Unknown Ban error which you can handle
client.users
users would be the manager
cache would be the cache of the manager
No it's on the manager itself
Ah
i think ๐ค
Ok
So
message.guild.members.unban()
Yeah that's it
how many days will it take
client.users would be the UserManager
to go through whole docs
of discord.js
you dont need to go through the entire docs @delicate shore
you go to the docs when you dont know something
@earnest phoenix yo
i wanna know everything
which i dunno
i have not read them
i learnt through tuotrials
Well when you need it to learn it read it
Yes
if(!message.memeber.hasPermission("YOUR PERMS HERE")){
return msg.reply("You dont have perms")
}
this is for perms ^^^
and now for say
wait
don't use caps

Are you sure the error is coming from there?
@strange trout so it will be like js try{ msg.guild.members.unban(bUser.user) }catch (err){ msg.reply("Unknown ban") }
@delicate shore try and see
ok
line 90 is the second if statement
bye
I'm not experienced with Lua, but are you trying to compare nil with a number?
@strange trout it's not jining args
what
.join lol
i am doing ^^
I'm not experienced with Lua, but are you trying to compare
nilwith a number?
@sudden geyser i guess i am?
but it's not working @restive pebble
Lemme see your code where you put reason
splice then join
ok
What is the best way to get a guild by ID when sharding?
f(command === "unban"){
if(!msg.member.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, You do not have perms to unban someone`)
}
if(!msg.guild.me.hasPermission("BAN_MEMBERS")) {
return msg.channel.send(`**${msg.author.username}**, I do not have perms to unban someone`)
}
let userID = args[1]
let reason = args[2].join()
if(!userID) return msg.reply("Mention a user lul")
msg.guild.fetchBans().then(bans=> {
if(bans.size == 0) return msg.reply("Bruh noone in this server is banned")
let bUser = bans.find(b => b.user.id == userID)
if(!bUser) return msg.reply("User not banned lol")
// if (!client.users.cache.has(args[1])) return msg.reply("Couldn't find user")
try{
msg.guild.members.unban(bUser.user)
}catch (err){
msg.reply("Unknown ban")
}
let bruhgggg = msg.author
const unban = new Discord.MessageEmbed()
.setDescription("Member Unbanned")
.addField(`Member id : ${userID}` ,`By: ${bruhgggg}`)
.addField(`Reason` ,`${reason}`)
.setFooter(`s!help For Commands`)
msg.channel.send(unban);
})
console.log();
};
```
What is the best way to get a guild by ID when sharding?
@wary flame give the library you are working on
args.slice(2).join(" ")
okkokokokokokokokok]kokok
discord.js @jaunty junco
discord.js @jaunty junco
@wary flame ok, but i cant help you sorry.
I think destructuring looks cleaner
const [id, ...reason] = args
Thanks for your time anyways
Or
const [, id, ...reason] = args
Anyone good with SQL syntax?
Somewhat, what are you trying to do?
say i have this object
let foo = {name: 'test', location:'somewhere'}```
Now i have a postgres jsonb table
its contains an array of objects inside like foo above.
To query filter it i can do ``filter->>'name'`` to find the proper row that its contained, however:
```js
//in the table
[{name:'bob', location:'bar'}, {a:1, b:2}, {n:1, m:4}]```
lets say i want to replace ``{a:1, b:2}`` obj in that table with the ``foo`` mentioned above(order doesnt matter)
the only non destructive way i see to get that would be using operator ``#-`` with the index of that object.
however im not seeing a way in SQL to get index of that object to define it to be deleted without destroying the array and checking individually
or returning the obj to js and then resending it after its been parsed on the code(instead of using SQL query)
any tips?
Im trying to efficiently query the removal of a specific obj in the array of a jsonb table, without querying twice or bringing back the obj to the code
Hmm, from what I know. I don't think you can use an SQL query to do that. You have to query the database, use JavaScript array methods on said array and then update it
That's what I do
thats the problem, doing 2 database calls with the code would take way too much time
the code is time sensitive
just the first query is taking 100 ish ms to complete
adding logic and then doing another call to update it would bring it way higher
if(message.member.hasPermission("SEND_MESSAGES") @earnest phoenix
Why is it taking so long? I do it a lot for some of my commands and it seems to be pretty quick
cuz the tables are enormous
im doing BLOBs on some of them, that requires transactions, it takes more time
Tables do be kinda thicc
Dunno then. I've never worked with super large data sets
version
ping is through websocket
If you look at the Client class in the documentation, you'll notice there's no .ping property. But there is .ws.ping instead.
@strange trout can u just tell me what line am rong in or how i fix it
Also that doesn't represent api latency
poge
Usually a requirement to having a bot here with that command is not making it accessible by everyone
Wouldn't be surprised if there are some
keyword USUALLY
But ^^
laughs in kotlin
its not hard to figure it out either, prefix+ eval
๐คทโโ๏ธ
I wonder how many people have their token accessible through eval
Yikes
ez token grabb
^^ making sure thatโs not possible is the first thing I usually do
Thatโs the environment
You can get your bots token through client.token
i have a function that removes the token from the eval
I just match and replace with regex
my eval command only works in one channel
I just match and replace with regex
@strange trout same
in a discord server only im in, in a room that requires admin to see
Yeah looks clean doing it that way
Nice
there is a special way to send emojis
I forget gimme sec lol
yea
it also needs to be in the guild with the emoji
If it's unicode then \๐
from what i understand
the id
that is emoji number??
of the emoji
๐ค
@solemn latch
try {
msg.channel.send(`:sheep_dance:
Fetchhing song, pls wait. **This might take time depending on current ping and cpu usage.**`)
.then(msg => {
msg.delete({ timeout: 3000 })
})```
it's still not working
i did
oh
it is not showing here
i actully added
the id of emote aswell
but it is not wokring
then edit your code here, to show what you put
is your bot in the server with that emoji
hmm
are you sure you didn't copy the message id instead
yes
very likely as ids are just now at 72 as starting
i copied the image adress
image adress?
and then cropred the
just copy the id
try getting the ID again, it looks like that is a message id
the id is in the url so it's fine
is this how i make/delete a channel
await message.guild.channels.delete()
await message.guild.channel.create()
if not tell me so i dig around more on discord py doc
i copued that id
is this not possible?
scores !== null ? {
let totalScore = 0;
scores.forEach(score => {
totalScore+=score.score;
});
await totalScore;
await channel.sendMessage(`Total score collected this match: ${totalScore}`);
} : null
so what to do ? @crimson vapor
im not sure as I do not use emojis
guys how to check if the one issuing the bot command has perms to ban? (in discordia)
does your bot have the send external emojis permission
only time ive ever used emoji's is by fetching the emoji
does your bot have the send external emojis permission
@pale vessel yes it has admin perms in my server
and the emoji is also in same server
๐ฉ
really?
add an a
that sucks
yeah
What is coffeescript
lemme try afain
are you sure that is the correct id?
it's a coffe
it is
with script
and emote name
yes
did it fix it
lemme see
it should fix it
Jฤvร sฤrรฏรt

ok, why is it multiple lines?
confidence 100
nice man
๐
why not just an if statement
Hello,
I am making a custom mongoose Schema class and I recieve this error:
OverwriteModelError: Cannot overwrite `Guilds` model once compiled.```
This is the class code:
```js
const mongoose = require('mongoose');
class Schema extends mongoose.Schema {
constructor(name, data) {
super(data)
this.model = mongoose.model(name, this)
this.model.get = async (options, callback) => {
this.model.findOne(options, (err, res) => {
return callback(res, err);
});
}
this.model.title = name
this.model.delete = async (options, callback) => {
this.model.findOne(options, (err, res) => {
if (res) {
res.delete()
return callback(true)
}
else return callback(false)
})
}
return this.model
}
}
module.exports = Schema```
I'm not sure why this doesn't work as it was working earlier
hey
i am having issues
with google commadn
any suggestion for fun commands ?
other than the 8ball
loadSchemas() {
const models = fs.readdirSync("./Models/")
for (var model in models) {
delete require.cache[require.resolve("../Models/" + models[0])]
model = require(`../Models/${models[0]}`)
this.db[model.title] = model
this.log(`${model.title} was loaded`)
}
}```This is my code for handling Schemas
aaaaaaaaaaaaaaaaaaa
is there a way i can mention all channels in the guild?
message.guild.channels?
map the collection
on d.js

ok

the doc says there is a text_channel.delete()
but the error is telling me text_channel has no attribute called delete
is your code
text_channel.delete
uh
What does your code look like
yes
or
text_channel.delete()
it was just a first thought.
pretty sure with the () is correct
What's text_channel
await message.guild.text_channels.delete()
well
wait is it text_channels or text_channel
Neither
lol
Let me explain a bit of it
isn't it just channels
or TextChannel
I think its just channels
channels includes voice and category channels
k
it is a list
Yes
but how do i delete the channels in the list
That list consists of TextChannel objects
you either iterate over the list or just a separate element
text_channels.TextChannels
are you trying to nuke a server?
im testing discord py stuff on my test server
ok
text_channels.TextChannels
@elfin flower no
(safe a nuke)
client.on('ready', () => {
client.user.setStatus('online')
client.user.setPresence({
game: {
name: 's!help',
type: "STREAMING",
url: "https://www.twitch.tv/"
}
});
});```
Why my status is not updating in v12
ยฏ_(ใ)_/ยฏ
lel
sorry to break it down to you but if you can't read docs properly, you won't be able to code properly
if you don't understand docs then we can't help either
lol
h
Essentially your text_channels consists of those objects
each element is a TextChannel object that can be deleted if you iterate over them
aka a for loop
name="i-love-children"
test server feat. meme channel memes
ttb moment
i
@pale vessel ```client.on("ready", () => {
client.user.setActivity(Use s!help., {type: "playing"});
});
Not updating status
ยฏ_(ใ)_/ยฏ
what language is taht
isn't it PLAYING
that*
js
discord.js v12
i demand you to read docs
@pale vessel nope
im a discord py man
could u share @pale vessel
lel
v12 is stable now, right
yeah
yes
||sir has entered the chat||
wait
on discord py its
await client.change_presence(activity=discord.Game(name='Playing game'))
to change activity
i putted playing but it is PLAYING
put*
if only you read the docs shivaco sent...

aren't you supposed to loop through the channels? TextChannel doesn't sounds like it's from a loop
discord.TextChannel doesn't
for loop
Show your code
i deleted it
i think he wants the entire command/code
Alright
maybe you should learn python
The docs say discord.TextChannel.delete because delete is a method of an instance of discord.TextChannel (if you could use it on the class itself, it would say classmethod in the docs)
i may not know python, but it seems like a solution for you
I'm so confused, the user is in the server, the bot is in the server but it still returns undefined. (JavaScript)
console.log(client.users.cache.get("314470444713377800"))
I've even tried this but still the same result:
console.log(message.guild.members.cache.get("USERID"))
And the ID's are correct
the fetch method returns a promise, right?
I don't think it'll be ideal for this circumstance, here let me show you
The docs say
discord.TextChannel.deletebecausedeleteis a method of an instance of discord.TextChannel (if you could use it on the class itself, it would sayclassmethodin the docs)
Guild.text_channelswhereGuildis an instance of a guild (you get it from message.guild) returns a list that contains those TextChannel instances. Iterating over that list (with aforloop) you will get access to each element and be able to use it
@earnest phoenix fetch gets from the cache first, if its not in the cache it gets it from discord iirc.
cache doesnt have to have a user in it
its only users that have previously been cached
I'm making a request to my webserver which is hooked up to my SQLite database.
I'm making a leaderboard feature which will display the top 10 users on the server.
It successfully returns the top ten users / and they are also ordered, they come through like this:
[
{ userid: 314470444713377800, wallet: 100, bank: 8900, tokens: 0 },
{ userid: 420366170428801000, wallet: 0, bank: 900, tokens: 0 },
{ userid: 480171429929680900, wallet: 100, bank: 0, tokens: 0 }
]
This is what i'm trying to accomplish...
var embed = new Discord.MessageEmbed()
.setTitle(`Banked Money Leaderboard | Top ${config.economy.leaderboardLimit}`)
.setDescription(`${fetchUsers.body.map(x => `${fetchUsers.body.indexOf(x) + 1} โข ${client.users.cache.get(toString(x.userid)).tag}: ${config.economy.currency} \`${x.bank}\``).join("\n")}`)
.setColor('GREEN')
return message.channel.send(embed).catch(console.error);
Guild.text_channelswhereGuildis an instance of a guild (you get it from message.guild) returns a list that contains those TextChannel instances. Iterating over that list (with aforloop) you will get access to each element and be able to use it
As a small example:
my_list = [object1, object2, object3] # assume all objects have a method .delete()
for object in my_list: # iterating over the list
await object.delete() # accessing the current element in the list and using .delete() on it```
okay
It maps all the responses, and tries to get their full tag
While in the description
make a for loop and loop over the database return
So I don't think that .fetch() will be good
it can work
i do this with a few things where i get mutiple datasets
is your function not async
you can probably make it one
hi, i'm trying to write a 'say' command for my bot, but users can abuse this and get bots to ping roles / users. how do i replace a mention with just the @ + username to avoid pinging a user
you can use the disableMentions option , depending on which library you use
^ the disableMentions option basically does this for you lul
tim, fetch tries to get from cache before fetching from the api right?
yes
aight ty
and if not cached it cached it (can be disabled with a boolean)
o yeah, was in the docs, i just didnt look hard enough.
https://discord.js.org/#/docs/main/stable/class/UserManager?scrollTo=fetch
client.users.fetch(id,false) will disable caching
what objects do i
You simply iterate over guild.text_channels
How do I get if channel is nsfw in python?
check if the Channel object returns a isNSFW true
Yay
if ctx.channel.is_nsfw(): ctx.send("U can't use that command here") else: #code```
๐
low key you havent awaited that send and one liners are ๐คข
lemme fix your code
if ctx.channel.is_nsfw():
await ctx.send("You can't use that command here!")
else:
#code
just invert the is nsfw and return
can anyone help me wit some code
@bot.command()
async def problem(ctx):
"""Create instant invite"""
link = ctx.channel.create_invite(max_age = 300)
guild = guild
await ctx.send(719613758049091584,f"Here's an invite to your server! {link}")#sending
yeah but it's pointless
File "main.py", line 35
await link = ctx.channel.create_inv
ite(max_age = 300)
^
SyntaxError: cannot assign to await exp
ression
๎บง
oh
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'guild' referenced before assignment
i tried to revfrence it
guild doesn't exist
:-0
Use ctx.guild
ctx.guild = guild
guild= ctx.guild
why do you even need the guild
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() takes from 1 to 2 positional arguments but 3 were given
yes
only put a string as only argument to .send
if you want to send a message to the current channel, use ctx.send and don't set any ID
this what i have tso far
@bot.command()
async def problem(ctx):
"""Create instant invite"""
guild = ctx.guild
link = await ctx.channel.create_invite(max_age = 300)
await ctx.send(719613758049091584,f"problem in {link}")#sending
```
if amazon free tier has 750 free hours of EC2 and theres less than 744 hours per month, why do people pay for EC2 still
@slender thistle its sending a message to my server like if someone says poge problem i can join there server
How does one cache all users in a server on a ready event, using JavaScript?
@median star you should probably make them confirm that a person will join their server
Then use bot.get_channel and use .send on the returned channel from there
someone know postgresSQL or SQL syntax rather well?
@bot.command()
async def problem(ctx):
"""Create instant invite"""
guild = ctx.guild
link = await ctx.channel.create_invite(max_age = 300)
chan = bot.get_channel(719613758049091584)
await ctx.chan.send(f"problem in {link}")#sending
that would be cry
@pale vessel I'm still having trouble with the same thing ๐
Could you assist?
You have chan, not ctx.chan
(max_age = 300)
chan = bot.get_channel(719613758049091584)
await chan.send(f"problem in {link}")#sending
Yes
discord.py: how can I get the number of shards/current shard?
Why doesn't it cache them when the bot turns on anyway?
It uses obserd amounts of ram
Okay, what do you suggest then?
Fetching members you need.
Fetch gets from the cache if its cached
If its not. It caches it
I know what it does, but in my circumstance, what would I do?
I swear it's like talking to a brick wall
You're not comprehending my question
Your question is how to get users who may or may not be cached
From what i can tell
Thats not the question you asked here.
You asked how to get all users cached on startup
I asked: Why doesn't it cache them when the bot turns on anyway?
Not: How to get all users cached on startup
Anyway
That doesn't matter
The issue is linked
anyone know why dis not work?
ctx.send('are you sure you want a staff to join and help')
await bot.add_reaction('๐')
if reaction.emoji == '๐':
await ctx.send()
Ngl I still don't see the problem sk1ll.
anyone know why dis not work?
ctx.send('are you sure you want a staff to join and help') await bot.add_reaction('๐') if reaction.emoji == '๐':
@median star what do you even want to do there
iscord.ext.commands.errors.MissingRequiredArgument: reaction is a required argument that is missing.
If you are trying to do it all in the description, just make a function to do it for you.
@bot.command()
async def problem(ctx, reaction):
await ctx.send('are you sure you want a staff to join and help')
await bot.add_reaction('๐')
if reaction.emoji == '๐':
"""Create instant invite"""
guild = ctx.guild
link = await ctx.channel.create_invite(max_age = 300)
chan = bot.get_channel(729403688455635014)
await chan.send(f"problem in {link}")#sending
so they confirm they want a staff to join
@solemn latch ^^^^^^^
but still, do a for() in
I'm not a python dev
;-;
use bot.wait_for to wait for a reaction add
for(c in results) => {//do the adding here}
await ctx.send('are you sure you want a staff to join and help')
await bot.wait_for.add_reaction('๐')
if reaction.emoji == '๐':
"""Create instant invite"""
guild = ctx.guild
?
im just gonna copy this, getting tired of going up and down
I'm making a request to my webserver which is hooked up to my SQLite database.
I'm making a leaderboard feature which will display the top 10 users on the server.
It successfully returns the top ten users / and they are also ordered, they come through like this:
[
{ userid: 314470444713377800, wallet: 100, bank: 8900, tokens: 0 },
{ userid: 420366170428801000, wallet: 0, bank: 900, tokens: 0 },
{ userid: 480171429929680900, wallet: 100, bank: 0, tokens: 0 }
]
This is what i'm trying to accomplish...
var embed = new Discord.MessageEmbed()
.setTitle(`Banked Money Leaderboard | Top ${config.economy.leaderboardLimit}`)
.setDescription(`${fetchUsers.body.map(x => `${fetchUsers.body.indexOf(x) + 1} โข ${client.users.cache.get(toString(x.userid)).tag}: ${config.economy.currency} \`${x.bank}\``).join("\n")}`)
.setColor('GREEN')
return message.channel.send(embed).catch(console.error);
I was thinking that this would just return the users tag.
console.log(message.guild.members.fetch("420366170428801025").then(user => { user.tag }))
So I could pretty much add that into the .map(x => { __here__ }) and get it that way
that result, let it be a let:
then loop a for(in) to with concat
so . anyone know?
await ctx.send('are you sure you want a staff to join and help')
await bot.wait_for.add_reaction('๐')
if reaction.emoji == '๐':
"""Create instant invite"""
guild = ctx.guild
?
that just returns one
oh no
Have you tried reading the docs for once
loop it thru with a concat variable
not in a .map()
does this not work in djs-light?
if (!message.guild.member(client.user.id).hasPermission('MANAGE_CHANNELS')) {
let description = '';
for (r in results) description.concat(r.name // r.tag // r.money)
No because this will do it for each members ID that is in the array object in the code block above
arent you listing top 10?
im assuming you'd wanted all 10 results looped into the description
[
{ userid: 314470444713377800, wallet: 100, bank: 8900, tokens: 0 },
{ userid: 420366170428801000, wallet: 0, bank: 900, tokens: 0 },
{ userid: 480171429929680900, wallet: 100, bank: 0, tokens: 0 }
]
To fetch these current users, I was thinking of something like this:
array.map(x => { message.guild.members.fetch(x.userid).then(u => u.tag) })
Yeah but there's currently only three in there while testing
Because I want the user objects
dont do fetch
And tbh, good point, I forgot about that lmao
you have the users in cache
client.users.cache.get('')
They haven't cached
then how'd get them with your bot?
he cant know if its in cache, since he is getting stuff from a database
That's the whole thing i'm on about ๐
It returns undefined when trying to get the user in the so-called cache
do a manual eval. online users only are cached if i recall
We are all online ๐
The user ID's that are specified above, correspond to online users
the fact that only on this guild i get 60k cache and not the 110k this guild has leads me to believe d.js only caches on message event or fecthes who's online
you could do api calls, but that'd be a bit bad
client.api.fetch('id')
hmmmmmmmm
and, if I was to do this <@userid>, if the userid is not found, it would come back as undefined
or something
you are simply adding their id onto the string
say this
@earnest phoenix
but
if you dont have that user cached on your client
it'll show like this
@limber island
It will show like that if the user isn't in the server and I try to do this <@userid>.
Either way
thats why i asked, you doing a top 10 in the server, no?:
Yea
so everyone should have those users cached, because they are in shared guild(the only one you are trying to get)
if its cross servers you might wanna fetch tag
cuz no shared guilds
but if its in the same one it should be fine
then its fine, everyone will have the users cached
you're doing this basically
'<@' + id + '>'
@stoic spear
I know but if a user leaves the server, it won't change to an actual mention
It will stay as those numbers
Which are bad
indeed
await bot.message.add_reaction('๐')
if reaction.emoji == '๐':
;-; 
you could try to do a call for each error on get
hey, im messing around with discord.py, any idea on how i can delete all channels?




