#development
1 messages · Page 1555 of 1
Kinda, but you can add buttons, images, fields, etc
Yeah, basically a form
Still an insane UX improvement
Slack had that for years
I think, Discord should just tell everyone "we'll slowly copy all Slacks good features"
Lul
i was reading the article like "wow, these guys really seem to like discord!"
It's hilarious that they call it "inovation"
then i realized it was an article made by discord
maybe if discord made it based around any discord bots prefix
so we could easily add commands with easier arguments
O that would be nice
Or making selecting which bot your trying to use easier.
Slowest part of slash commands is when two bots have the same command and you have to get your mouse to select it.
well i have a weird logic error that i don't want to @ts-ignore
hey
this is not a dev question
but
can anyone help me out with this? my friend said for first 100 votes on your bot you get $15 and then $1 for every 1k vote
kinda confused about the whole process thing
marketing budget? like am i supposed to spend some $$?
gotcha
in typescript if I want to say client.x = y, how can I get that typed without extending client?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I mean but ts will always say Property x does not exist on type Client
you're kinda forced to extend
it's overall a better idea than just assigning variables
1 hour left of work 
too fucking bad

i'm your boss take a nap or go home
const { inspect } = require("util");
const Discord = require("discord.js")
module.exports = {
name: 'eval',
description: '**ONLY DEVELOPER**',
run: async (client, message, args) => {
// Number Of Guilds! client.guilds.cache.map(s => s.name)
const evalcommand = args.slice(0).join(" ")
if (message.author.id !== "725945760629129277") return message.channel.send(' Only the Developer of the bot can use this command!')
if (!evalcommand) return message.channel.send("Please specify something to Evaluate")
try {
const evaled = eval(evalcommand)
let evalembed = new Discord.MessageEmbed()
.setColor('#f03824')
.setTitle('Evaluated')
.addField(`Input`, `\`\`\`${evalcommand}\`\`\``)
.addField(`Output`, `\`\`\`js\n${inspect(evaled, { depth: 0 })}\`\`\``)
.addField(`TypeOf`, `\`\`\`${typeof (evaled)}\`\`\``)
message.channel.send(evalembed)
} catch (error) {
let embed1 = new Discord.MessageEmbed()
.setColor('#f03824')
.setTitle('Error')
.addField(`Error`, `${error}`)
message.channel.send(embed1)
}
}
}
How can i make it to send it in many embeds?
paginate or split the value
how?
@tight heath when i run that code it send it like this, i want the emoji name first then the id, how do i do that?
switch .id and .name
ok
discord.js: Does anyone here have experience with the ratelimits when sending messages to multiple webhooks at once?
ok true, then it's more a discord api question itself
But what would happen if I send one message to 400 webhooks at the same time? 🙂
it'd work, probably
Interesting 
probably
webhooks are independent kinda
cause you know, there's a global ratelimit for regular messages (not webhook)
that's why I'm asking
how would they globally rate webhooks reliably
guys
.substr()
Only allow X connections/messages per IP address or something?
The substr() method returns a portion
of the string, starting at the specified index and extending for a given number of
characters afterwards.
eh, you could
I guess i should test it out then, lets see how well discord likes it when the numbers grow
java why am i getting this error
This looks like the offender.
Nah that's fine
Matthew is right
finally I got something right
Hey guys, does anyone can help me
When im trying to play music through lavalink, i have this error
INVALID_HOST: No available node with 1
const { inspect } = require("util");
const Discord = require("discord.js")
module.exports = {
name: 'eval',
description: '**ONLY DEVELOPER**',
run: async (client, message, args) => {
// Number Of Guilds! client.guilds.cache.map(s => s.name)
const evalcommand = args.slice(0).join(" ")
if (message.author.id !== "725945760629129277") return message.channel.send(' Only the Developer of the bot can use this command!')
if (!evalcommand) return message.channel.send("Please specify something to Evaluate")
try {
const evaled = eval(evalcommand)
let evalembed = new Discord.MessageEmbed()
.setColor('#f03824')
.setTitle('Evaluated')
.addField(`Input`, `\`\`\`${evalcommand}\`\`\``)
.addField(`Output`, `\`\`\`js\n${inspect(evaled, { depth: 0 })}\`\`\``)
.addField(`TypeOf`, `\`\`\`${typeof (evaled)}\`\`\``)
message.channel.send(evalembed)
} catch (error) {
let embed1 = new Discord.MessageEmbed()
.setColor('#f03824')
.setTitle('Error')
.addField('Error', `${error.message}`)
message.channel.send(embed1)
}
}
}
@lethal trout try this
const { inspect } = require("util");
const Discord = require("discord.js")
module.exports = {
name: 'eval',
description: '**ONLY DEVELOPER**',
run: async (client, message, args) => {
// Number Of Guilds! client.guilds.cache.map(s => s.name)
const evalcommand = args.slice(0).join(" ")
if (message.author.id !== "725945760629129277") return message.channel.send(':alertsign: Only the Developer of the bot can use this command!')
if (!evalcommand) return message.channel.send("Please specify something to Evaluate")
try {
const evaled = eval(evalcommand)
let evalembed = new Discord.MessageEmbed()
.setColor('#f03824')
.setTitle('Evaluated')
.addField(`Input`, `\`\`\`${evalcommand}\`\`\``)
.addField(`Output`, `\`\`\`js\n${inspect(evaled, { depth: 0 })}\`\`\``)
.addField(`TypeOf`, `\`\`\`${typeof (evaled)}\`\`\``)
message.channel.send(evalembed)
} catch (error) {
let embed1 = new Discord.MessageEmbed()
.setColor('#f03824')
.setTitle(':alertsign:Error:alertsign:')
.addField("Error", error)
message.channel.send(embed1)
}
}
}
what did u change?
Line 33 change addfield
Okay so, I'm trying to make the bot return an action if "botin" value is = null, tried with botin = ; == ; === null/undefined not sure what I'm doing wrong
P.s: Trying to make it join a voice channel.
Here's the code:
const botin = message.guild.me.voice.channel.id;
if(botin === null) {
bot.channels.cache.get(channel).join()
const embed = new Discord.MessageEmbed()
.setTitle('Join')
.setColor('BLUE')
.setDescription('Bot has joined your channel!')
message.channel.send(embed);
}
And basically this is the error:
(node:19896) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null
Ping me if you answer ^^
🥄 🥣
Why?
Doesn't works because it's supposed to be a null value
And the ! still not define anything
spoonfed him, usually we just guide these to go right way, not giving the answer immodialely
!null = null
Ok😒
can it just be
const botin = message.guild.me.voice.channel;
!null is true
The bot can't get id channel if channel is null
The thing is that I need it to be null
yea try this instead
And if it detects that it's a null value, then return
yea that should work bruh
this
const botinC = message.guild.me.voice.channel;
if (botinC) {
let botin = botinC.id
}
And this is for getting channel id
yeah thats the same
I now👍
I think yes
Yes
wait really??
Yes 👍
If database key is Alex
Just type
Alex.save()
No you can't save audio file
For img just you can save the URL or Link
welp
const channel = message.member.voice.channel.id;
const botin = message.guild.me.voice.channel.id;
let isPlaying = bot.player.isPlaying(message.guild.id);
if(isPlaying) {
let embedno = new Discord.MessageEmbed()
.setTitle('Error')
.setColor('RED')
.setDescription('The bot is already playing into another channel!')
message.channel.send(embedno);
} else if(botin === null) {
bot.channels.cache.get(channel).join()
const embedyes = new Discord.MessageEmbed()
.setTitle('Join')
.setColor('BLUE')
.setDescription('Luxury has joined your channel!')
message.channel.send(embedyes);
} else if (botin === channel) {
const embedin = new Discord.MessageEmbed()
.setTitle('Error')
.setColor('RED')
.setDescription('Luxury already joined your channel!')
message.channel.send(embedin);
} else {
bot.channels.cache.get(channel).join()
const embedyes = new Discord.MessageEmbed()
.setTitle('Join')
.setColor('BLUE')
.setDescription('Luxury has joined your channel!')
message.channel.send(embedyes);
}
}
This is the full command code tho, I'm trying to make a "join" command for a music bot. (P.s: Maybe here you can see why I can't simply use const botin = message.guild.me.voice.channel;)
does discord attachment have expired date
u can bro
No, anyways already tried it and still not works
const channel = message.member.voice.channel;
const botin = message.guild.me.voice.channel;
let isPlaying = bot.player.isPlaying(message.guild.id);
if(isPlaying) {
let embedno = new Discord.MessageEmbed()
.setTitle('Error')
.setColor('RED')
.setDescription('The bot is already playing into another channel!')
message.channel.send(embedno);
} else if(botin === null) {
channel.join()
const embedyes = new Discord.MessageEmbed()
.setTitle('Join')
.setColor('BLUE')
.setDescription('Luxury has joined your channel!')
message.channel.send(embedyes);
} else if (botin === channel) {
const embedin = new Discord.MessageEmbed()
.setTitle('Error')
.setColor('RED')
.setDescription('Luxury already joined your channel!')
message.channel.send(embedin);
} else {
channel.join()
const embedyes = new Discord.MessageEmbed()
.setTitle('Join')
.setColor('BLUE')
.setDescription('Luxury has joined your channel!')
message.channel.send(embedyes);
}
}
But that's not the point, is it possible in JS to return if the value is null?
noice
but isn't it spoonfeed again bruh
@dark thorn bro when you get a key for channel you don't need type bot.channels.cache.get(. . .)
Just if key === channel
Type channel.join()
And for channel you can type
const botinC = message.guild.me.voice.channel.id
This but I'd message.guild.me.voice.channelvalue === null
The bot getting error becouse can't get channel id if channel is null
well its an id before
@dark thorn
Becouse for last time the value is channelID not channel.
Gotcha
Wouldn't just the else block be sufficient though
Hello, I was adding some stuff to https://disco-oauth.now.sh/. I just added the ability to have https://discord.com/developers/docs/topics/oauth2#state-and-security this. I was also working on adding some optional middleware for various server modules so users can just have it all set up in 1 go. Does anyone have ideas on what settings can I allow the user to modify besides the following: -
/**
* Path settings for middleware functions.
* @typedef {Object} PathSettings
*
* @property {String} auth The path where the user needs to be redirected to for authentication.
* @property {Array<String>|String} all The paths where all of the user's data will be available.
* @property {Array<String>|String} user The paths where just the user object will be available.
* @property {Array<String>|String} guilds The paths where just the user's guilds will be available.
* @property {Array<String>|String} connections The paths where just the user's connections will be available.
*/
/**
* Helper middleware settings
* @typedef {Object} MiddlewareSettings
*
* @property {String} id The discord application's client ID.
* @property {String} secret The discord application's client secret,
* @property {Array<String>} scopes The OAuth2 scopes that will authorize.
* @property {String} base The base url for all the paths in Path settings.
* @property {PathSettings} paths The path settings for various purposes.
* @property {String} redirect The url where the user will be redirected to after authentication.
*/
while not strictly what you're asking, you should use string instead of String for type defs. Same for boolean vs Boolean and number vs Number
the capital variants reference the Constructor Function of the respective types while the lower case versions reference the primitive types which is intentional
Wait, you're right, why had I not realised that yet
Common mistake. It's fine :)
Hello PapiOphidian
Thanks for the clarification, appreciate it. :-)
Can anyone show me a slash command oauth2 URL format ?
I know it should contain applications.commands or something but how should it look like ?
anyone ?
I made some events but the bot only replies on the last event . There is no error too
REEEEE, having API issues again
...
embed=discord.Embed(
type='rich',
colour=discord.Color(0x4C128E),
description=f'''
...
**Alert(s):** {res3.get('title')}
(Please note that alerts and sunrise/sunset times come in as EST while server time is 1 hour ahead of EST)
'''
)
embed.set_author(name="CURRENT SERVER WEATHER", icon_url='https://cdn.discordapp.com/attachments/781808819705217034/789673205018525706/8fb49e66641f72b64cf9ce1b9568dc65.png')
embed.set_footer(text="Developed by LIPD Producctions Inc.#1205")
embed.timestamp=datetime.datetime.utcnow() + datetime.timedelta(hours=1)
channel = self.bot.get_channel(771353867694506026)
await channel.send(embed=embed)
Produces: (Rest of code does not affect problem area)
Data when I do {res3['alerts'):
[{'regions': ['Western Bergen', ' Northern Middlesex', ' Eastern Passaic', ' Richmond (Staten Is.)', ' Rockland', ' Southern Fairfield', ' Eastern Union', ' Western Passaic', ' Southern Queens', ' Western Union', ' New York (Manhattan)', ' Southern Middlesex', ' Hudson', ' Northern New Haven', ' Northern Queens', ' Western Essex', ' Northern New London', ' Eastern Bergen', ' Southwest Suffolk', ' Northern Westchester', ' Southern Nassau', ' Kings (Brooklyn)', ' Putnam', ' Bronx', ' Eastern Essex', ' Southern Westchester', ' Northwest Suffolk', ' Southern New Haven', ' Northern Nassau', ' Northern Fairfield'], 'ends_utc': '2021-02-02T11:00:00', 'effective_local': '2021-01-30T03:40:00', 'onset_utc': '2021-02-01T05:00:00', 'expires_local': '2021-01-30T15:00:00', 'expires_utc': '2021-01-30T20:00:00', 'ends_local': '2021-02-02T06:00:00', 'uri': 'https://api.weather.gov/alerts/NWS-IDP-PROD-4745120-3838902', 'onset_local': '2021-02-01T00:00:00', 'effective_utc': '2021-01-30T08:40:00', 'severity': 'Warning', 'title': 'Winter Storm Watch issued January 30 at 3:40AM EST until February 2 at 6:00AM EST by NWS New York NY', 'description': '* WHAT...Heavy snow possible. Total snow accumulations of 6 to 9\ninches possible. Winds could gust as high as 45 mph.\n\n* WHERE...Portions of northeast New Jersey, southern Connecticut\nand southeast New York.\n\n* WHEN...From late Sunday night through late Monday night.\n\n* IMPACTS...Travel could be very difficult. The hazardous\nconditions could impact the morning and evening commute.'}]
Language is Python
so why are you getting the title from res3 instead?
What do you mean by that?
you should've done something like res3['alerts'][0]['title'], right?
what you're doing is res3['title'] instead
Have to drop the 0, because I need ALL titles
you can't index a list with string, so for loop. Or just a list comprehension.
Comprehension?
python list comprehension, google it if you dont know what it is
basically its a loop
a 1 line loop
assuming title is nullable and you're using 3.8+, [title for i in res3['alerts'] if (title:=i.get('title'))] will return a list of titles.
And will this put each title instance on a new line?
just join them 
That’s what I’m trying to figure out
@earnest phoenix ```py
res3 = {"alerts": [{"title": "one"}, {"title": "two", "other": 33333}]}
newline = '\n'
a = f'''
...
Alert(s): {' '.join(alert['title'] for alert in res3.get('alerts', []).split(newline))}
(Please note that alerts and sunrise/sunset times come in as EST while server time is 1 hour ahead of EST)
'''
print(a)
As an example?
Can’t use backslash in f-string
Says it’s invalid syntax
res3 = {"alerts": [{"title": "one"}, {"title": "two", "other": 33333}]}
newline = '\n'
a = f'''
...
**Alert(s):** {' 'newline.join(alert['title'] for alert in res3.get('alerts', []))}
(Please note that alerts and sunrise/sunset times come in as EST while server time is 1 hour ahead of EST)
'''
print(a)
I mean ofc it's invalid syntax, ' ' is still there
Oh
Can I do newline newline or just save the trouble and do a double \n in the reference?
I know one of it is invalid, but just try it and see 
Lol, I’m going to get you back for that! 😂
Eh, just one looked good enough for me. Thanks for your help
I will be getting you back though 
👍
In mongoose connection i got operation server.findOne() buffering timed out after 10000ms error spam what can i do
sometimes?
Yes sometimes connection is done succes
I use vps
both on the same machine?
Nope
so one VPS for Bot and one for Database?
Its atlas not local
did you know how to whitelist the IP?
When i use my own ip adress its not working too
add the IP of you VPS
and if you want to connect from your PC with compass add your Pcs IP but with a TTL
ive used Atlas for a while and you can whitelist more than one IPs
I always did with 0.0.0.0
0.0.0.0 binds it to no IP -> everyone who knows your connection string could try to bruteforce into your DB
I understand ty for helping bro
Thank you so much bro <3
There is some excuses for it, such as having a dynamic IP, or using a service where you don't know the IP
Use a VPN then
there is not really a excuse for an Open port, exept you want people having access to it
@earnest phoenix It gave an error
Unhandled exception in internal background task 'weatherembed_loop'.
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/pi/Documents/Room_Sealer/cogs/room-sealer-weather.py", line 99, in weatherembed_loop
**Alert(s):** {newline.join(alert['title'] for alert in res3.get('alerts', []))}
AttributeError: 'list' object has no attribute 'get'
tru printing it then
Is it possible to check if the user has admin perms without members intent
It works fine as a command. It’s the task that’s an issue, and I don’t know why
print it 
And the eval I showed you did work
`@client.command(pass_context=True)
@commands.has_permissions(manage_messages=True)
async def clear(ctx, limit: int):
await ctx.channel.purge(limit=limit)
await ctx.send('Cleared by {}'.format(ctx.author.mention))
await ctx.message.delete()
@on_error
async def clear_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("You are missing the permission to manage message to use that!")`
what should i use instead on @on_error
try-except is reasonable
I don’t see how printing will do anything seeing how nothing got changed from the command and task
telling me ?
@slender thistle
dobol ping
oh
sorry

now i will get mute so bye 
Your reply already mentioned me, no need for another one
Meaning you can handle errors with a simple try-except branch instead of using an on_error
You're the only one who can debug it 
tysm ❤️
you use @clear.error not @on_error
@hasty mulch show what res3 outputs
if you wish to handle MissingPermissions from all commands, then use on_command_error
try and except won't work since the function won't run in the first place ig
In the command itself
unless you're handling the error from purge
Oh for fuck's sake

Ya, fix the decorator
@slender thistle https://pastebin.com/0Vqszker
it's indeed a dict, not a list, so there's no way it raised that error 
'Tis why I slap typing annotations everywhere
They are, but if you use an IDE, it's quite convenient
Well I want to add a Levelsystem to my musicbot, so each second the user is in the same channel as the bot AND the bot is playing counts as XP
I see
Ya, my IDE yells at me for incorrect types and i love it
@slender thistle Exactly, I’m so confused as well
and what is the question?
that's why you print that, it won't harm you 
@earnest phoenix I can’t
CODE
it took me 5 sec to make lol
oops I thought I wrote it
So what is the easiest way to track the XP
in a structured database
compare timestamps when a user joins or leaves the voice channel
And compare it with playtimes?
You might need to store how long a user has been listening once a method which pauses playback/stops is called. You could increment the amount of time by the last time the queue was paused/started if last pause is null or whatever. Then if a user leaves or queue stops, you could write changes
Instead of dealing with an interval or what have you, I feel like that would be more efficient
exactly
dont count how many seconds the person is inside the room, write down then they entered and when they left, and calculate the time spent inside
you can calculate when it's going to happen
remember that you're the one who has the data
no
he said he's not here 😩
who's tim
Lie!
When i trying to play music trough lavalink i have this error
INVALID_HOST: No available node with 1
Lavalink 100% connected to my server, and code is correct
if the code would be correct it would work
there is somewhere an error in your code.
YOU GENIUS

there is no need to get salty about it
Why do I come across such geniuses?
but you try to connect to a lavalink instance with probably the wrong credentials
Node_modules that's my code ?
How to get the attachment from a message?
if you dont want help just say it, i dont really enjoy working with salty people
i don't quite understand how this works
hey guys
Debugger attached.
TypeError: message.author.setNickname is not a function```
message.member.setNickname
that should work
const myArray = [
"slut","good dancer","i am gay","playboy","Schoolshooter","Diamond Hoe","Isaac Newton","gayboy","Official Retard","i am a retard","asshole","Lonely ass boy", "tiktok famous", "racist" , "rapist" , "Sweet home alabama", "child predator" ,"Weak ass boy","Balls o'steel","Mike Coxlong"
];
const randomItem = myArray[Math.floor(Math.random()*myArray.length)]
if(message.author.id !== client.user.id){
message.author.setNickname(randomItem)
}```
I need help, but why did you say about my code wrong, if error incoming from node_modules file
i suppose message.member and message.author are the same.
not quite
returns a collection of attachments, if you map them you get all of them or use first for the first one
owh
message.author == message.member.user
no
setNickname is not a user function
its a member function
owh okay
the user object has nothing to do with the server
it comes from the node_modules bcs your lavalink module is throwing the error
only the member object
var pingperson1 = message.guild.members.cache.random()
pingperson1.setNickname(randomItem)```
this would work too i suppose, but not for the author. It just selects 1 random member which is okay in my case.
@earnest phoenix Bot just needed a fucking restart
LAVALINK_NODES=[{"host": "here is my ip, ye", "port": port is here, "password": "password is here", "region": "eu"}]
did you pass everything as needed as string or as number?
bcs it gets a 1
this is why i guess you added the ip as number not as string
so you use a domain?
Nope
there is not much left lol
const randomItem = myArray[Math.floor(Math.random()*myArray.length)]
if(message.author.id !== client.user.id){
message.author.edit({ nickname: randomItem })
}
```i still get the same error btw
Hosting gives me ip and port actually
TypeError: message.author.edit is not a function
yea but what you supplied is either a domain or hostname
Check
but you make sure everything you supply is in the needed format?
nipe ip
thats not an ip
And after : that's port
thats an hostname
but should still work
but you got somewhere a 1 in your connection stuff that just say 1.
but you still have the same error?
the error is still the same?
i dont do music bots bcs they are a pain in the ass to work with, but give me a sec maybe i find something
You can only edit a member
Kk
and it's { nick } not { nickname }
what lavalink package did you use and what version is your lavalink server?

there are like 2 or 3 different lavalink packages
That's latest stable
Lavacord
when you define your nodes did you give them ids?
?
Nodes id
Hmmmm
Yes, i think yes
const nodes = [
{ id: "1", host: "localhost", port: 2333, password: "youshallnotpass" }
];
``` this is how they want it to be in the github repo
ooof
i think its beause canvas constructor has been updated and i didnt install it
gimmie a sec
https://github.com/lavacord/Lavacord the page also contains more informations that could help you
OHHH CANVAS
Try delete it
And install again
It helped for me
Oh
lol
uH
@silent cloud did what you said and
according to the docs its right tho
o
i was looking at outdated docs
rip
Lol
No, id doesnt helps, all
How to check if the bot has permission to send a message in the channel
let channels = client.guilds.cache.get(message.guild.id).me.permissions.has("EMBED_LINKS").channels
console.log(channels)```
Pls help me
bot remove grant code
Türkmüsün
?
@earnest phoenix
how do i remove
remove code grant
Oke
I closed and I will try
Thnx
does any one here code with dart?
What does Client Secret do?
at Client.<anonymous> (C:\Users\YouTu\go\src\hello-world\hello-world\index.js:22:1)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\websocket.js:825:20)```
I do not know how to define this, Its suppost to be a embed but idk how to make it send.
message.channel maybe?
I feel like an idiot, Thanks.
or like c#-
whats funny .__.
Who the fuck still uses Ruby
It also doesn't have clojure, php, python, c++, dotnet, asp, rust, kotlin, c, d, e, f, g, h, i, j, k or r support. Because it's a NODE modules.
uh oh, how do i set details when compiling c++ using g++
i cant seem to find anthn
this
Didn't think I needed to say it was node only considering it's written in JS and is available on NPM.
lavalnk has support for many lags and its written in java on NPM so
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12608) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12608) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Anyone?
when it gives errors like at index.js:198:23 its telling you where it is
just check to see if its a file you have
like if it says error at /libs/LIB/process handler or something its probs not you
or you coded it le weong
wrong*
Ok, I have nothing wrong in the coding tho?
show code
if (message.content === "=pinging")
var pingEmbed = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle('Pinging Administrative Users')
.setAuthor("Flyer Empire", "https://i.imgur.com/fG9jEUE.jpg","https://i.imgur.com/fG9jEUE.jpg")
.setDescription("If you need help please make a ticket, Do not ping admins, Punishments could be given!")
.setThumbnail("https://i.imgur.com/fG9jEUE.jpg")
.setImage('https://i.imgur.com/fG9jEUE.jpg')
.setTimestamp()
.setFooter('Flyer Empire Ping Message', 'https://i.imgur.com/fG9jEUE.jpg')
message.channel.send(pingEmbed)
});```
Trying to make a basic embed
Ok
^^^
SyntaxError: Lexical declaration cannot appear in a single-statement context
←[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m```
it is discord.js, So javascript
const prefix = '=';
if (message.content.startsWith(prefix + 'pinging') {
let pingEmbed = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle('Pinging Administrative Users')
.setAuthor("Flyer Empire", "https://i.imgur.com/fG9jEUE.jpg","https://i.imgur.com/fG9jEUE.jpg")
.setDescription("If you need help please make a ticket, Do not ping admins, Punishments could be given!")
.setThumbnail("https://i.imgur.com/fG9jEUE.jpg")
.setImage('https://i.imgur.com/fG9jEUE.jpg')
.setTimestamp()
.setFooter('Flyer Empire Ping Message', 'https://i.imgur.com/fG9jEUE.jpg')
message.channel.send(pingEmbed)
}
missing brackets
and you should add startsWith
Ok
instead*
the lavalink on npm is lavalink.js not lavalink. its a javascript wrapper for the lavalink library
no no not that
←[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m``` This came up with your code @young flame
o they removed the old lavalink
npm is a package manager for javascript, it doesnt have stuff for other langs
it may have stuff that is "based" on something else in another lang, but still provides ways to use it in javascript
I'm encountering errors with voice connections currently, my bot will at random throw a 522 error while in a vc causing it to crash, is anyone else having this issue and/or is there a known fix?
It's signifying a timed out connection, which doesn't make a ton of sense considering sometimes it happens when the bot is playing an audio stream without any hitches
if you use vsc i can recommend this extension https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens
will help you finding this stuff you struggle with
Thank you @lusty quest
wut
lavalink-dev-version is the one i was talking about
offer a virgin to the Discord API gods and hope they are good to you Did something wired happens before the timeout?
it got removed
(by wired im assuming you misspelled weird) nope, it just... stops playing. It's happened during a stream and after a stream has ended, and it's all seeming to happen at random
there aren't issues with the read stream im feeding it either, from what i can tell it's purely from my bot's connection to the discord api
its the links?
ye
it's originating from ws, specifically in /ws/lib/websocket.js at line 604
idk then, never really worked with Music bots since they are a pain in the ass. maybe tim got a idea
How do i fix them, Do you got a uploader?
yeah true on that lol, dealing with not only discord but streaming platforms is a bitch lol
k
The only error now is ')' expected
@barren brook is this the code?
Yea
you mean this? https://www.npmjs.com/package/lavalink-dev-version
this one missing )
if (message.content.startsWith(prefix + 'pinging')
it should be
if (message.content.startsWith(prefix + 'pinging'))
isn't it?
is it fixed?
hmmm
ffs
Nope
welp
help
let user = message.guild.members.get(message.content.split(' ')[1]) || message.mentions.members.first();
^
TypeError: message.guild.members.get is not a function
did u define members if u need to?
guild.members.cache.get
djs ver 12 right
@barren brook whats the error??
@sacred aurora You fixed the error but now it wont send.
How do I fix it?
let user = message.guild.member.cache.get(message.content.split(' ')[1]) || message.mentions.members.first();
^
TypeError: Cannot read property 'get' of undefined
members
let user = message.guild.members.cache.get(message.content.split(' ')[1]) || message.mentions.members.first();
you should use mentions rather than that
it should work tho
actually, nvm
message.guild.memebers.cache.get
if your getting it by id
why didnt you just like
message.guild.memebers.cache.get[1] or something
like get it by args
but mesaage.content includes the command itself so if the first arg was an id it would be 1
like if its warn
You should have a variable that holds the arguments instead of repeatedly splitting it
warn reason then mention
oh, true that, i usually split them in my messages so it doesnt get passed by
this
i modify message object itself before sending it out, so that doesnt happen
This guy definitely needs a command handler
100%
efficient memory management was never a strong point of novice JS devs
i also attach extra things onto message to reduce logic
another error wtf
args on this code didnt work
but another code work why
error:
.setDescription(` reason : **${args.join(" ")}**`)
^
ReferenceError: args is not defined
client.on("message", message => {
if (!prefixes[message.guild.id])
prefixes[message.guild.id] = {
prefix: process.env.PREFIX
};
var prefix = prefixes[message.guild.id].prefix;
if (message.content.startsWith(prefix + "warn")) {
if (!message.channel.guild)
return message.channel
.send("THIS COMMAND IS ONLY FOR SERVERS")
.then(m => m.delete(7000));
if (!message.member.hasPermission("MANAGE_MESSAGES"))
return message.channel.send("sorry but u dont have ``MANAGE_MESSAGES`` prems");
let user = message.guild.members.cache.get(message.content.split(' ')[1]) || message.mentions.members.first();
let warn = new Discord.MessageEmbed()
.setFooter(`WARNED By ${message.author.tag}`, `${message.author.avatarURL}`)
.setAuthor('Warn', 'https://cdn3.iconfinder.com/data/icons/musthave/256/Delete.png')
.setThumbnail(user.avatarURL)
.setDescription(` reason : **${args.join(" ")}**`)
.setColor(RANDOM);
user.sendEmbed(warn);
message.delete();
message.channel.send("**Done **")
}
});
fs.writeFile("./prefixes.json", JSON.stringify(prefixes), err => {
if (err) console.error(err);
});
//server
this is code
copy paste?
nope
Using JSON as database
Do you have a message listener for every command?
🗿
i think so 
bruh
@earnest phoenix https://discordjs.guide/command-handling/
if you follow the guide you'll have a good 7/10 bot by the end of it
currently i'd rate it a good 1/10

They don't even check what the command is on the event listener so all commands will be executed at once
-1/10
Wait nvm they do, PepegaBlind
trying to give you a personal evaluation so you have a rough idea of how bad things are as is, and im being honest. You only realise how bad it is once someone experience rates it. My old code is garbage, but i only learned its garbage after i learned more about js
you might not care about my opinion either, which is fine, the code will work but its horribly optimized
Imagine if JS wasn't as friendly as it already is, most of them would just stop programming them until learning how it all works 
So what ur tip for my
if js was replaced with rust cold turkey the world would be a better place 
Learn JS first, then read the official guide and consider making a command handler at least
And don't use JSON as a database
JSONs are prone to corruption
It's prone to corruption
First and most important:
use a command handler https://discordjs.guide/command-handling/
second, stop using vars, they are really annoying to work with since they get hoisted internally. TLDR, dont use vars, EVER. You likely wont have a proper use case for it.
lower your complexity, stop using that many if's, merge them to check what you need before running it.
stop using embed builder, they are horrible, start sending an object direct to the channel.send() method directly instead.
properly check your content before sending it, you dont check if message.content after being split has more than 1 argument.
wrap your user.sendEmebed() under a try catch, you wont always be able to message a user if they have dms disabled
stop using a json database, that is prone to corruption
All that in 20 lines of code, thats why i meant its a 1/10 right now, and thats only on the message event
@opal plank btw this guy loves nsfw
who?
The guy who u just pinged
how is that related to #development ?
No, idea ima head out
ty ❤️
no problemo
Could someone help me? I'm new to discord bot development and im having trouble finding out how to find a certain role in a server to ping it. Ex: I want my bot to find the role mine craft and ping that role. (I code in JS)
filter guild roles and then send it in the channel you want
use guild.roles.cache to get all roles, that is a MAP/COLLECTION
d.js adds a handy filter() method to it, so you can pass a function
now simply pass a function that matches the name, or includes it(depending on what you want)
check if it returned anything, if it did, get the id and send in chat in this format <&ID_OF_THE_ROLE>
speaking of rating, @cinder patio do you mind peering a lib and tell me things you think might be worth adding/improving?
(Find is probably the right function for this but ye)
this
Yeah sure! Just gimme a minute to get on my pc
alrighty
is it possible to output node canvas as an svg?
I'm here
aight, heres a couple points i already know are bad and already being worked on:
refactoring, most methods can be simply refarctored as they are too similar:
wrong usage of class functions, they are inside the constructor
the majority of what im looking for in feedback goes with the logic and optimization
why offline bot?
What happens when you try to run it?
you didnt client.login()
they didnt even add a client.login evie lmao
its there
not where you sent it
Specifically, exactly, precisely, what happens when you type node index.js or whatever, in your command prompt?
not what happens on discord. What happens in the command prompt
wait what
no response
multiple client message events
in terminal
I mean I also just get a syntax error from that code overall so... I Dunno
i formatted it
not erwin yooo
i assume the syntax is fucked up from copy pasting too
maybe you can help me
sup
I would have formatted it had it not had a syntax error
it was just missing 2} and 1 )'s
pog
Ah yes indeed now I see it clearly
ok now works
when im trying to play music through Lavalink i have this error
thenx
clearly ban command was copy/pasted randomly in there
i dont do music bots so i cant help with that
bruh
Error: Cannot find module 'discord.js'??
i noticed too
install discord.js then
ctually
no
yeah, install it
so you copy/pasted from a vid
a video for what?
ok
You think "I copied from a vid" is different than "I copied from github"? lol.
you're making a tutorial on how to do a discord bot when you dont know how to make a discord bot?
shouldnt you learn js before making a tutorial on it?
Ok well here's a hint: copy/pasting shit from the internet doesn't work well in JS any better than it worked in python
yes
You could abstract probably all methods in the client, so for example, instead of having all the methods that deal with characters inside the main class, have a different class that extends Map, and inside it have all the caching logic and everything regarding the characters
i already started that a while back on the refactor
here
actually
there
not sure if thats what you meant with the caching logic though
yea not exactly
that answers the first half you said about abstracting all methods, but im not sure what you meant regarding the cache
this is as much abstraction as i could do with the methods without majorly updating it
class Characters extends Map {
client: ...
constructor(client: ...) {
super();
this.client = client;
}
//.. all methods that deal with characters are here.
}
That's how I would do it
whats the advantages of doing that?
it's cleaner
i dont understand why you extending map to each cache
hmmm i kinda see what you mean, but wouldnt that create unecessary references for the cache?
that'd be setting client on everything
whats disadvantage of command handler?
You don't have to pass client to it, only whether there should be caching or not
yes
currently all cache is being intiated with new Map(); if i go your route that'd mean for each double methods(getCharacter, getCharacters for example) would need to be extended with that
yeah but I don't think that's a problem, it makes it look cleaner and easier to understand
how can i create a bot webhook?
did you find more stuff other than that?
like?
that would mainly fall under readability, im more concerned about performance rn
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.
since i'll be doing a whole refactoring, that'll fall under when i do thgat
I'm not sure what you mean, the character methods would be inside the Character class
then why is it offline?
theres only 2 character methods
it is offline since 3 days
character and characterS
since when i hosted it
at Client.<anonymous> (C:\Users\YouTu\go\src\hello-world\hello-world\index.js:18:12)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\websocket.js:825:20)```
Anyone?
most of the methods are doubled, so theres a method for specific one , and for all of them, which is just the base + S on the end
when you mentiond Character i assume you want me to extend this one or completely make a new class?
class Characters extends Character extends Map {
super()
}```
wait I'm confused where's the code in the screenshot
You reek of Java.
dont look at the refactor, look at the main one i sent, its here
oh I'm looking at the refactor
nono, the refactor is still working in progress
refactor will only change readability, nothing logic-wise
what im concerned about currently is logic
performance and logic
Anyway do you really need to prepend every method with get
yes, some future methods will have post
and it makes sense for methods to start with a verb
get
fetch
do
post
if (data.headers['x-ratelimit-remaining'] !== undefined)
this._quota = data.headers['x-ratelimit-remaining'];
if (data.headers['x-ratelimit-limit'] !== undefined)
this._quotaMax = data.headers['x-ratelimit-limit'];
if (data.headers['x-ratelimit-reset'] !== undefined)
this._reset = data.headers['x-ratelimit-reset'];
you should probably put this in a function if you haven't in the refactor, it's in 14 different places in your code
i did
its in refacto as setHeaders
i looked at canvas2svg but its very outdated and no longer works, any other ways?
in that same post theres 3 other libs you can use down below on the other comments
they are all for html canvas
Othar than the stuff I already mentioned, everything looks fine. I would store all the settings in an interface rather than in the main class itself, other than that everything looks fine
but that's not a big deal and just a personal preference ^
Thank you a lot for the feedback, i'll put a bunch of what you said into the refactor as soon as its finished
this project might turn into a big one so im concerned about stability and performance
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1```
send hulp
there are currently only 1 good genshin API, for any upcoming devs that might use it https://docs.teyvat.dev/getting-started/Welcome
And because of the size of the game, im expecting a lot of genshin bots or stuff regarding genshin, and my wrapper is the main one to use on this api
Getting Started
np! You should definitely refactor it, but if it gets big then people are gonna start contributing to it and making the code better
you just have to make it readable!
i assume it'll grow a bit too much, rn theres nobody advertising it, but its the only API usable for genshin
every other NPM package that claims to be an API or genshin package is just straight up bullshit with a json db
new error
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.
sed
look at my competitors
json db https://github.com/xhayper/genshin-impact-wrapper#readme
json db https://www.npmjs.com/package/genshin-impact-api
json db https://github.com/HerixOfficial/genshin-impact/tree/master/src/info
EY an actual API https://www.npmjs.com/package/@teyvatdev/node-sdk
This is an actual API wrapper, unlike most npm packages that stores json databases containing character data, this fetches and caches it locally from the API real time, so if the values change, you would normally require the author of the package to manually update their database, which forces users to need to update their package. This leads to apps needed to be shutdown for upgrades and updates. Unlike those, we fetch this data dynamically and check periodically for changes in the API itself, so the only updates you'll need to do on this package are major API changes, not related to the data, which is handled internally.
there isnt a SINGLE api on npm other than mine```
Its so polluted with modules that claim to be API's that i had to put this on my front end
Yeah using an api is definitely better than packaging up a json file with all the characters in it lmao
and they are SO bad people are legit await'ing for json read's https://cdn.discordapp.com/attachments/730579769154076702/804381716449591316/unknown.png
k
i dont see why you need to await for this rather than keep it in memory or just straight up sync read, but oh well
that just comes to show how bad they are, and they are call themselves API's
here have a star, even though I've never played the game and will probably never use it
why lol
LOL hayper's
they were trying to flex on their new update on the server
Have you seen marvin's api?
before realising both the owner of the API and me who's the owner of the SDK were in the server

i have not
theres only 1 other api competing with yoroshi's
with with genshin api, which is not even 10% done
Dev resources for Genshin Impact. Coming Soon.
yoroshi was the main dev of that project flaz
Ah
the whole project crumbled, and yoroshi alone alreayd made all this
those either convert an svg to canvas, and the one that doesnt is an old archive
Getting Started
that API is done by 5 devs, yoroshi ALONE made more than those 5 people combined in 1 and a half weeks
YOOO
if you plan on using genshin API, defitively use https://docs.teyvat.dev/getting-started/Welcome instead, its cleaner, better and a lot nicer
Getting Started
It uses GraphQL
yeah
That's fucking pog
shameless plug btw
if you want to use it with ts/js
now code review me
O
gib gib

i'll check it in a bit, i gotta go to the market grab food for today
cool finding, node canvas supports svg out of the box
fr?
?? Probably

o
Pokecord bot
can you not?
this chat for development

then just ```js
res.type('text/html');
res.send(canvas.toBuffer());
Did you need something
https://github.com/GoogleFeud/ms2 It's very different from your repo but
i was gonna recode canva-conductor anyways
i'll take a look at it shortly, let me get to the market rq
ah yes
me want pokecord codes 
@slender thistle
courage the cowardly bot
pokecord was shutdown
I don't know who pokecord is
and the github for the sorcecode is private
pokecord shut down a long time ago
Did you need something
I know
there is poketwo
@cinder patio looks great, well done
Yea
o
We will not spoonfeed code
ohk
@lament rock is this good
And there are very low chances you will find any code that does what Pokecord used to.
idk if negative 1 is good or bad

nt sure if its a valid number to
mmm
no not really
since he had a team to help manage it
speaking or help manage it i should see how miles is doing brb
@crude ember this
-1 is fine. Some applications have jank ways to calculate latency. If a heartbeat to determine server time dif hasn't occured, people would probably default to -1 as a place holder
Or logic to determine latency is flawed

ooo
kk
i thought it went godspeed
negative latency doesn't actually exist
it's just flawed logic
Everything will always take positive time
even the fastest operations
What ~_-
Are DMs sent to users or members?
Users. If you're using Discord.js, GuildMember does implement PartialTextbasedChannel, so you could do GuildMember.send
can I do something like client.users.fetch(id).send()?
fetch returns a Promise. You will need to resolve the Promise<User> with await or a .then
fetch defaults to resolving with a Promise from cache if it's in cache

client.users.cache.get(id).send(msg)
does client.users.fetch() just get the /user/:id endpoint?
if the user is not in the UserManager.cache Collection, then yes
wait
client.api.users.get("id") what it basically is
bro poggg
@cinder patio apart from some inferred types that dont perticularly need to be there, everything looks good
stuff like this, when you return its inferred type, no need for explicitly typing it
its same redundancy as ```ts
let aNumber:number = 1
it's an eslint setting
makes return types required
nicee ❤️ thanks

pog
happy bday
@opal plank Thanks! 🙂
how do i make a circle in node canvas and fill it with an image?
you can arc a circle and crop the context

