#development

1 messages · Page 1881 of 1

rocky dagger
#

it worked thanks

umbral lake
#
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

wheat mesa
#

is there any way to make optional parameters without overloading something a billion times in java

proven lantern
#

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?

pale vessel
#

If it's a guild-only interaction I guess not

proven lantern
# pale vessel 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

ancient token
#

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.

proven lantern
umbral lake
#

and when I console log oldState, its undefined

#

and I activated intents

proven lantern
#

this is the type of object that both oldState and newState is

#

there is no channelID property

umbral lake
proven lantern
#

if oldState was undefined then your code would throw an error, but it logs both yes and no

wheat mesa
#

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

proven lantern
#

no, swing is great. applets are going to replace javascript in the browser any day now

umbral lake
#

but idk where was the error

proven lantern
# umbral lake 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

wheat mesa
proven lantern
wheat mesa
#

Either that or I've done something terribly wrong

umbral lake
# proven lantern there wasn't an error. the code just isn't doing what you expect. if oldState w...
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

proven lantern
#

how are you importing this

#

and using it

novel snow
#

Anyone got a idea to recursively add more buttons and parts to a embed based on a collection?

umbral lake
novel snow
#

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?

proven lantern
#

.map() the fields to the embeds

novel snow
proven lantern
#
const embeds = fields.map(field => ({title:field.title,description:field.description}))```
urban slate
#

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

sterile lantern
#

If I do !check #channel, how would I check that #channel is a mentioned channel like #development (discord.js)

urban slate
#

message.mentions.channels

lyric mountain
#

use git, you don't need to transfer pc --> server

urban slate
#

but how

lyric mountain
#

create a private repo and use it to sync changes between the two ends

wheat mesa
#

Still can't figure out this lag issue

proven lantern
lyric mountain
#

github too

wheat mesa
#

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

proven lantern
#

are they free on github yet?

lyric mountain
#

since 2 years ago

#

or around that

#

github no longer has paid features (except actions budget)

proven lantern
#

nice

wheat mesa
#

released 1998

lyric mountain
#

maintained until now

wheat mesa
#

Still though

lyric mountain
#

like, they update it regularly

wheat mesa
#

It's fucking me so hard rn

#

No idea why

proven lantern
#

javascript is going to be replaced by java applets any day now

lyric mountain
#

bruh

#

it's the other way around

lyric mountain
#

javascript came exactly to allow browser <--> java integration

wheat mesa
#

I've looked through my code and it doesn't look like there's anything suspicious that could cause something like that

lyric mountain
#

y aren't u using intellij gui builder?

wheat mesa
#

That's a thing?

lyric mountain
#

...

wheat mesa
#

Haven't used Intellij pretty much at all

#

ngl

lyric mountain
#

remember android studion is intellij for android-only

#

intellij has gui builders for both desktop and android

wheat mesa
#

I'll try that out, but for right now I want to get this issue fixed

lyric mountain
#

but well, that doesn't look like a swing issue

wheat mesa
lyric mountain
#

what version are u using?

wheat mesa
#

Of Java?

lyric mountain
#

ye

wheat mesa
#

16

lyric mountain
#

openjdk, oracle or openj9?

#

just do java --version

wheat mesa
lyric mountain
#

hm

#

show the code related to that window

wheat mesa
#

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);
}

}

lyric mountain
#

if you create a JFrame without anything inside does it still occur?

sterile lantern
#
let ticketowner = a discord id
ticketowner.send('hi')```
#

how come this wouldnt work

lyric mountain
#

u cant send a message to an id

sterile lantern
#

hmm

#

how would i send a message to a user

#

with only their ID

lyric mountain
#

fetch the user to get user object

sterile lantern
#

ohh

#

ok

#

toSend is literally just client.users.fetch(ticketowner)

#

TypeError: toSend.send is not a function

solemn latch
#

Did you await the promise?

wheat mesa
sterile lantern
#

o

#

ty

wheat mesa
#

Like, resizing by dragging the arrows on the window

lyric mountain
#

hm

#

show ur psvm method

wheat mesa
#
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
    }
}
lyric mountain
#

that's weird

wheat mesa
#

Possibly an issue with my graphics drivers I suppose? That's the only thing I can think of

lyric mountain
#

maybe

#

I never experienced lag using swing

#

try putting the webhook in a separate thread

wheat mesa
#

Eh, it's nothing to do with the webhook I don't think

sterile lantern
#
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/).")
}```
wheat mesa
#

This is the result of an empty window, trying to resize

sterile lantern
#

probs doing smth wrong but idek

lyric mountain
#

ye, looks like driver issue

wheat mesa
#

My screen was blank for that whole time recording

#

(Except for like the first second)

#

I'll update my drivers and see what happens

lyric mountain
#

java uses opengl btw

#

updating drivers might solve it

urban slate
#

can someone tell me why this is happenning?

lyric mountain
#

update node

urban slate
#

to?

lyric mountain
#

latest

urban slate
#

it is 12v

#

how do i update node?

lyric mountain
#

are u in replit?

urban slate
#

no

#

aws

#

ligthsail

#

idk shit about it

lyric mountain
urban slate
#

❤️

blazing umbra
#

My bot is not starting

lyric mountain
#

error?

blazing umbra
#

Ha

blazing umbra
lyric mountain
#

ah, that's the actual error

#

you're not waiting shards to connect

lyric mountain
#

u cant use message.mentions.channel

blazing umbra
#

@lyric mountain hlo

lyric mountain
#

because message.mentions return more than 1 value

lyric mountain
sterile lantern
#

o

urban slate
#

i tried doing what that website said but my node is not getting updated

#

@lyric mountain

sterile lantern
#

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]

lyric mountain
#

u need to force it, by default it won't update major versions

urban slate
#

how do i force it?

#

-f?

lyric mountain
#

sadly idk how, all I know is that ?? error is due to outdated version

urban slate
#

oh

lyric mountain
#

you'll need someone who knows to pop here

#

like tim or whatever

lyric mountain
#

or something like that

sterile lantern
#

wym

#

well i tried

#

client.channels.fetch(args[0])

#

but that wouldnt work

#

bc

#

<#> is included

#

and that only takes numbers

lyric mountain
#

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

sterile lantern
#

message.channels[0] doesnt work

umbral lake
#
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}€ ![coins](https://cdn.discordapp.com/emojis/886983473859026994.webp?size=128 "coins")`);
        }
        var finallb = realArr.join("\n")
        const embed = new Discord.MessageEmbed()
        .setTitle(`![coins](https://cdn.discordapp.com/emojis/886983473859026994.webp?size=128 "coins") LeaderBoard de Spleen ![coins](https://cdn.discordapp.com/emojis/886983473859026994.webp?size=128 "coins")`)
        .setDescription(finallb)
        .setColor("RANDOM");
          message.channel.send(embed)
       }
    }

for my command how to know what position in the leaderboard the author is?

sterile lantern
#

quick db

#

lmao

boreal iron
sterile lantern
#

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

umbral lake
#

client.channels.cache.get("id oof")

boreal iron
#

You can get the (first) mentioned ID for example via. message.mentions.channels.first()

boreal iron
#

Fetch the channel after, not using get() and work the channel obj

umbral lake
wheat mesa
boreal iron
#

fetch is checking the cache in the first place, get will only search the cache

#

they are not the same

umbral lake
#

oh okay

boreal iron
#

Not all channels, members, etc. is cached

umbral lake
wheat mesa
#

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

hybrid roost
#

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
proven lantern
#

what's the point of Action Rows. is it just a visual grouping of buttons and select menus?

boreal iron
#

Pretty much, yeah

#

5 elements per row if I remember right

sterile lantern
#

wym

#

i only mentioned one channel

#

it sys

boreal iron
#

Unfortunately even a single button requires an action row

umbral lake
#
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}€ ![coins](https://cdn.discordapp.com/emojis/886983473859026994.webp?size=128 "coins")`);
        }
        var finallb = realArr.join("\n")
        const embed = new Discord.MessageEmbed()
        .setTitle(`![coins](https://cdn.discordapp.com/emojis/886983473859026994.webp?size=128 "coins") LeaderBoard de Spleen ![coins](https://cdn.discordapp.com/emojis/886983473859026994.webp?size=128 "coins")`)
        .setDescription(finallb)
        .setColor("RANDOM");
          message.channel.send(embed)
       }
    }

for my command how to know what position in the leaderboard the author is?

sterile lantern
#
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

proven lantern
boreal iron
#

Yeah

#

As I said

sterile lantern
#
let last = ""
for (var i in money) {
          last += `**${money.indexOf(money[i])+1}.**     <@${money[i].ID.slice(6)}> - \`${money[i].data}\`\n`;
        }```
proven lantern
#

i kept reading

#

sad times

boreal iron
#

It's like a virtual container, like a div in HTML

sterile lantern
#

yeah message.channels.mentions.first() doesnt work

#

:(

#

imean

#

message.mentions.channels.first()

boreal iron
#

Did you even mention a channel?

sterile lantern
#

yes

#

oh wait i see what i did

earnest phoenix
#

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?

umbral lake
sterile lantern
#

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

umbral lake
wheat mesa
#

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.

sterile lantern
lyric mountain
wheat mesa
#

Yeah I looked at that exact post, didn't seem to help

novel snow
proven lantern
#

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

boreal iron
#

Just store the string as JSON for example

lyric mountain
boreal iron
#

That's at least one string

lyric mountain
#
JTextArea textArea = new JTextArea();
DefaultCaret caret = (DefaultCaret) textArea.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
wheat mesa
lyric mountain
wheat mesa
#

Testing it rn

boreal iron
hybrid roost
#

It is already 16.9.1

earnest phoenix
#

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?

lyric mountain
#

"addons"?

hybrid roost
boreal iron
#

You gonna run apache as service

hybrid roost
#

I installed node from nvm

#

But when i use /usr/bin/node -v

#

It is 10.19.0

#

Lol

boreal iron
#

I wonder why you use nvm to install node if you have root access

hybrid roost
#

I have. But default node version here is 10.^ or 14.^

boreal iron
#

Those versions don't support null coalescing operators

lyric mountain
#

aren't optionals added in v13?

earnest phoenix
lyric mountain
hybrid roost
#

So, where is node that downloaded with nvm path?

lyric mountain
#

also, for a site, nginx or apache

sterile lantern
#

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

boreal iron
#

wtf do you mean hold the website online 24/7

lyric mountain
earnest phoenix
boreal iron
#

You gonna install apache2 as service and it will be online until you stop it

#

or an error occurs

lyric mountain
#

not even errors stop apache

boreal iron
#

It should be installed as service by default anyways

lyric mountain
#

it'll just error on the clientside

#

technically it'll not be hosted 24/7 like bots

#

it'll just serve content

boreal iron
lyric mountain
#

well, technically only apache errors not site's

earnest phoenix
#

i putted the website on var/www/html

boreal iron
#

Is apache2 installed and runnning?

lyric mountain
#

you still need to configure apache/nginx

boreal iron
#

And configured?

earnest phoenix
#

i only installed it, can you send me a guide

boreal iron
#

You gonna setup a virtual host for your domain in which you also define the document path

hybrid roost
#

OK. I resolved it

#

I take path with
nvm which 16.9.1
And paste it in .service file

sterile lantern
#
permissionOverwrites.edit(message.author.id,  { VIEW_CHANNEL: true } )```
#

how come this doesnt work

#

yes, i supplied a channel

#

nvm im using v12 not v13

proven lantern
#

i am getting a 400 error after adding components to the request. it looks right to me

rocky dagger
#

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

wheat mesa
#

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

sterile lantern
#
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

proven lantern
#

i want the emojis

#

dang

#

does my bot need special permissions to use emojis?

novel snow
sterile lantern
#

overwrites are pretty weird

#

sometimes they work sometimes they dont

#

that error makes no sense because the role exists

soft glade
#

does any one know why when i have a client event in my code is blocks out my client command? python

earnest phoenix
#

The command doesn't work? Do you mean an on_message event?

soft glade
#

yes

novel snow
#

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

novel snow
solemn latch
#

depends on your database and programming language

novel snow
#

NodeJS

#

Using MongoDB in a single string to store the information

solemn latch
#

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

novel snow
solemn latch
young patio
#

^

eternal osprey
#

How do i create a message collector in dm?

#

djs v12

young patio
#

so basically

#

wait brb

novel snow
#

20+ was more a figure of speech

novel snow
solemn latch
#

If you wanted to do that sure.
If you are only worried about the fields just store the fields.

eternal osprey
#

How do i create a message collector in dm?
djs v12

signal estuary
#
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
tulip ledge
tawdry oracle
#

why does my bot leak memory only in linux?

#

Im using nodejs lastest and ubuntu lastest

lyric mountain
#

...first answer me, why is the color blue not red?

tawdry oracle
#

what colour

lyric mountain
#

you see, you gave so little information that I'm better off figuring why water is wet

#

show some code, some error, something

tawdry oracle
#

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

tulip ledge
#

700mb

lyric mountain
#

that's not necessarily memory leak

tulip ledge
#

for a bot?

solemn latch
#

bots memory usage typically goes up by itself anyway

tawdry oracle
#

yeah

tulip ledge
#

thats quite a bit no

solemn latch
#

at least if you dont do something about it.

lyric mountain
tawdry oracle
tulip ledge
#

why does mine onlky use 90 mb then?

#

it's in 1k+ servers and is an rpg game

lyric mountain
#

what does it do and what lang?

#

do u use cache?

tulip ledge
#

ts

#

no I don't

#

I probably should tho

lyric mountain
#

that's it then

#

with cache you sacrifice RAM for performance

tawdry oracle
#

langs dont use athat much ram

lyric mountain
#

depends

#

java for sure uses more than c++

#

c++ uses more than assembly

wheat mesa
#

Saw the guy that made the d++ library with a bot running on like 4mb of ram

tawdry oracle
#

my bot has a c++ client and doesnt use that lot of ram

lyric mountain
#

c++ is crazy shit when you know how to deal with it

wheat mesa
#

C++ is also a mindfuck

tulip ledge
#

is c++ a good language to learn?

tawdry oracle
#

well imagine a bot with typescript AND c++

wheat mesa
tulip ledge
#

Like I've always wanted to learn it but never really got to it

wheat mesa
#

But it’s very complicated

lyric mountain
tulip ledge
#

I like complicated

lyric mountain
#

sanity? hell no

tulip ledge
#

Just

#

to learn

lyric mountain
#

c++ at its basic is not THAT hard

#

the issue comes when you need to do otherwise simple stuff

wheat mesa
#

It’s used in a lot of backend scenarios that require effective resource management

lyric mountain
#

like getting epoch millis

tawdry oracle
#

c++ is not that hard do

tulip ledge
#

any project I could start with?

#

for c++

wheat mesa
#

But learning c++ extensively will take a long time

tulip ledge
wheat mesa
#

A l o n g time

lyric mountain
lyric mountain
wheat mesa
#

Tbh I would start off with console projects

tawdry oracle
lyric mountain
#

c++ syntax is an horror movie

wheat mesa
#

Covers a lot of topics

#

Of the fundamentals

sterile lantern
buoyant aspen
#

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);```
tawdry oracle
buoyant aspen
#

hmm that's not a bad idea

warm crypt
#

yo does anyone know how i can make this on my website? like at the top of my webpage yk

#

kinda new to html

eternal osprey
#
  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?
solemn latch
#

do you have the intent for it?

eternal osprey
#

but it only collects message that are sent in the channel the command was used

solemn latch
#

so wait, the command is being sent in another channel other than the dm channel?

eternal osprey
#

yeah users use !ban @gleaming flame it will then send a message to their dms

#

and then the collector should begin in the dm

solemn latch
#

of the person banned?

eternal osprey
solemn latch
#

ah

#

so is the message variable a message sent in the dm?

eternal osprey
#
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!**")
}
})
  }```
solemn latch
#

your message collector is set to the channel the command was run in

#

not the dm channel

eternal osprey
#

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?

solemn latch
#

probably easier to just use the dmChannel property

#

on your usertoremove variable

eternal osprey
#

so usertoremove.dmChannel?

solemn latch
#

userToRemove.dmChannel

eternal osprey
solemn latch
#

do you have a dm channel open with them?

eternal osprey
#
   let channel = message.author.dmChannel```as i want to actually have a convo with the bot as command operator
eternal osprey
solemn latch
#

so youve sent messages to and from the bot before? 🤔 weird

eternal osprey
#

yup~!

solemn latch
eternal osprey
#

maybe it's the filter after all

#

i am in v12

#

dunno if that changes it?

solemn latch
rocky dagger
#

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

solemn latch
#

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

rocky dagger
#

that is true

#

you are smart

eternal osprey
#

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

solemn latch
#

let memberToRemove = message.mentions.members.first();

soft glade
#

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

spark flint
#

Not message.send

soft glade
#

i knew i forgot something

#

im retarded

#

thank you

#

im used to ctx.send

solemn latch
#

if your looking for big brain, try tim 😉

soft glade
#

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")
spark flint
#

You don’t even use User in thst

#

So remove it

soft glade
#

i get a syntax error when i do so

spark flint
#

Remove discord.member

#

async def block_links(message):

#

Just that

soft glade
spark flint
#

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

soft glade
#

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

spark flint
#

Replace user.roles

#

With message.author.roles

soft glade
#

ok

solemn latch
#

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

soft glade
#

@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

solemn latch
#

then youll have to risk some getting lost, as if your codes frequently offline you wont get those events.

boreal iron
#

Why does a ticket bot need to listen to reactions?

solemn latch
#

then if you really wanted to, on bootup check for users who reacted who havent had their ticket created

quartz kindle
#

shouldnt be a big deal to miss a couple events, the user will just try again, especially if the bot is offline

boreal iron
#

Just use a slash command to create a ticket

spark flint
#

Use slash commands or buttons

boreal iron
#

/ticket boom

quartz kindle
#

le tickéte

boreal iron
#

Shh

#

Le baguette

quartz kindle
#

fetch it and listen again

soft glade
quartz kindle
#

or just use partials and listen to reactionAdd

spark flint
#

json or a database

quartz kindle
#

you need a db

soft glade
boreal iron
#

Don't even think about a JSON database, lol

quartz kindle
#

just use sqlite

#

better-sqlite3 if node.js

spark flint
#

Store it in the format:
{
“Server ID”: {
“Ticket id”:”ticketauthor”
}
}

#

Or not JSON

quartz kindle
#

yes

spark flint
quartz kindle
#

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)

boreal iron
#

Eww selecting any column

quartz kindle
#

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

solemn latch
#

if you dont when you restart your OS youll need to manually start the bot

soft glade
#

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

quartz kindle
#

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

earnest phoenix
#

How to make a bot send something in a channel with id

#

discord.js

quartz kindle
#

show code

earnest phoenix
#

@quartz kindle ^^

quartz kindle
#

wtf is this

earnest phoenix
#

defines to try to fix it

quartz kindle
#

thats not how things work

earnest phoenix
#

i need the top 3

quartz kindle
#

you only need the second one

#

delete the other 3

#

and use message.client instead of client

#

message.client.channels.cache.get

earnest phoenix
#

ok

blissful coral
#

The fuck

#

const Discord, { MessageEmbed, Client, GuildMember } = require("discord.js")

#

If your using javascript you don't even need GuildMember

quartz kindle
#

he doesnt need any of them

blissful coral
#

Fr

#

LMAO

#

That is scary looking

quartz kindle
#

only MessageEmbed

earnest phoenix
#

Fix

#

Anyone?

#

cant help

quartz kindle
#

did you change anything? did reddit change anything?

#

did you try debugging it?

earnest phoenix
#

The code is right been working amazing for months

#

all of a sudden recently stopped working

#

makes zero sense

quartz kindle
#

things change

#

especially when your code relies on external services

solemn latch
#

maintaining code smh

earnest phoenix
#

^ 🤦

#

Shits wack lol 😂

solemn latch
#

its most of development 😔

earnest phoenix
#

Yeah I know that I’m relatively new to python development. Beginning of this year I started

#

My bot is in 515 servers + verified

muted warren
earnest phoenix
#

Shit used to work all of the time

#

Ughhhh

#

It’s definitely something on Reddit’s end @solemn latch @quartz kindle

solemn latch
#

Check the reddit docs for api version changes

agile seal
#

Hi anyone here expert with discord.js? I wanna ask what is the function for server boost count

earnest phoenix
#

Seems to return an integer with the number of boosts, a property of a guild object

grim aspen
#

question

boreal iron
#

answer

grim aspen
#

ok, so some of my commands use math.floor, is it still possible in command handlers?

boreal iron
#

huh?

wheat mesa
#

What

solemn latch
#

You can use any methods no matter what with command handlers

boreal iron
#

You mean like you have dynamic command names?

grim aspen
#

i was wondering if it was still possible with command handlers

#

because i've never worked with command handlers til now

boreal iron
#

If WHAT is still possible?

grim aspen
#

ffs

#

Math.floor(Math.random()

errant flax
#

?

grim aspen
#

it will generate a random number

boreal iron
#

What does this have to do with your command?

#

You mean like you have dynamic command names?

solemn latch
#

Any method can be used, yes it will work.

grim aspen
#

like if the bot were to respond to it's ping

wheat mesa
#

I still don’t understand the question being asked here

grim aspen
#

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?

wheat mesa
#

huh

boreal iron
#

It's like he's speaking spanish, damn

wheat mesa
#

I speak a little Spanish I can guarantee this isn’t Spanish

solemn latch
#

From what I can tell, the question is will the math methods work inside commands when a command handler is used.

wheat mesa
#

He sent me a few DMs and I understand what he’s trying to do now

grim aspen
#

waffle answered it in dms

#

i am very new to coding a discord bot using command handlers

boreal iron
#

I knew he was speaking spanish, damn

wheat mesa
#

¡No!

grim aspen
#

i'm very tempted to speak spanish now, but knowing damn well i'd be sent to #general-int

quartz kindle
#

cojones

grim aspen
#

i know exactly what that means

boreal iron
#

Tim, the master of all trolls is here.

wheat mesa
#

Problema?

grim aspen
#

kek

boreal iron
#

ur looking for trouble, Sir?

earnest phoenix
#

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.

grim aspen
#

does reddit even allow that using their api?

earnest phoenix
grim aspen
#

oh

#

actually show in dms

#

that may not be appropriate

soft glade
#

does anyone know how to install pyinstaller?

solemn latch
#

Using pip?

#

pip install pyinstaller

soft glade
#

for some reason that doesnt work

#

do i have to be on python 3.9?

wheat mesa
#

You don’t have python installed KEKW

soft glade
#

i just deleted it im reinstalling it rn then ima try it again

earnest phoenix
#

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

quartz kindle
#

debug it

errant flax
#

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

green vale
#

what's the best way to implement timers between process sessions in javascript? should i use a database and store unix timestamps?

torn blaze
#

Can I run python on a 4gb ram laptop

#

??

blissful coral
#

yes

#

easily

quartz kindle
#

lol

green vale
#

tim you good at js?

quartz kindle
#

ye

green vale
#

ye

#

okay

errant flax
quartz kindle
#

unless your timers are not dependent on any fixed value

errant flax
#

ah

green vale
errant flax
#

wait all lowercased right

quartz kindle
#

yes

errant flax
slow terrace
#

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'
earnest phoenix
#

Anyone can help

slow terrace
#

const cmd = client.commands.get(query.toLowerCase());

#

query is args

quartz kindle
#

and what is the command structure?

slow terrace
#

client commands it's working but the problem is

earnest phoenix
#

Hii Tim

slow terrace
#

when there is no permissions or any thing it throw this error

quartz kindle
#

yes

#

cmd.permissions has to exist

#

you cant use .map if it doesnt exist

slow terrace
#

I used if() {
} else {
}
and still

flint beacon
#

I hope I pass

quartz kindle
earnest phoenix
#

No

quartz kindle
slow terrace
#

permissions: [],

quartz kindle
#

you can do it with a ternary as well

earnest phoenix
#

@lament bronze

#

@lament bronze

errant flax
#

bruh stop pinging

quartz kindle
#

cmd.permissions ? cmd.permissions.map(...) : "None"

errant flax
quartz kindle
slow terrace
#

Hmmm

    if (typeof data !== 'string') throw new error(errorMessage);
                                        ^

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
quartz kindle
slow terrace
#

I added || 'None'
why not working lol

#

And permissions: [],
in the cmd

lament bronze
#

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

quartz kindle
lament bronze
# quartz kindle 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

quartz kindle
#

what version of discord.js?

lament bronze
#

v13

earnest phoenix
#

13

quartz kindle
#

show the rest of the code

#

the spawn function

lament bronze
#
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();```
quartz kindle
#

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

lament bronze
# quartz kindle show aqua.js

const Aqua = require('./base/Aqua.js');
const config = require('../config.json');
const client = new Aqua(config);
client.init();

quartz kindle
#

show Aqua.js

slow terrace
errant flax
#

how do u update ur npm package?

quartz kindle
slow terrace
#

ok

lament bronze
#

here

slow terrace
#
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

quartz kindle
quartz kindle
#

its returning a non-string value

slow terrace
#
const text = require('../../util/string');
slow terrace
lament bronze
# quartz kindle does `node aqua.js` work?
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'
}
quartz kindle
quartz kindle
errant flax
#

how do u update ur npm package?

quartz kindle
#

publish the new version

errant flax
#

like do npm publish again?

quartz kindle
#

yes

#

after changing the version in your pakage.json

#

to a bigger version

errant flax
quartz kindle
urban slate
#

yo

lament bronze
#

oh okay

urban slate
#

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

quartz kindle
#

how did you open it

urban slate
#

vim index.js

quartz kindle
#

google how to exit vim

lament bronze
urban slate
#

oh

#

so is the code text editor called vim?

quartz kindle
#

yes

urban slate
#

ahhhh

#

okk

quartz kindle
#

vim has a lot of keyboard shortcuts, basically the entire program runs on keyboard shorcuts

#

i never used it tho

urban slate
#

ohh

#

well nice i got out of it

#

thnx mate

quartz kindle
lament bronze
#

tried that too

#

but no use

quartz kindle
#

show what you tried

lament bronze
#

kkeppt it to auto

inner fulcrum
#

Tim = pog

slow terrace
hollow hull
#

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);
smoky spire
#

update your node version to 16.6+

hollow hull
#

ok

errant flax
#

how do i make a dev version for my npm package?
like
package-name@dev?

errant flax
#

so u have to do

#
new Discord.Client({
intents: ["GUILDS","GUILD_MESSAGES"]
})
high crown
#

Guys I have one question

lyric mountain
high crown
#

Can we make per server prefix in Commando?

#

Ig no

lyric mountain
#

Yes use a database

high crown
#

Ohh k

#

Like quick.db?

#

Or SQL?

lyric mountain
#

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

high crown
#

I have stored the prefix in environment variable

#

I have to move it from there

high crown
errant flax
lyric mountain
#

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

torn blaze
#

hey i am new to python and i dont even know how to setup the pyhton in pycharm can anyobody teach me a little.

errant flax
earnest phoenix
#

anyone know any reliable VPSs?

rose warren
#

I also recommend Pulseheberg

earnest phoenix
earnest phoenix
urban slate
#

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

urban slate
#

@rose warren

rose warren
#

ty

urban slate
#

np

earnest phoenix
#

anybody help me to fix a python code

#

Thats showing

velvet night
#

First of all, did you enable the applications.command scope from the oauth2 page?

urban slate
#

yo anyone knows any good apis for quotes by tag?

#

free cause

eternal osprey
#

is there a way to ping a role and assign it to a variable?

#

Like message.roles.mentions.first() or anythin

urban slate
#

that

#

litreally

eternal osprey
#

ah never though that this was a thing!

#

Thank you

urban slate
#

let user = message.mentions.members.first()

#

this is what i used

#

but

#

instead of members you can use roles

eternal osprey
#
 let targetuser = message.member.mentions.first()```cannot read property first of undefined?
#

owh lmao i did i wrong

#

@rose warren

urban slate
#

did u fix it? @eternal osprey

eternal osprey
#

how would i actually enter that [[entries]] part

urban slate
#

soo normally we can do role.members

#

but i am not sure cause i have not done stuff like this with roles before

signal estuary
#

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.

ancient nova
#

can anyone help me with sum

eternal osprey
#
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?
tawdry oracle
#

what is the difference between fetchAllMembers client option and the GUILD_MEMBERS intent?

ancient nova
#

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

hybrid cargo
hybrid cargo
ancient nova
#

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

hybrid cargo
#

Or u can just make a function and check if it's undefined. If yes return what u want

ancient nova
#

it's in an enclosed function can't make that

tawdry oracle
tawdry oracle
# hybrid cargo No

and is there a way of only listening to guild join/leaves? and not other member updates?

hybrid cargo
#

like guildMemberAdd guildMemberLeave and guildMemberUpdate

#

Read the docs and use the events which you need

tawdry oracle
#

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

rose warren
#

Are you using djs v13?

tawdry oracle
#

yes

rose warren
#

You can leverage your caching options then

tawdry oracle
#

the small bot is using like 700mb with only 70 guilds or so

rose warren
#

Or use another js lib like djs-light

tawdry oracle
#

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,```
signal estuary
#

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?

signal estuary
boreal iron
#

embed.title = null;

earnest phoenix
#

.setTitle("hii");

signal estuary
signal estuary
boreal iron
#

No your editing the object directly

earnest phoenix
#

Is there any python dev?

signal estuary
rose warren
livid jackalBOT
#

@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.

earnest phoenix
boreal iron
#

(object structure)

upper moss
earnest phoenix
#
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

signal estuary
#

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

hybrid cargo
#

U did not return if the condition is not satisfied

signal estuary
#

Oh ok

signal estuary
hybrid cargo
#

What is msg

#

Cause it looks like you are using 2 diff functions

tulip ledge
#

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

signal estuary
tulip ledge
#

wdym

signal estuary
#

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 });
}
tulip ledge
#

alright

#

and with react to another user you mean the collector gets run?

gritty pebble
#

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()
tulip ledge
#

don't u have to do

createMessageCollector({
  filter: msgCol,
  max: 1
})
gritty pebble
#

nvm i found the error, it was using bot when my default is client, derp :p

ancient nova
#

how to do you parse xml to json

#

tf

tulip ledge
#

yes

#

because if you do

{
  msgCol,
  max: 1
}

You shorthand it so it looks like:

{
  msgCol: msgCol,
  max: 1
}
signal estuary
#

let me check

tulip ledge
#

But the createMessageCollector function needs an object which includes filter

signal estuary
#

works lol thx @tulip ledge

tulip ledge
#

np

signal estuary
# 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
tulip ledge
#

log f

#

and debug through that way

errant flax
#

is it possible to have a mobile status for a bot?

vivid fulcrum
#

yes

#

when sending IDENTIFY payload set the $browser property to "Discord Android"

high crown
#

excuse me

eternal osprey
#

is there a way to see the most recent user who left a role?

earnest phoenix
#
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

#

?

ancient nova
#

anybody know how to parse xml and make it json?

high crown
eternal osprey
high crown
#

when the member changes userame

high crown
ancient nova
#

okay how do you fetch xml, and parse it?

#

simple data.something won't work like json woulda

high crown
#

aah

#

u need db

#

and mine is fucking shit

swift cradle
#

idk js, but dont use json as a db, use a proper db

high crown
#

hey

#

I'm not able to make per server prefix command

rich copper
#

We can make music bots right

high crown
#

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

rich copper
#

Yeah and if I don't use youtube API youtube cannot warn me right

swift cradle
rich copper
#

Okay

high crown
#

can anyone pls help

#

i'm not getting any error

rich copper
#

So discord is not doing anything about music bots

high crown
#

but it is simply not working

swift cradle
swift cradle
rich copper
#

@earnest phoenix okay

#

@swift cradle dismusic

rich copper
#

@high crown I don't know java

#

I can help in python

high crown
#

js*

#

ah

rich copper
#

Even idk js

#

Js means java script right

high crown
high crown
rich copper
#

@high crown lol

high crown
#

poison

#

spelling op

rich copper
#

@high crown idk java and java script

high crown
#

yes yes

rich copper
#

@earnest phoenix @swift cradle custom prefix is not needed for a bot right

swift cradle
high crown
#

it is

swift cradle
#

no

high crown
rich copper
#

But I don't know that it uses youtube

swift cradle
high crown
#

but it will work fine if u simply define it in main file

rich copper
quartz kindle
#

java and javascript is like car and carpet
they are 100% different

swift cradle
high crown
swift cradle
#

dont give answers if you dont know

high crown
high crown
#

I have made music bot

#

ok

swift cradle
high crown
#

so pls