#development
1 messages · Page 1881 of 1
const Discord = require('discord.js');
module.exports = (oldState, newState) => {
if (!oldState.channelID) {
console.log(`yes`)
smeh = setInterval(function () { db.add(`coins_${newState.id}`, 30) }, 30000);
}
if (!newState.channelID) {
console.log(`no`)
clearInterval(smeh);
}
};
when I join a channel, the bot says yes and no
discord.js v12 btw
is there any way to make optional parameters without overloading something a billion times in java
if i allow other users to make bots and register it with my interactions url will that be a security risk to my interactions url?
If it's a guild-only interaction I guess not
it wouldnt be a guild-only interaction. The user would create their own bot and bot token. I'd setup my interactions url to work with their application_id and bot token. This means they could register more slash commands, but they would all fail
someone?
So I have a bot that stores parameters from a command being ran (Ex: -tag create [name] [message]) It stores everything provided after the create inside of my database with the [name] being the data name and the [message] being the data value. In order to comply with Discords requirements for message content I have to delete the message content after 30 days of storage, how can I do this if I want the data to be stored forever until it is either removed by the user or another server moderator, or by me.
which event are you listening to?
voiceStateUpdate
and when I console log oldState, its undefined
and I activated intents
this is the type of object that both oldState and newState is
there is no channelID property
yes but oldState is undefined :/
if oldState was undefined then your code would throw an error, but it logs both yes and no
dear god is swing just so old that it runs my computer to a halt whenever I move the window? it becomes so incredibly laggy
literally turns my monitor black at the end lmfao
no, swing is great. applets are going to replace javascript in the browser any day now
yep
but idk where was the error
there wasn't an error. the code just isn't doing what you expect. if oldState was undefined then oldState.channelID would throw an error. what is undefined is oldState.channelID
oldState doesnt have a channelID property
I'm gonna disagree with you on the swing one
how dare you
Either that or I've done something terribly wrong
const Discord = require('discord.js');
const db = require('quick.db')
module.exports = (oldState, newState) => {
console.log(oldState)
console.log(newState)
/*if (newState.channelID === null) console.log('user left channel', oldState.channelID);
else if (oldState.channelID === null) console.log('user joined channel', newState.channelID);
if (!oldState.channelID) {
console.log(`yes`)
smeh = setInterval(function () { db.add(`coins_${newState.id}`, 30) }, 30000);
}
if (!newState.channelID) {
console.log(`no`)
clearInterval(smeh);
}*/
};
and both are undefined
Anyone got a idea to recursively add more buttons and parts to a embed based on a collection?
with an handler but I found, thx x)
And say you'd have like 3 parts to a embed and there are only 2 fields in the collection that it would make 2 parts of the embed and ignore the last one?
.map() the fields to the embeds
How would I do so?
const embeds = fields.map(field => ({title:field.title,description:field.description}))```
yo lads
anyone of you host your bot on aws lightsail?
i dont know shit about linux
how do i transfer my bot which i coded is vscode in wwindows to the server
i have set up filezilla and stuff
If I do !check #channel, how would I check that #channel is a mentioned channel like #development (discord.js)
message.mentions.channels
forget filezilla
use git, you don't need to transfer pc --> server
but how
create a private repo and use it to sync changes between the two ends
Still can't figure out this lag issue
bitbucket lets you make private repos
github too
KuuHaKu have you had any issues with the performance of Java's Swing framework? I know it's old asf, but after about 10 seconds it'll straight up turn my screen blank for a few seconds
are they free on github yet?
since 2 years ago
or around that
github no longer has paid features (except actions budget)
nice
it's not old kekw
released 1998
maintained until now
Still though
like, they update it regularly
javascript is going to be replaced by java applets any day now
javascript came exactly to allow browser <--> java integration
I've looked through my code and it doesn't look like there's anything suspicious that could cause something like that
y aren't u using intellij gui builder?
That's a thing?
...
remember android studion is intellij for android-only
intellij has gui builders for both desktop and android
I'll try that out, but for right now I want to get this issue fixed
but well, that doesn't look like a swing issue

what version are u using?
Of Java?
ye
16
It's probably ugly, but ```java
public class SwingUI {
private final JFrame frame;
private final JButton sendButton, nameButton;
private final JTextField messageArea;
private final Webhook webhook;
public SwingUI(Webhook webhook) {
this.webhook = webhook;
messageArea = new JTextField();
frame = new JFrame();
sendButton = new JButton("Send Message");
nameButton = new JButton("Change Name");
init();
}
public void init() {
ButtonListener bl = new ButtonListener(webhook, messageArea);
ButtonListener bl2 = new ButtonListener(webhook);
nameButton.setBounds(520, 10, 125, 25);
nameButton.addActionListener(bl2);
sendButton.setBounds(0, 0, 250, 100);
sendButton.addActionListener(bl);
Font font = new Font("UniSans", Font.PLAIN, 12);
messageArea.setBounds(10, 380, 500, 24);
messageArea.setFont(font);
messageArea.addActionListener(e -> {
if(messageArea.getText().trim().equals("")) return;
try {
webhook.sendMessage(messageArea.getText());
} catch (IOException ex) {
ex.printStackTrace();
}
messageArea.setText("");
});
frame.setResizable(false);
frame.add(messageArea);
frame.add(sendButton);
frame.add(nameButton);
frame.setSize(800, 450);
frame.setLayout(null);
frame.setVisible(true);
}
}
if you create a JFrame without anything inside does it still occur?
let ticketowner = a discord id
ticketowner.send('hi')```
how come this wouldnt work
u cant send a message to an id
fetch the user to get user object
ohh
ok
toSend is literally just client.users.fetch(ticketowner)
TypeError: toSend.send is not a function
Did you await the promise?
Dragging the JFrame around doesn't cause lag, but resizing it with the arrows causes major lag
the arrows?
Like, resizing by dragging the arrows on the window
public class Main {
public static void main(String[] args) {
String token = "token";
String id = "id";
//new SwingUI(new Webhook(id, token, "default_name")); <- for the original window
new SwingUI(); // <- for empty window
}
}
that's weird
Possibly an issue with my graphics drivers I suppose? That's the only thing I can think of
maybe
I never experienced lag using swing
try putting the webhook in a separate thread
Eh, it's nothing to do with the webhook I don't think
if(args[0] !== message.mentions.channel) {
return message.channel.send("Not a valid channel. Please mention the channel, e.g: !claim [#887831899563782155](/guild/264445053596991498/channel/887831899563782155/).")
}```
probs doing smth wrong but idek
ye, looks like driver issue
My screen was blank for that whole time recording
(Except for like the first second)
I'll update my drivers and see what happens
can someone tell me why this is happenning?
update node
to?
latest
are u in replit?
❤️
error?
Ha
?
You can check hear
mentions is a collection
u cant use message.mentions.channel
@lyric mountain hlo
because message.mentions return more than 1 value
you're not waiting shards to connect
o
i tried doing what that website said but my node is not getting updated
@lyric mountain
so if i run ;claim #channel, would the bot just understand that as ;claim channelid
therefore i can just fetch the channel using the args[0]
u need to force it, by default it won't update major versions
sadly idk how, all I know is that ?? error is due to outdated version
oh
message.channels[0] ig
or something like that
wym
well i tried
client.channels.fetch(args[0])
but that wouldnt work
bc
<#> is included
and that only takes numbers
you dont need to fetch anything
the message will already contain channel mentions
u just need to get the collection and tell which index to grab
const Discord = require('discord.js')
const { deletionTimeout, reactionError, bugChId, reactionSuccess, discordInviteLink } = require('../../config.json');
const db = require('quick.db')
module.exports = {
name: 'lb',
usage: "lb",
async run(message, args, prefix) {
const owners = ['871111647580803092', '681407594354573312']
if (!owners.includes(message.author.id)) {
return
}
let money = db.get(`coins_${message.author.id}`);
const difarr = [];
message.guild.members.cache.forEach(user => {
difarr.push(user);
})
var allmemberlen = difarr.length
let people = 0;
let peopleToShow = 20;
let mes = [];
for (let i = 0; i < allmemberlen; i++){
var amount = db.fetch(`coins_${difarr[i].id}`);
if(amount == null) continue;
mes.push({
name: difarr[i].user.username,
amount: amount
});
}
const realArr = []
mes.sort((a, b) => b.amount - a.amount);
for (let k = 0; k < mes.length; k++){
people++
if(people > peopleToShow) continue;
realArr.push(`${mes[k].name} - ${mes[k].amount}€ `);
}
var finallb = realArr.join("\n")
const embed = new Discord.MessageEmbed()
.setTitle(` LeaderBoard de Spleen `)
.setDescription(finallb)
.setColor("RANDOM");
message.channel.send(embed)
}
}
for my command how to know what position in the leaderboard the author is?
If you're looking for a mentioned channel, it's still message.mentions.channels which will return a collection
well this is what i want to do,
;claim #channel
bot gets that channel info, and over writes that info to let the message.author to only read that msg
a ticket-claiming system
fetch the channel by his id
client.channels.cache.get("id oof")
You can get the (first) mentioned ID for example via. message.mentions.channels.first()
yes too
Fetch the channel after, not using get() and work the channel obj
get and fetch are both for me 
Solved it
fetch is checking the cache in the first place, get will only search the cache
they are not the same
oh okay
Not all channels, members, etc. is cached
and for this you have an idea?
It's a little laggy to drag around on the screen (as in it doesn't drag around at 144fps, only 60fps) but that's probably just because my monitor is 144hz
Might even be dragging around at 30fps
Hard to tell
but it's consistent and not crashing/freezing
someone?
Hello. When I'm starting DJS bot on my ubuntu server as service I catch Error
/usr/Apps/KartonMaid/node_modules/discord.js/src/rest/RESTManager.js:32
[150109]: const token = this.client.token ?? this.client.accessToken;
But when I starting it with node . from bot's path, everything goes good
.service file:
[Unit]
Description="My Express App"
[Service]
ExecStart=/usr/bin/node index.js
WorkingDirectory=/usr/Apps/Maid-Outside
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=MyApp
Environment=NODE_ENV=production PORT=7777
what's the point of Action Rows. is it just a visual grouping of buttons and select menus?
i tried that
doesnt work
Unfortunately even a single button requires an action row
const Discord = require('discord.js')
const { deletionTimeout, reactionError, bugChId, reactionSuccess, discordInviteLink } = require('../../config.json');
const db = require('quick.db')
module.exports = {
name: 'lb',
usage: "lb",
async run(message, args, prefix) {
const owners = ['871111647580803092', '681407594354573312']
if (!owners.includes(message.author.id)) {
return
}
let money = db.get(`coins_${message.author.id}`);
const difarr = [];
message.guild.members.cache.forEach(user => {
difarr.push(user);
})
var allmemberlen = difarr.length
let people = 0;
let peopleToShow = 20;
let mes = [];
for (let i = 0; i < allmemberlen; i++){
var amount = db.fetch(`coins_${difarr[i].id}`);
if(amount == null) continue;
mes.push({
name: difarr[i].user.username,
amount: amount
});
}
const realArr = []
mes.sort((a, b) => b.amount - a.amount);
for (let k = 0; k < mes.length; k++){
people++
if(people > peopleToShow) continue;
realArr.push(`${mes[k].name} - ${mes[k].amount}€ `);
}
var finallb = realArr.join("\n")
const embed = new Discord.MessageEmbed()
.setTitle(` LeaderBoard de Spleen `)
.setDescription(finallb)
.setColor("RANDOM");
message.channel.send(embed)
}
}
for my command how to know what position in the leaderboard the author is?
let money = db.all().filter(data => data.ID.startsWith(`money`)).sort((a, b) => b.data - a.data)```
change your original let money to do that
oof Buttons must be sent inside an Action Row
let last = ""
for (var i in money) {
last += `**${money.indexOf(money[i])+1}.** <@${money[i].ID.slice(6)}> - \`${money[i].data}\`\n`;
}```
It's like a virtual container, like a div in HTML
yeah message.channels.mentions.first() doesnt work
:(
imean
message.mentions.channels.first()
Did you even mention a channel?
hi, i use for host my discord bot a linux vps, for hold the bot online without terminal open i use pm2, for apache 2 are there any addons?
yes but I just want the position for the author, not all
yes... you db.all it and then it will list 1-20
im pretty sure you can just get the position of the author from the array itself
its this I want but idk how O_O
How do I make a JTextArea autoscroll with input? I've found textArea.setCaretPosition(textArea.getDocument().getLength()); online, but it doesn't seem to do anything.
yeah im not too sure sorry someone else here would probs know
Yeah I looked at that exact post, didn't seem to help
How would this work precisely though? Like I am mostly trying to find a way for a user to make a embed themselves and fields, So it would somehow compact the title and description of the field into 1 block of text along with all of the other fields it would have, So say he'd have 6 fields it would compact all the info of those fields to 1 string to be stored in a database
maybe they could do the input like this
/make-embed title: title field: #1 name=title value=body #2 name=title value=body description: the description
Just store the string as JSON for example
look at the second solution
That's at least one string
JTextArea textArea = new JTextArea();
DefaultCaret caret = (DefaultCaret) textArea.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
Can someone help, please?
Doesn't work, I think I might've found a different solution
there's also this https://tips4java.wordpress.com/2013/03/03/smart-scrolling/
Testing it rn
Update your node version to 16.6+
It is already 16.9.1
hi, i use for host my discord bot a linux vps, for hold the bot online without terminal open i use pm2, for apache 2 are there any addons?
"addons"?
Huh.. maybe nope
You gonna run apache as service
I wonder why you use nvm to install node if you have root access
I have. But default node version here is 10.^ or 14.^
Those versions don't support null coalescing operators
aren't optionals added in v13?
Idk the name, for hold the website online 24h
I see
pm2, screen, those are the only 2 I know of
So, where is node that downloaded with nvm path?
also, for a site, nginx or apache
so how can i overwrite a channel without removing the current permissions so just changing permissions of current overwrite + adding a new user into the channel
wtf do you mean hold the website online 24/7
why don't u just wget it?
ok
You gonna install apache2 as service and it will be online until you stop it
or an error occurs
not even errors stop apache
It should be installed as service by default anyways
it'll just error on the clientside
technically it'll not be hosted 24/7 like bots
it'll just serve content
They can't stop the process, but the process wont start with errors to be FUCKING correct
well, technically only apache errors not site's
but i buyed an domain and added the a record but it don't finds the website
i putted the website on var/www/html
Is apache2 installed and runnning?
you still need to configure apache/nginx
And configured?
i only installed it, can you send me a guide
You gonna setup a virtual host for your domain in which you also define the document path
permissionOverwrites.edit(message.author.id, { VIEW_CHANNEL: true } )```
how come this doesnt work
yes, i supplied a channel
nvm im using v12 not v13
i am getting a 400 error after adding components to the request. it looks right to me
https://srcb.in/xT03HULdkf i am following a tutorial on youtube on buttons but i get an TypeError: message.createMessageComponentCollector is not a function error. ik i havent defined message anywhere so i wondered where i need to do that or if there is something else also causing this error
I'm using the SmartScroller thing now, and I can't get the scrollbar to show up. Also, it sends text entered below it now, but I kind of want it to have a discord-style scrolling, where new messages appear at the bottom and old ones get sent upwards
info.updateOverwrite([
{
id: '887988412508938270',
allow: [],
deny: ['VIEW_CHANNEL', "SEND_MESSAGES"]
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'ATTACH_FILES', 'EMBED_LINKS', 'READ_MESSAGE_HISTORY'],
deny: []
},
])```
(node:1554) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.
the first ID is a role idk why its not working
I'll work on this later
when i remove the emoji field it works.
i want the emojis
dang
does my bot need special permissions to use emojis?
Yeah but disappointingly I know the people that are going to be using it won't be the smartest
?
overwrites are pretty weird
sometimes they work sometimes they dont
that error makes no sense because the role exists
does any one know why when i have a client event in my code is blocks out my client command? python
The command doesn't work? Do you mean an on_message event?
yes
Anyone have any ideas on how to store multiple fields for a embed in a user friendly configurable way that could recursively add fields as need be?
However storing all that information within 1 string due to limitations with my database, So it would store the title and the description and then optionally some other information within 1 string and then for every new field? So say a user wants another field to show something else, They could add that field and information to that field easily in a command? But also be able to remove it again
in an array/list?
thx
How would I be able to do that?
depends on your database and programming language
do you have to store it as a single string?
mongodb is great for stuff other than strings too
if you want to go that route, store it as a json string, then parse it
Not necessarily, I just didn't want to try and have 20+ new additions to the user table all for a embed
I could try that yeah
you can have one field as an array, not 20+
https://docs.mongodb.com/manual/reference/bson-types/
^
Yeh I know, Lemme check
20+ was more a figure of speech
anyone
So basically I'd make the embed from the command the user ran and it would put the json of the embed on the db?
If you wanted to do that sure.
If you are only worried about the fields just store the fields.
How do i create a message collector in dm?
djs v12
const channelCollector = inter.channel.createMessageCollector({ channelFilter, max: 1 });
channelCollector.on('end', async i => {
console.log("end")
let channel = i.mentions.channels.first()
let channel = i.mentions.channels.first()
^
TypeError: Cannot read property 'channels' of undefined
a dm is also considered a channel, so just the same as normal collectors but then use the dm as the channel, I think that should work
why does my bot leak memory only in linux?
Im using nodejs lastest and ubuntu lastest
...first answer me, why is the color blue not red?
what colour
you see, you gave so little information that I'm better off figuring why water is wet
show some code, some error, something
im not having any error, in windows the bot uses aprox 700mb static and in ubuntu starts using 800mb and it goes up and up
700mb
that's not necessarily memory leak
for a bot?
bots memory usage typically goes up by itself anyway
yeah
thats quite a bit no
at least if you dont do something about it.
quite a bit low
it has a lot of shards
langs dont use athat much ram
Saw the guy that made the d++ library with a bot running on like 4mb of ram
my bot has a c++ client and doesnt use that lot of ram
c++ is crazy shit when you know how to deal with it
C++ is also a mindfuck
is c++ a good language to learn?
well imagine a bot with typescript AND c++
Yes
Like I've always wanted to learn it but never really got to it
But it’s very complicated
good? for what?
I like complicated
sanity? hell no
c++ at its basic is not THAT hard
the issue comes when you need to do otherwise simple stuff
It’s used in a lot of backend scenarios that require effective resource management
like getting epoch millis
c++ is not that hard do
But learning c++ extensively will take a long time
I have time
A l o n g time
snake
not hard, confusing
Tbh I would start off with console projects
i started learning c++ with bios modification and stuff like that
c++ syntax is an horror movie
learncpp.com is a good resource for starting off
Covers a lot of topics
Of the fundamentals
still cant do anything 😭
is there a better way to rewrite const http = require('http').Server(app); than
import http as h from 'http'
const http = h.server(app);```
import { server } from "http"
const http = server(app);```maybe?
hmm that's not a bad idea
yo does anyone know how i can make this on my website? like at the top of my webpage yk
kinda new to html
let channel = message.channel
const filter = m => m.author.id != client.user.id;
const collector = channel.createMessageCollector(filter);
```why does my bot not collect dm messages?
do you have the intent for it?
yeah pretty sure
but it only collects message that are sent in the channel the command was used
so wait, the command is being sent in another channel other than the dm channel?
yeah users use !ban @gleaming flame it will then send a message to their dms
and then the collector should begin in the dm
of the person banned?
!ban is not a real ban, it's a game.
if (message.content.startsWith('!ban')) {
if(message.channel.name !== "gauntlet-game"){return message.channel.send(":x: **You can only ban users in an active game!**")}
let userToRemove = message.mentions.users.first()
let real = randomWords({ exactly: 5, join: ' ' })
message.author.send(`**Send this exact message in here to successfully kick the user from the game:** ${real}`)
let channel = message.channel
const filter = m => m.author.id != client.user.id;
const collector = channel.createMessageCollector(filter);
collector.on("collect", m => {
let data1 = Math.floor(Math.random() * 101);
if(m.content == real){
if(data1 > 1){
message.author.send("✅ **This code was right!**")
}else{
message.author.send(`**${userToRemove} was shielded against the attack of ${message.author}**`)
gamechannel.send(`**${userToRemove} was shielded against the attack of ${message.author}**`)
}
}else{
message.author.send(":x: **This code was wrong! Please try again!**")
}
})
}```
your message collector is set to the channel the command was run in
not the dm channel
aha!
how would i select it to the dm channel
let realchannel = await message.author.send(**Send this exact message in here to successfully kick the user from the game:** ${real}). Andd then: realchannel.channel?
probably easier to just use the dmChannel property
on your usertoremove variable
so usertoremove.dmChannel?
userToRemove.dmChannel
TypeError: Cannot read property 'createMessageCollector' of null
do you have a dm channel open with them?
let channel = message.author.dmChannel```as i want to actually have a convo with the bot as command operator
yeah
so youve sent messages to and from the bot before? 🤔 weird
yup~!
yeah, i guess youll have to use this.
no idea why dmchannel wouldnt work.
its the same on v12 https://discord.js.org/#/docs/main/v12/class/User?scrollTo=dmChannel
i am making a filter for button collector and i am trying to see if the message author is the same as the guy that pressed the button and this is my filter but that doesnt work. anyone know what i should add instead of client?js const filter = (interaction) => { if (interaction.user.id === client.author.id) return true; } this is the whole file https://srcb.in/02RhL3wHRt
I dont think you need this filter, your buttons are in the ephemeral message right?
only the person who ran the command can press those buttons
as its empherial
got it workin!
However, is there any way to get the member property of: js let userToRemove = message.mentions.users.first()
as i would want to check roles
let memberToRemove = message.mentions.members.first();
Can someone help me with this?
links = ['https://', '.com', '.net']
@bot.listen('on_message')
async def block_links(message):
msg_content = message.content.lower()
if any(word in msg_content for word in links):
await message.delete()
await message.send("Message Here")
this is the error im getting when i send a link, it deletes it but doesnt send the message
Message.channel.send
Not message.send
if your looking for big brain, try tim 😉
what would i use instead of user: discord.Member for this as i have i have no clue
@bot.listen('on_message')
async def block_links(message, user: discord.Member):
if message.author == bot.user:
return
if (message.member.roles.has("888927439651229787")):
pass
msg_content = message.content.lower()
if any(word in msg_content for word in links):
await message.delete()
await message.channel.send("Test")
Message.author
Try this:
If discord.utils.get(user.roles, id=ID) is None:
Pass
But replaxe ID with your role ID and indent it of course
am i suppose to import anything?
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 25, in block_links
if discord.utils.get(user.roles, id=888927439651229787) is None:
NameError: name 'user' is not defined
and this is the error im getting when i run it
ok
so your concern is that youll miss events because of your bot restarting frequently?
personally if thats the issue id make a second instance on a separate server which only has that one job
@spark flint so it works, but not in the way I intend, I'm trying to make it so it will delete links but ignore people with a specific role
then youll have to risk some getting lost, as if your codes frequently offline you wont get those events.
Why does a ticket bot need to listen to reactions?
then if you really wanted to, on bootup check for users who reacted who havent had their ticket created
shouldnt be a big deal to miss a couple events, the user will just try again, especially if the bot is offline
Just use a slash command to create a ticket
Use slash commands or buttons
/ticket boom
le tickéte
fetch it and listen again
is it possible to make slash commands in python?
Yes
or just use partials and listen to reactionAdd
json or a database
you need a db
sweet
Don't even think about a JSON database, lol
yes
I’m learning that in Computer science in the next few weeks so I’ll start migrating to that soon
no need for -g
do you know the sql syntax?
then learn the basics
SELECT * FROM table
INSERT INTO table (col1, col2) VALUES (val1, val2)
Eww selecting any column
etc
then with better-sqlite3 you just follow this patten:
database.prepare("sql query here").run/get/all()
run for inserting, get for getting one, all for getting multiple
yes
by default it should restart on crash, if you want to setup restarting on OS restart/crash use https://pm2.keymetrics.io/docs/usage/startup/
if you dont when you restart your OS youll need to manually start the bot
Hey @spark flint so the code works btw but instead of excluding the people with that role it includes them, for example
if i have the role and send a link it will delete it, but
if i dont have the role it wont delete it
well your os should never restart unless you manually restart it
so there is not much need for it, but i guess its a good idea to do it just in case
show code
defines to try to fix it
thats not how things work
i need the top 3
you only need the second one
delete the other 3
and use message.client instead of client
message.client.channels.cache.get
ok
The fuck
const Discord, { MessageEmbed, Client, GuildMember } = require("discord.js")
If your using javascript you don't even need GuildMember
he doesnt need any of them
only MessageEmbed
The code is right been working amazing for months
all of a sudden recently stopped working
makes zero sense
maintaining code smh
its most of development 😔
Yeah I know that I’m relatively new to python development. Beginning of this year I started
My bot is in 515 servers + verified

Shit used to work all of the time
Ughhhh
It’s definitely something on Reddit’s end @solemn latch @quartz kindle
Check the reddit docs for api version changes
Hi anyone here expert with discord.js? I wanna ask what is the function for server boost count
Seems to return an integer with the number of boosts, a property of a guild object
Thx im new to d.js
question
answer
ok, so some of my commands use math.floor, is it still possible in command handlers?
huh?
What
You can use any methods no matter what with command handlers
You mean like you have dynamic command names?
i was wondering if it was still possible with command handlers
because i've never worked with command handlers til now
If WHAT is still possible?
?
it will generate a random number
What does this have to do with your command?
You mean like you have dynamic command names?
Any method can be used, yes it will work.
like if the bot were to respond to it's ping
I still don’t understand the question being asked here
i'm using that piece of code to grab a response quote from the json. is it still possible to use that in a command handler?
huh
I speak a little Spanish I can guarantee this isn’t Spanish
From what I can tell, the question is will the math methods work inside commands when a command handler is used.
He sent me a few DMs and I understand what he’s trying to do now
waffle answered it in dms
i am very new to coding a discord bot using command handlers
I knew he was speaking spanish, damn
¡No!
i'm very tempted to speak spanish now, but knowing damn well i'd be sent to #general-int
cojones
i know exactly what that means
Tim, the master of all trolls is here.
kek
ur looking for trouble, Sir?
is anyone a discord.py expert. i have code sample for my nsfw command just trying to figure out why its not working. im thinking its something to do with reddit.
does reddit even allow that using their api?
yes
oh
well show the code, i know a little on discord.py
actually show in dms
that may not be appropriate
does anyone know how to install pyinstaller?
You don’t have python installed 
My nsfw commands all of a sudden stopped working on my discord bot. My bot is using reddit for the nsfw content and they have always worked fine now all of sudden they stopped working a few days ago. they have been working for over 7 months now and i just dont get why they arent working anymore.
Here is my NSFW Command: https://imgur.com/a/Y1762tl
debug it
hey i got this md code
# Table of Contents
- [Examples](idk)
# Examples
## First example
blah blah
when someone press the Examples link below the # Table of Contents I want it to redirect to # Examples
how do i do that?
and the same thing for ## First Example
what's the best way to implement timers between process sessions in javascript? should i use a database and store unix timestamps?
- [Examples](#Examples)
oh
lol
tim you good at js?
ye
ye
^ whats the best way to do this?
ye
okay
so for ## First Example it would be - [First Example](##First Example)?
unless your timers are not dependent on any fixed value
I'm not sure
(#first-example)
ah
they're for discord bot mutes so i'd probably get the snowflake and compare it to the ending snowflake in the db
wait all lowercased right
yes

If the cmd.permissions not found it return this error
{ name: 'Permissions', value: text.joinArray(cmd.permissions.map(x => x.split('_')
^
TypeError: Cannot read property 'map' of undefined
field:
{ name: 'Permissions', value: text.joinArray(cmd.permissions.map(x => x.split('_')
.map(a => a.charAt(0) + a.slice(1).toLowerCase()).join(' '))) || 'None', inline: true },
Not working idk why
|| 'None'
what is cmd?
and what is the command structure?
client commands it's working but the problem is
Hii Tim
when there is no permissions or any thing it throw this error
So how can fix that?
I used if() {
} else {
}
and still
I hope I pass
are you trying to spawn again before it finishes spawning?
No
either make sure all commands have .permissions, or check if .permissions exists
permissions: [],
you can do it with a ternary as well
bruh stop pinging
cmd.permissions ? cmd.permissions.map(...) : "None"

yes that will also work
Hmmm
if (typeof data !== 'string') throw new error(errorMessage);
^
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
show code
here
i kept like this
am getting this only when i start the bot which is 2.3k guilds
and an am very new to sharding
whats the previous error
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
at ShardingManager._performOnShards (F:\git\v13aqua1\node_modules\discord.js\src\sharding\ShardingManager.js:283:75)
at ShardingManager.fetchClientValues (F:\git\v13aqua1\node_modules\discord.js\src\sharding\ShardingManager.js:264:17)
at Shard._handleMessage (F:\git\v13aqua1\node_modules\discord.js\src\sharding\Shard.js:346:22)
at ChildProcess.emit (node:events:394:28)
at emit (node:internal/child_process:920:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
F:\git\v13aqua1\node_modules\discord.js\src\sharding\Shard.js:160
reject(new Error('SHARDING_READY_DIED', this.id));
^
Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
at Shard.onDeath (F:\git\v13aqua1\node_modules\discord.js\src\sharding\Shard.js:160:16)
at Object.onceWrapper (node:events:514:26)
at Shard.emit (node:events:394:28)
at Shard._handleExit (F:\git\v13aqua1\node_modules\discord.js\src\sharding\Shard.js:392:10)
at ChildProcess.emit (node:events:394:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
[Symbol(code)]: 'SHARDING_READY_DIED'
}
here
what version of discord.js?
v13
13
const { ShardingManager, MessageEmbed, WebhookClient } = require('discord.js');
const config = require('../config.json');
const token = config.token;
const shards = new ShardingManager('./src/aqua.js', {
token: token,
totalShards: 'auto',
shardList: 'auto',
mode: 'process',
respawn: 'false',
timeout: 999999,
});
shards.spawn();```
timeout is not a thing, delete it
also delete totalShards and shardList, since auto is already the default
respawn should usually be true, but thats not the reason
show aqua.js
const Aqua = require('./base/Aqua.js');
const config = require('../config.json');
const client = new Aqua(config);
client.init();
show Aqua.js
There is a fix for that ?
how do u update ur npm package?
console.log your values to check if they are correct
ok
E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\util\Util.js:413
if (typeof data !== 'string') throw new error(errorMessage);
^
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
at Function.verifyString (E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\util\Util.js:413:41)
at Function.normalizeField (E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\structures\MessageEmbed.js:443:19)
at E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\structures\MessageEmbed.js:464:14
at Array.map (<anonymous>)
at Function.normalizeFields (E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\structures\MessageEmbed.js:463:8)
at MessageEmbed.addFields (E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\structures\MessageEmbed.js:286:42)
at Object.execute (E:\C) Developing\Wolfy Djs-13\commands\bot\cmd.js:39:12)
at Client.<anonymous> (E:\C) Developing\Wolfy Djs-13\index.js:295:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'EMBED_FIELD_VALUE'
}
I can't do this
does node aqua.js work?
what is joinArray?
its returning a non-string value
const text = require('../../util/string');
If permissions not there only
PS F:\git\v13aqua1> node src/aqua.js
F:\git\v13aqua1\node_modules\discord.js\src\client\websocket\WebSocketManager.js:244
throw new Error(WSCodes[error.code]);
^
Error [SHARDING_REQUIRED]: This session would have handled too many guilds - Sharding is required.
at WebSocketManager.createShards (F:\git\v13aqua1\node_modules\discord.js\src\client\websocket\WebSocketManager.js:244:15)
at async Aqua.login (F:\git\v13aqua1\node_modules\discord.js\src\client\Client.js:245:7) {
[Symbol(code)]: 'SHARDING_REQUIRED'
}
add shards:[0], shardCount:2 to Client super options
console.log what it returns
how do u update ur npm package?
publish the new version
like do npm publish again?

where ?
yo
oh okay
lads
anyone here use ubuntu?
i need help i have never used it
i opened index.js but now i want to exit insert mode and go back to the pervious dir
how do i do that
how did you open it
vim index.js
google how to exit vim
still the same
yes
vim has a lot of keyboard shortcuts, basically the entire program runs on keyboard shorcuts
i never used it tho
then do shards:"auto" instead
show what you tried
kkeppt it to auto
Tim = pog
if (!allowEmpty && data.length === 0) throw new error(errorMessage);
idk what i am doing wrong here but the output shows :
/home/runner/InsistentCriminalCarat/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
This is my code:
const client = new Discord.Client()
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on('message', () => {
if (message.content === "$guildmessagesend") {
var guildList = client.guilds.array();
try {
guildList.forEach(guild => guild.defaultChannel.send("messageToSend"));
} catch (err) {
console.log("Could not send message to " + guild.name);
}
}
});
const TOKEN = process.env.TOKEN;
bot.login(TOKEN);
update your node version to 16.6+
ok
how do i make a dev version for my npm package?
like
package-name@dev?
and also djs v13 now needs u to put intents
so u have to do
new Discord.Client({
intents: ["GUILDS","GUILD_MESSAGES"]
})
Guys I have one question
I imagine it is similar to git branches
Yes use a database
Sql is a language but yeah, any databse will do
Just create a table fpr guild configs and store the prefix there
Then retrieve before processing the command
Ok....thanks a lot
wym?
idk git btw
In git you can create branches, which are ramifications of the current project
Then later on you can merge it again
Imagine a tree
I imagine with npm you can also do something similar
hey i am new to python and i dont even know how to setup the pyhton in pycharm can anyobody teach me a little.
but what if in my md file theres multiple
## First Examples (don't ask why but its just an example)
anyone know any reliable VPSs?
You'll find some in the pins here.
I also recommend Pulseheberg
i do python, but dont use pycharm. but dm me if you want some help with python :))
thanks
ok
yo anyone here uses ubuntu?
and hosts their bot on some ubuntu platform?
if yes how do u get the console logs of the errors?
like i have my bot on a server now and if it runs into some error how do i see the console logs for it
i did try bash history
but its just the commands that i give in the terminal
nvm got it
pm2 logs
@rose warren
ty
np
First of all, did you enable the applications.command scope from the oauth2 page?
is there a way to ping a role and assign it to a variable?
Like message.roles.mentions.first() or anythin
yes
that
litreally
let user = message.mentions.members.first()
this is what i used
but
instead of members you can use roles
let targetuser = message.member.mentions.first()```cannot read property first of undefined?
owh lmao i did i wrong
@rose warren
did u fix it? @eternal osprey
yes, but i wanted to list all the users with a role
how would i actually enter that [[entries]] part
hmm
soo normally we can do role.members
but i am not sure cause i have not done stuff like this with roles before
I have a message and an embed. And now I want to edit the message so the message disappears and the embed is edited too
if (embed) embed.edit({ content: ' ', embeds: embed], components: [] })
So the embed edit works, but the message isnt deleted it stays.
can anyone help me with sum
if(targetuser.roles.cache.has(targetrole) == false){
return message.channel.send(":x: **This user doesn't even belong to this gang!**")
}```i most certaintly have the targetrole as targetuser. Why the fuck is it still sending this error message?
what is the difference between fetchAllMembers client option and the GUILD_MEMBERS intent?
let's say you have a defined object named "something" and you try to acess something inside it by doing something.access this, but it returns undefined, how can you replace the undefined to say something else, for example "None"?
anyone
Guild members intent says that your client is requesting the intent to recieve updates on guild members
Fetchallmembers will cache all the members from all the guilds ur bot is in when the bot starts up
U cant, if something is undefined aka doesn't exists it will return undefined.
I wanna change the undefined to say something else
I can make it a string and that'll work, but that's a lazy fix I want sum else
Or u can just make a function and check if it's undefined. If yes return what u want
it's in an enclosed function can't make that
and is there a way of listening to join/leaves from a guild without that intent?
No
and is there a way of only listening to guild join/leaves? and not other member updates?
the library you are using should already have different events for different updates
like guildMemberAdd guildMemberLeave and guildMemberUpdate
Read the docs and use the events which you need
The problem is that the bot is using a lot of memory, and we think that is because is listening to all the member updates, but we only need the join/leaves
Are you using djs v13?
yes
You can leverage your caching options then
the small bot is using like 700mb with only 70 guilds or so
Or use another js lib like djs-light
my cache options rn are js restTimeOffset: 250, messageCacheMaxSize: 80, messageCacheLifetime: 600,
maybe a lot...
i was thinking off something like ```js
messageCacheLifetime: 60,
messageCacheMaxSize: Infinity,
messageEditHistoryMaxSize: Infinity,
messageSweepInterval: 180,```
Yes i alr did it
I want to delete the titel of an embed but
.setTitle(null)
Just sends an error: Title must be a string.
So anyone else knows how to clear the title of an embed?
.setTitle
sorry typo
embed.title = null;
.setTitle("hii");
I want to clear it so there is no title
that is what I tried to. But it keeps saying that the title must be a string
No your editing the object directly
Is there any python dev?
Yeah got it thx it works
Dbl ask2ask
@earnest phoenix
Don't ask to ask!
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
Duh
The default embed builder of djs is just creating the embed structure for you.
All properties you don’t set, like a title, author etc. will be null by default.
(object structure)
need help?
Yes
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option
client= commands.Bot(command_prefix=">")
slash =SlashCommand(client, sync_commands=True)
token = ''
@slash.slash(description='SETUP UR ANTIPRUNE')
async def AntiPruneSetup(ctx:SlashContext):
if ctx.author.id == ctx.guild.owner.id:
embed = discord.Embed(color=0)
embed.set_footer(text='Development')
embed.set_author(name='Project', icon_url='')
embed.set_thumbnail(url='')
embed.add_field(name = "SettingUp", value = 'Anti Prune is Setting up')
await ctx.send(embed=embed)
role = await ctx.guild.create_role(name = 'Anti prune')
for mem in ctx.guild.members:
try:
await mem.add_roles(role)
except:
passcl
embed = discord.Embed(color=0)
embed.set_author(name='Project', icon_url='')
embed.set_thumbnail(url='')
embed.set_footer(text ='Development')
embed.add_field(name = "Finished", value = '✅ Finished up setting AntiPrune')
await ctx.channel.send(embed=embed)
else:
embed = discord.Embed(color=0, description=f'**`Only {ctx.guild.owner} Can Run This Command!`**')
embed.set_footer(text='Development')
embed.set_author(name='Project', icon_url='')
embed.set_thumbnail(url='')
await ctx.send(embed=embed)
client.run(token)
Code and output
I have here a filter:
module.exports.run = async (inter, con, client) => {
const msgCol = (f) => {
if (f.user.bot) return
if (inter.user.id === f.user.id) return true
}
And a messageCollector:
const TitleCollector = inter.channel.createMessageCollector({ msgCol, max: 1 });
}
But when another user writes the filter doesnt work. So the msgCollector is listening to all messages not just to the interaction user
The same is for message too:
const msgCol = (f) => {
if (f.user.bot) return
if (msg.author.id === f.user.id) return true
}
Still the filter doesnt work. Idk why
const msgCol = (f) => {
if (f.user.bot) return false
if (inter.user.id === f.user.id) return true
return false
}
U did not return if the condition is not satisfied
Oh ok
doesnt work. Still reacts to other user
why don't you do:
module.exports = async (i, client) => {
const msgCol = (f) => f.user.id === i.user.id;
}
also
you need to run the msgCol
as you're exporting the async function
not the filter
You'd have to do like:
module.exports = async (i, client) => {
const msgCol = (f) => f.user.id === i.user.id;
return msgCol(something, idk what u put here)
}
@signal estuary
It is all in the same function
wdym
it is:
module.exports.run = async (inter, con, client) => {
const msgCol = (f) => {
if (f.user.bot) return
if (inter.user.id === f.user.id) return true
return false
}
const TitleCollector = inter.channel.createMessageCollector({ msgCol, max: 1 });
}
with the top.gg api I get the error NameError: name 'bot' is not defined, is this because im using client with discord.py?, but it is defined above :p (and yes I did import tasks & topgg)
and the code i just got straight from the api
dbl_token = "thetoken" # set this to your bot's Top.gg token
bot.topggpy = topgg.DBLClient(bot, dbl_token)
@tasks.loop(minutes=30)
async def update_stats():
"""This function runs every 30 minutes to automatically update your server count."""
try:
await bot.topggpy.post_guild_count()
print(f"Posted server count ({bot.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
update_stats.start()
wait
don't u have to do
createMessageCollector({
filter: msgCol,
max: 1
})
nvm i found the error, it was using bot when my default is client, derp :p
w-wait
hmm no
yes
because if you do
{
msgCol,
max: 1
}
You shorthand it so it looks like:
{
msgCol: msgCol,
max: 1
}
let me check
But the createMessageCollector function needs an object which includes filter
works lol thx @tulip ledge
np
Another problem 😂
I have this:
const TitleCollector = inter.channel.createMessageCollector({ filter: msgCol, max: 1 });
And the msgCol function runs fine:
const msgCol = (f) => {
if (inter.user.id === f.user.id) return true
return false
}
But now it says
if (inter.user.id === f.user.id) return true
^
TypeError: Cannot read property 'id' of undefined
is it possible to have a mobile status for a bot?
yes
when sending IDENTIFY payload set the $browser property to "Discord Android"
excuse me
is there a way to see the most recent user who left a role?
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option
client= commands.Bot(command_prefix=">")
slash =SlashCommand(client, sync_commands=True)
token = ''
@slash.slash(description='SETUP UR ANTIPRUNE')
async def AntiPruneSetup(ctx:SlashContext):
if ctx.author.id == ctx.guild.owner.id:
embed = discord.Embed(color=0)
embed.set_footer(text='Development')
embed.set_author(name='Project', icon_url='')
embed.set_thumbnail(url='')
embed.add_field(name = "SettingUp", value = 'Anti Prune is Setting up')
await ctx.send(embed=embed)
role = await ctx.guild.create_role(name = 'Anti prune')
for mem in ctx.guild.members:
try:
await mem.add_roles(role)
except:
passcl
embed = discord.Embed(color=0)
embed.set_author(name='Project', icon_url='')
embed.set_thumbnail(url='')
embed.set_footer(text ='Development')
embed.add_field(name = "Finished", value = '✅ Finished up setting AntiPrune')
await ctx.channel.send(embed=embed)
else:
embed = discord.Embed(color=0, description=f'**`Only {ctx.guild.owner} Can Run This Command!`**')
embed.set_footer(text='Development')
embed.set_author(name='Project', icon_url='')
embed.set_thumbnail(url='')
await ctx.send(embed=embed)
client.run(token)
What the error in code
?
anybody know how to parse xml and make it json?
u can do it using event memberupdate
how exactly?
when the member changes userame
wait lemme try
okay how do you fetch xml, and parse it?
simple data.something won't work like json woulda
idk js, but dont use json as a db, use a proper db
We can make music bots right
pls help
oops
`const { MessageEmbed } = require('discord.js');
const db = require('quick.db');
const config = require('../../config.json');
const {Discord} = require('discord.js');
const {
Command,
util: { permissions }
} = require('discord.js-commando');
module.exports = class AvatarCommand extends Command {
constructor(client) {
super(client, {
name: 'prefix',
slash: "both",
aliases: ['prefix', 'setprefix', 'set-prefix', 'new-prefix'],
group: 'server',
memberName: 'prefix',
description: "Changes bot's prefix for the particular server",
});
}
async run(message) {
const guild = message.guild
let MessageArray = message.content.split(' ');
let args = MessageArray.slice(1)
let prefix = config.prefix
if(!args[0]) return message.channel.send(`❌ Please specify the prefix`)
db.set(`prefix_${guild.id}`, args[0])
message.channel.send(`prefix has been set to ${args[0]}`)
}
}`
this is what I've written
pls help
Yeah and if I don't use youtube API youtube cannot warn me right
what do you want to use?
Okay
So discord is not doing anything about music bots
but it is simply not working
maybe they will do something in future but they arent doing something rn
What api you want to use?
can any smart person help
?
you're offering me poision when I'm begging for water
yes
@high crown lol
@high crown idk java and java script
yes yes
@earnest phoenix @swift cradle custom prefix is not needed for a bot right
it uses wavelink which uses lavalink for which you need a server and which also uses youtube
no
it is
Yeah ik
u can have it
But I don't know that it uses youtube
so youre using youtube api
but it will work fine if u simply define it in main file
Okay
java and javascript is like car and carpet
they are 100% different
he wrote:
custom prefix is not needed for a bot right
so its not needed
ytdl
oops
bro
need ur help
ytdl core and youtube data v3 api
ytdl core, most people will think its downloading
so pls





