#development
1 messages ยท Page 758 of 1
%s is supposed to mean its being formatted as a string, but if its using datetime what comes after the % doesnt matter
Although isn't there many ways to format a string in js as well
like some things are just odd in python
but its not as bad as clojure's VARIBLES actually being constants
async def find_one(client, table, cond, col):
cursor = await client.db.cursor()
if table in table_names:
await cursor.execute(f'''SELECT * FROM {table} WHERE {col}}=?''', (cond))
else:
return
Hmm, I think this finishes the find_one function
dont you need the cursor.findone() or is it diffrent to the SYNC version of sql
also btw you still shouldnt use f strings with sql
cuz it is liable to an attack and just not good practice
you could do it for table name maybe
then*
cuz im not sure exactly how else you would do it tbh
oof
refer to sqlite docs
I don't see how it is liable to attacks
altho you have a stray }
f-stringa, .format tend to fuck up
especially if I am checking the table name
I mean
altho you have a stray }
ah
cool
just one fyi
if it hasnt got anything
in that row under that condition
it will return NONE
I also forgot how to define primary key in sql
isn't it just
PRMARY_KEY
or whatever
think so yh
I have used too many orms
I usually use an orm
Haven't used actual sql in ages
@modest maple do you know how to do an sql injection in a bot

can someone tell me why returnOriginal isnt working as expected in mongodb?
{
"_id" : ObjectId("5e05daea850bf786aa7ddd32"),
"user" : "321242389106786314",
"month" : true,
"score" : 30
}```
oh wait
shell and driver call this other things dont they
thats fucking weird
let finfo = await db.collection("factions").findOne({_id: "info"});
let list = "";
for(var i = 0; i < finfo.count; i++){
db.collection("factions").findOne({_id: i}).then(async fsinfo => {
let fserver = await client.guilds.get(fsinfo.serverID);
let memberCount = await fserver.members.filter(m => !m.user.bot).size
list += `**[${parseInt(i)+1}]:** \`${fsinfo.name}\` (${memberCount} members)\n`;
});
}
let embed = new Discord.RichEmbed()
.setTitle("List of factions.")
.setDescription(list)
.setColor("#ffa500");
message.channel.send(embed);
``` Can someone tell me what I did wrong here? The console didn't output anything and "list" is empty when sent.
can you do += in js?
Yes
findOne
Unless I missunderstood and your factions model has a count property
I guess it does?
Either way, that database query in a loop
Could probably be optimized and converted to just 1 query
couldnt you just do findmany
or just find
Depends on what he's using
But I don't understand the point of the info one
If you're keeping track of the total factions in the info thing
ok i will try findmany
You could simply not do that and use countDocuments instead
Assuming you're using mongodb

The main reason your list was empty is because you're adding to it in the .then(), your code continues without waiting for that to happen.
๐
howtodo a timeout and if someone says the thing i want to it blocks and automaticly turns off the timeout after some seconds
You can save the timeout in a variable and then use clearTimeout(variable) to stop it at any time
On the discord.js docs it says that collection.findAll() is deprecated, but is there any other way to find all things that pass a test?
Or in my case I want to find out how many pass a test
Ah, thank you
how i make an animated icon for my bot on dbl website ?
have fun using scss on your dbl page
scss is compiled down to css
Evaling this code snipet below returns undefined, how would I actually get results from the forEach()?
this.client.shard.broadcastEval(`
const guild = this.guilds.get('614109432145641473');
if (guild) {
const role = guild.roles.get("659351040893648916");
role;
}
else {
false;
}
`).then(results => {
results.forEach(result => {
if (result !== false) {
result
}
});
});
lol wtf
@valid frigate what?
afaik you're not getting results for maybe one of the reasons below
- the role/guild you're trying to get doesn't exist in any shard's cache
- console.log results shouldnt return undefined first
or maybe your comparison is wrong as well
!== is strict
The role does it exists and I'm not logging it
Replacing result with msg.channel.send(result.id) does send the role ID
What
As in that there is no eval output
???/
Like
why are you checking if result is true, first question
if in broadcastEval script, it returns false, it shouldn't return anything
I'm checking if it's not false
yeah but you're doing that with a strict comparison
!== checks if it's literally true
So I don't get this
Sending result.id to my channel does send the role ID so the comparison is fine
idk then lol
I want my forEach to return the role object rather than nothing
have you considered find
as in find one item in the array that is not false
try that, and if it doesnt work there's also filter
How would I use to find to find something that is not false
!play the lion sleep tonight
Ye sure
@twilit rapids you could use filter and check if the results aren't false
let arr = [ false, false, false, true ];
return arr.filter(c => c !== false);
idk if that helps
@twilit rapids for each is async
for of would work better with return
this.client.shard.broadcastEval(`this.guilds.has('614109432145641473') ? this.guilds.get('614109432145641473').roles.get('659351040893648916') : false`)
.then((data) => data.filter(Boolean))
@twilit rapids and as a tip, you can simply like this.
But wouldn't guild be undefined in guild.roles
Okies
you can chain it like that
since you are sure it would not get undefined due to has check
and it will either return undefined or false
and since js has no strict type checking
So that then returns the role object
undefined or false = falsy
if it can find the role ofc
but yeah that 2 liner code does all that work
Looks like it

I mean he already have the code
I just simplified it

although if you dont need the whole object role
and you only need the id
sending the id only would work better, processing and ipc wise
Basically, I want to check if the msg author has a specific role in my server
basically id only?
this.client.shard.broadcastEval(`this.guilds.has('614109432145641473') && this.guilds.get('614109432145641473').roles.has('659351040893648916') ? this.guilds.get('614109432145641473').roles.get('659351040893648916').id : false`)
.then((data) => data.filter(Boolean))
then it can kinda get longer like this but yeah it still will work
But then I would have to also add checking if the user has the role in my server
I dont really cache guilds that arent in same shard
it will just cause confusion and dup cache
since you cant cache the role without guild object unless you cache it via your own
which I really dont see any benefits other than less ipc I guess, but ipc is designed for that thing eitherways
(this.guilds.get(id) || {roles:{get:()=>{return {id:undefined}}}}).roles.get(roleid).id
lmao
lmao thats another way of doing it but I love my ternaries 
sometimes I chain ternaries which is a bad idea
but I do it anyways
chaining ternaries is so annoying
there should be a better way to use ternary chaning
coding privately is where I unleash all the bad practices 
dont we all?
being creative or whatever goes in your brain
thats why we dont code FOSS
its fun
lmao
chain an or statement works as well if you are in to that kind of thing
Where do I set envs in github actions?
So how would I then check if a specific user in my server has that role, because I also have to fetch the user first
This is going to be such a long broadcastEval lmao
easiest way is custom functions then call it on broadcastEval
const weeb = new Client();
weeb.invokeWeebness = (id) => {
const guild = weeb.guilds.get('some id');
if (!guild) return false;
const role = guild.roles.get('some id');
if (!role) return false;
return guild.members.has(id) && guild.members.get(id).roles.has(role.id);
}
//
client.shard.broadcastEval(`this.invokeWeebness('${lewd id}')`)
.then(_ => _.filter(Boolean))
tip #1: you dont need the whole code to be on broadcastEval
padoru season makes me a good person
What would lewd id then be? The user's ID?
weebs
@opaque eagle you set env variables in the secrets tab in settings
i.e ```yaml
env:
token: ${{ secrets.SSH_USER }}
oh
Error: 'Command' object has no attribute 'time'
Code causing the error: ```py
@bot.command()
async def uptime(self, *ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
embed = discord.Embed(colour=ctx.message.author.top_role.colour)
embed.add_field(name="Uptime", value=text)
embed.set_footer(text="Uptime!")
try:
await ctx.send(embed=embed)
except discord.HTTPException:
await ctx.send("Current uptime: " + text)
Language: Python
Possible Fixes: Unsure
Help needed: A lot
When: ASAP
tfw you fill out a form
yeah i made it myself
doesnt look like asap
current_time = time.time() that is not datetime
lol

EXACTLY
WHAT
you have to use datetime, but you are using time
The lib is the same thing smh
just help me lol
I AM
we already told you what you have to do
search up how to use datetime and python modules
you have to use datetime, not time
yeah i get that. just tell me what to do
not like that :/
thats literally it
like the code to put in ohmylord
time.time goes to
use datetime instead
datetime.time?
really?
How to add a number like this:
1 + 6 = 7
When i try it in my script: js String + String
Then is the output: //String1 = 1 String2 = 2 12 i dont want that
you do know
Math.floor(String + String)
Maybe?
youre adding two string
y i saw that
math.floor ?
couldnt you just use the Number function
i dont know that function
you need to change it to an int, search up parseInt
^^
its legit what turns a string into an int if it can
Error: TypeError: descriptor 'time' of 'datetime.datetime' object needs an argument
Code causing the error: ```py
start_time = datetime.time()
Language: Python
Possible Fixes: Unsure
Help needed: A lot
When: ASAP
ew w3schools
well youre the one who cant be asked to look at proper docs so im linking you to the basic learners edition :P
SBot check out the link and see how you can incorporate it
i have a diff error now lul
https://docs.python.org/3/library/datetime.html
https://docs.python.org/3/library/datetime.html
https://docs.python.org/3/library/datetime.html
Read that then and stop complaining and asking for help then saying no

Error: TypeError: descriptor 'time' of 'datetime.datetime' object needs an argument
Code causing the error: ```py
start_time = datetime.time()
Language: Python
Possible Fixes: Unsure
Help needed: A lot
When: ASAP
https://docs.python.org/3/library/datetime.html
https://docs.python.org/3/library/datetime.html
https://docs.python.org/3/library/datetime.html
Read that then and stop complaining and asking for help then saying no
spam
ikr
ur kinda unhelpful
READ MY CODE

if you read the docs
you would know this
and know the much much much easier solution
but as youre refusing to read them
F*CK IT ILL JUST STACKOVERFLOW LMAO
leave me alone
๐
:(
it's like 3 seconds but okay
can you stahp
dude i just read the docs and i have no idea how to fix it lmao
for?
the datetime documentation that was sent above
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'
Never had this error before.
are you sure your getting the address correctly
it seems your trying to get a member
by the argument
You use address before the "const address"
I don't use JS so, im just guessing here
Let me see.
if "address" is used before its const/let/var address = smh, it wont simply work. Does that even make sense???
and if its inside if(cond) var smh = 0; console.log(smh) wont work
instead you can do let smh; if (cond) smh = 0; console.log(smh) will work
- thats basic js, so please, try find google for simple questions and even harder, before ask here.
But thats still basic js
- you cant ping 127.0.0.1 cause its localhost
try hypixel.net
or smh
(node:13072) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:443 what the error says???
or wait
its because you did ping 127.0.0.1/localhost/0.0.0.0/198.168.xxx.xx OR your ip is blacklisted on the api.
What you input?
!status mc.gamster.org?
i found the error
you typed http:/ instead of http://
now working?
404 = The server/page doesnt exist.
the site exist but the page in the site doesnt exist.
http(s):// is real. http(s):/ wont work
basic internet stuff
what youre req'ing
๐คฆโโ๏ธ
requesting thats what i meant..
the url you requesting
i dont mean like https://api.mcserverping.us/ping that, i mean the url with the server ip
or this what was in ur code https://api.mcsrvstat.us/ping/mc.gamster.org
๐ use your browser before asking us help for requests ๐
then it should work.
Try axios or node-fetch then (cause snekfetch is anyway depreacatedadatata)
I checked the url in the browser
it works for me
feels like you're parsing the data wrong, do what @restive furnace said
probs copy pasta, cause this line wont make even sense: let entry = bodt.find(post => post.id === id)
thats not even needed
So many possible issues there
why do you slice args.join(" ") with 22
That means the first 22 characters of that string are gone
So unless your prefix and command itself add up to something above that limit
address would always contain nothing
copy pasting in code is generally a red flag
It means you could have probably coded a function or something
and re-used that
Doing so will prevent a lot of issues such as you wanting to update something that's used in multiple places and forgetting to update it in some places
If it's one method, you only have to change that one method
etc
Dont say that 24/7 its just basic js not api...
Go through your code line by line and try to understand what's happening
this guy deleted all of his messages
Deleted messages are also logged here... lol
t = await find_one(client, table, col, cond)
await cursor.execute(f'''UPDATE }''')
How would I get the table from t and use it in the next sql query
Is there a way to disable CORS in ExpressJS
I want to send Admin cmds used on my Roblox game here to discord, how can I do it?
Yeah
if so, webhooks
Introduction Iโve been scripting for a long time, and as a result, Iโve come up with various different ways to do things as opposed to more traditional methods. One of these methods Iโve come up with is using Discord Webhooks to track and/or notify me of whats happening...
look into webhooks
It's hard for the scripts (For me) but it can be done, right?
Yes
Anyone know an API for PUBG Mobile?
wow i thought roblox dev used some gui like scratch lmao
Roblox is pure lua for the most part
They remove some things that are unneeded but for the most part everything is there
oh ok
Ye
I'm wondering why this is happening?
I'm making a starboard bot for a friend's server (library: Eris) and when I destruct the emoji, it destructs and then returns undefined/null?
const key = emoji.id ? `${emoji.name}:${emoji.id}` : emoji.name;
const emote = msg.reactions[key];
console.log(key, emoji);
โญ { name: 'โญ', id: null }
[14:50:37 PM] [ERROR/14367] -> Cannot destructure property `emoji` of 'undefined' or 'null'
They basically made their own lua lib called Roblox Lua
Youโre not destructing anything btw
Youโre just using a template literal xd
^

That error originates further up ur code
Yea
hmm
I wish python had a version of sequelize xd
like an ORM?
I hate doing sql queries
I know python has orms
But I wish there was a sequelize one for py
Yes but isnโt sequelize made for js
What Iโm saying is I wish there was an orm like sequelize xd
oh
I love sequelize
meh
Itโs easy to use
yeah
But a pain in the ass at times
Does anyone know of a good platform to write docs for a REST API
How would I make a composite key in sql
so that way it takes two fields to look something up
How do you make a website display an embed when posted in html?
an embed in discord?
Heโs asking how you display an embed on his website
Iโm assuming he means a discord embed
already found out
ok
stole html code from my xenforo forum 
let fcount = db.collection("factions").countDocuments();
let factions = db.collection("factions").find();
let list = "";
for(var i = 0; i < fcount; i++){
let fserver = client.guilds.get(factions[i].serverID);
let memberCount = fserver.members.filter(m => !m.user.bot).size
list += `**[${parseInt(i)+1}]:** \`${factions[i].name}\` (${memberCount} members)\n`;
}
let embed = new Discord.RichEmbed()
.setTitle("List of factions.")
.setDescription(list)
.setColor("#ffa500");
message.channel.send(embed);
``` Can someone tell me why list is empty? The console didnโt upload anything.
did you check if the for loop actually enters
learn to debug your code
go through it step by step until you find the line that's causing the issue
Lol
In sequelize how could I define an array of jsons with values
items: Sequelize.ARRAY(Sequelize.JSON({
id: Sequelize.SMALLINT,
name: Sequelize.STRING,
level: {
type: Sequelize.SMALLINT,
defaultValue: 0,
allowNull: false
}
})),
My idea was something like this
but idk
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
``` Help me
Yeah, but I can't figure it out.
So what are you trying to get?
Animated emoji
Show the line of code lol
.addField(`${client.emojis.get("660134474247307284")}`)
const client = new Discord.Client();
exports.run = async (bot, message, client, args) => {
}
``` there is
Are you creating a new client every time you use a command
Bot info command
It looks like they might be.
I did not understand

How are you defining bot
...
Yea
Hey, for a music bot, it looks like the song is playing, but I hear no audio. I can see the green circle, but still no audio, could this be an issue with one of the modules like node-opus?
I'm not really looking for help with code, just wondering if anyone has had this issue and knows what causes it.
nvm I figured it out
How do I setup the list bot?
What
what
Do I like set it up or is it automatically set when I invite it?
What do you mean
Help me!
TypeError: Target is not an array.
db.push I get this error while using
Help me!
let invite = await client.guilds.get(teaminfo.serverID).channels.first().createInvite({maxAge: 0});
``` The error is "Unknown Channel". Can someone tell me what did I do wrong here?
@earnest phoenix what is db?
quick.db 7.0.0-b22
sorry I dont have experience with quick.db
thnaks
right............
@earnest phoenix Firstly that error is saying what ever youre pushing isnt an array OR youre trying to treat it like its an array when it isnt
@earnest phoenix i dont think you need to specify a channel to create an invite?
the createInvite function is from a textchannel
Also
how can I get a random channel? I tried getting the first channel but it says unknown channel
Is this for a server you can publicly access
Then you might as well stop
Youโre breaking the tos
You canโt make an invite for a server you havenโt been invited to or isnโt publicly available to join
Itโs breaking the users privacy

i mean it isn't public yet but it can be used by me
yes
Mk
My guess is
your client.guilds.get isnโt returning anything
So it doesnโt have any channels
Make sure youโre getting a guild object
does console.log ing it solves it?
Console logging helps debug it
What does it return
guild {...}
Is it empty
no
let invite = await client.guilds.get(teaminfo.serverID).channels.first().createInvite({maxAge: 0});
Okay
var user=client.users.get(userid);
some ids says undefined.
Is this an error or have users been deleted?
use client.fetchUser()
ok thx
i dont see a problem with var
at least it works
Thatโs...no
i just know let is updated var
Lmao
This dude
Just because it works doesnโt mean you should use it
Just because it works doesnโt mean you should use it
ik
Var has scoping issues
On top of many other issues
i only use var after if statements because let doesn't work
Lmao
๐ค
I can always come to discord bot help channels for a little humor
Why not just assign the variable as nothing then give it a value inside the if statement
let something;
if(!something){
something = new value
}
something;
Bad example
But ya get what I mean hopefully
ok any idea on my invite provlem?
ok
I used now client.fetchUser() but again undefined says code
check if the user exists and the id is correct
User has used my bot 3 months ago.
Also make sure youโre using a UserID and not a MessageID, or GuildID
I'm sure of that.
I do not understand whether the user deleted it.
A few ids give this problem. (5 of them in 1000 ids.)total 1000 ids
wait you are fetching 1000 users?
WHY!?
My bot is a collection bot.
That's why I'm trying to find the inactive.
what
Iโm debating whether I wanna save the last bit of sanity I have tonight and not open up Pycharm or say fuck it
pycharm is <3
Itโs 5am I havenโt slept since 6am yesterday which is when I woke up
look at dat sexyness
I just
Donโt wanna make a bot alone
I hate coding alone
I like collaborating
It makes it more fun
I am coding a bot in discord.js
& im trying to find a way to do a word filter for example ...
MY MESSAGE: Hey can you join my server <Server Link>
BOT: Hey can you join my server
So the bot replaces the links https || http with a space
replace method?
Yes
.replace("https", "") like this
"Hello World".replace('Hello', 'IAmTooTiredFuckMyLife')
ooh ...
Yea
Thanks alot
Np
It worked but not completely
Dosnt it like remove the whole link
And also it didnt remove both ..
var desc = args.slice(1).join(" ");
if (message.content.includes('https'||'http')) desc = desc.replace("https", "")```
this is how i did it
Doinng replace like that will only remove the first instance
I recommend googling: js remove links from string
You should find a regex code that will help you with that
Use regex
I was typing that Eri
runs away
xD
if (message.content.includes('https'||'http')) desc = desc.replace(/(https?|ftp):\/\//, "")
Would this do the trick
That would only replace https:// and ftp:// and http://
nvm I will test it
oor oks
will it replace all links
or just the first link found
will it do that in all the links found or just one
Just one
ooh thanks
how I can revoke all invites of a server using d.js?
instead of message.author.roles you should use message.member.roles
what do you want to do
^
even though you need to get the role then the name
:0
if you would like to make a list of the roles, you should use this:
message.member.roles.map(r => `${r.name}`).join('\n')
np
Well you shouldn't use template literals like that
Just using (r => r.name) would be fine
ah, true
how to connect discord.py to reddit using PRAW?
I'm sure Google can help. Or you can look at the PRAW Docs.
@client.command()
async def shibapic(ctx):
shiba_submissions = reddit.subreddit('shiba')
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in shiba_submissions if not x.stickied)
await ctx.say(submission.url)
For some reason it says:
Instance of 'Reddit' has no 'subreddit' member
well ig it has no .subreddit
wdym
I wouldnt use PRAW for a bot, due to it blocking quite a bit
what do I use for reddit then?
You can just do a GET request to reddit.com/r/shiba/hot.json
to keep it async
with aiohttp
oh ok ima try it
Dont need to do any fancy executor stuff when you have aiohttp
ok
Hello
hello
let discord = require("discord.js");
let client = new discord.Client();
const broadcast = client.createVoiceBroadcast();
client.on("ready", () => {
console.log(95742980);
var voiceChannel = client.channels.get("551078363478097931");
voiceChannel.join()
.then(connection => {
const stream = "https://radio.wearebounce.net/radio/8000/radio.mp3"
broadcast.playStream(stream);
const dispatcher = connection.playBroadcast(broadcast);
})
.catch(console.error);
});
why wont this play the stream?
do you get an error? ๐
ps: i've never done a music bot
no i dont

imagine Creating a new Client for Each command
^
@earnest phoenix i do have it login, just did not show that part
@obtuse thistle It does join the voice channel, but does nothing afterwards
have you tried putting breakpoints around the dispatcher and/or stream to see what happens in them?
@snow urchin an url is not a readableStream
you need to connect to the url with an http library and open a readableStream from it
import asyncio
async def handle_echo(reader, writer):
data = await reader.read(100)
message = data.decode()
addr = writer.get_extra_info('peername')
print(f"Received {message!r} from {addr!r}")
print(f"Send: {message!r}")
writer.write(data)
await writer.drain()
print("Close the connection")
writer.close()
async def main():
server = await asyncio.start_server(
handle_echo, '127.0.0.1', 8888)
addr = server.sockets[0].getsockname()
print(f'Serving on {addr}')
async with server:
await server.serve_forever()
asyncio.run(main())```
am i right in thinking i should be able to run these scripts on separate programs and have them still communicate via tcp
@quartz kindle It worked before the way I am doing it now with the url
Do I ask people for help on my server?
@earnest phoenix #502193464054644737
Ok thx
just post your question
didnt save changed
The system cannot find the file Logger.py.
Press any key to continue . . .
@echo off
cd "D:\Innkeeper\Status%Ping\"
start Logger.py
pause```
now
why df is it working when i run the bat normally
but not when i call it via python
what
yh
ยฏ_(ใ)_/ยฏ
o h
then idk
Is there a way to check if the link is a message or not - discord.js
FOR EXAMPLE: https://blabla.com - this is not a image
https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg this is
Do you mean whether or not the link embeds?
message.embeds I think is a property that exists
so simple message.embeds
that code won't work if the user doesn't have embed permissions
or if they put the url in <>
or if they suppress the embed
silly question but it is not possible for two guilds to have channels with the same id right?
thank you
Hey guys can someone help me please, I'm using
message.reactions.get(reaction).users
but the bot is only getting his own reactions
Vote system, adding and leave message from server bot etc
when your bot is sharded, its instances can't see each other
Sharding basically works by having a second instance of your bot running, altho it shouldnt be needed for your bot untill you get neer 2,000 guilds
for example guilds on one shard are not visible on another unless you eval them
so you have to treat it as seperate programs almost
@icy osprey use fetchUsers on the reaction
iirc users is just cached users
fetchUsers is guaranteed to return all of the users who reacted
on the reaction
singular reaction
reactions is a collection of all of the reactions
yup
It's afunction right ?
So I need to await ?
yeah
or if your method isn't async use .then
Who can help me plz ?
to ?
How are we supposed to help you with that
No idea how you try/want to handle the votes
I have a vote system with webhooks
But with shardin, he does not work
So i want vote system with sharding work
Ok
That's still not very helpful
But if it was working before
And doesn't work now
It's probably because when someone votes you do something
that doesn't work properly when sharded
We can't help you with that if you don't show us code or at least tell us what you're doing
I know sharding
probably because the lib you're using works only with a non sharded client
it's not that hard to setup webhook handling without a lib doing it for you
make a webserver, listen on port for whatever path, do whatever with the data DBL sends you
Ok i have another example
I have a another system
Who work when my bot is not sharding
And not work when he is shard
let adding = bot.channels.get("493061310968496128")
try {
let embed = new Discord.RichEmbed()
.setThumbnail(bot.user.displayAvatarURL)
.setColor("2ca823")
.addField(`Discord supplรฉmentaire`, `Nom : **${guild.name}** \nID : **${guild.id}** \nCrรฉateur : **${guild.owner.user.tag}** \nMembres : **${guild.users.size}**`)
adding.send(embed)
} catch (e) {
console.log(e)
}
})```
When my bot is added to guild
He send message to channel in my discord
But this code work just in one shard
If aiT4S RANDOM IF THE CODE IS NOT LAUNCH IN THE GOOD SHARD THE CHANNEL IS NOT FIND
Is located on 1 shard
@earnest phoenix Thank you so f*** much you fixed few bugs in my bot thanks to your tip
You'd have to get it to run from the other shard
Whatever library you use for sharding might have certain tools to help with that
JS
You could also, use discord webhooks
??
Which seem like they would fit the use case above a lot better
And would also ignore the issue of sharding completely
So my system has to be redone to work with sharding
You can add a webhook to a discord channel > you send a request to the webhook > the webhook posts a message in that channel
I have several system who don't work with sharding, fuck sharding ๐
Mmmmh
Interessing
but yeah
How i can make that ?
You can just google discord webhooks
It's pretty simple
And if you're using discord.js I believe they even have tools to send to webhooks easier
Anyway, for certain other features you may still need your shards to be able to communicate with eachother in some way
There's many ways to do so
I use node-ipc for mine
I have several system down you can explain with what i cna patch this : system of log when user write command, system vote, dm log when user send private message to my bot
All your logs to discord channels will probably be the same issue
Being that the channel doesn't exist over there
you generally shouldn't log to discord anyways
log to a .log file and make a command which uploads the .log file whenever you need it
But i want log when user make command
^^
But i want in channel it's easier for my staff ^^
I just log certain key stuff so staff members can see if something's going on
As they don't have access to my server
then allow staff to execute the command aswell
logging to discord is bad and unreliable
and soon enough it'll get so spammy that you'll start to get ratelimited
I'll think about it in the meantime I'll do that
So, @late hill for example i want make my system of when user add my bot the bot send message to a channel of my discord
I do what
Excuse me for question ^^'
I log shards disconnecting and stuff
But I want to understand so I can start
using a webhook
^^
Not that spammy
If you want to use the webhook method
You add a webhook the channel first
Then you can send stuff to it
With simple requests
Mmmmh ok i do create webhooks in the channel of my server and i do put my code where ?
In one shard ?
It's boring that we can't connect all the shards
why am I getting error, role aint a role or a snowflake
its in guildMemberAdd event
nvm solved just seen as i posted rip
You'd just put the code in the guildCreate event?
AHHH
No i have understand
My bad ^^ Ok yeah
I go learn discord webhooks, if i have any problem i can send private message to you ?
guys
does anyone use postman
for JSON?
for json what
var webhook = message.channel.createWebhook(message.author.username, message.author.displayAvatarURL)
var mentionHook = new Discord.WebhookClient( webhook.token , webhook.id );
hi, i'm trying to make a command that creates a webhook with username and pfp of the author -> send a message, for some reason the code above returns a 405: method not allowed, what should i do?
also i'm not sure that webhook.token and webhook.id even works
(the webhook gets created successfully)
createWebhook returns a promise
Await it before using it's properties perhaps?
Not sure if that will fix your problem, just a thought
so i should do something like this?
var mentionHook = async new Discord.WebhookClient( webhook.token , webhook.id );```
oh ok
Like var x = await y()
ok, i'll try that
The function itself must be async
alright i'm retarded
yep, i can't afford/host a vps
message.delete();
// Setting The Webhook
async function webhsetup(){
var webhook = await message.channel.createWebhook(message.author.username, message.author.displayAvatarURL)
var mentionHook = new Discord.WebhookClient( webhook.token , webhook.id );
var args = args.join(" ")
if(args.toLowerCase().includes("@everyone") || args.toLowerCase().includes("@here")){
message.channel.send("Nope.")
return;
}
var scream = randomCase(String(args));
mentionHook.send(scream)
}
webhsetup();```
i'm probably doing something wrong
yep, didn't copy that
any errors?
no errors, but nothing gets sent
the function doesn't seem to work
the message gets deleted, but nothing else
also this UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'join' of undefined
Technically overwriting it and setting it to args.join() should be fine
But it might be messing up because you're using var
Which makes it accesable in a lot more places
Mean that could get fucked with
should i use const?
Well
Just stop using var without needing var
But also, just use a different variable name for the joined arguments

You're basically redeclaring args
While using args for it
Which is probably an issue
okie i'll change the name of the modified args
still method not allowed
the webhook.id and webhook.token return undefined
You didn't mention method not allowed before
Your bot won't always be allowed to create webhooks
You'll have to handle that
Your bot won't always be allowed to create webhooks
You'll have to handle that
how?
wait, nvm
Check if you have permissions or not
i mean, the webhook gets created
but it's probably the
var mentionHook = new Discord.WebhookClient( webhook.token , webhook.id );
Why would that not be allowed
did you await the webhook variable
Hey guys
var servers = client.guilds.size;```
Is this the right way to count users and servers ?
coz it doesn't gives me the right user amount
That is all the users cached at the moment.
You'd have to iterate over all the guilds and get the user count from each one.
Yes
thanks
note that that will count duplicates



