#development

1 messages · Page 1926 of 1

slender wagon
#

ye

feral aspen
#

Input the ID as a string not an Integer.

slender wagon
#

f

pale vessel
#

It can get fucky if the ID is over the maximum safe integer

slender wagon
#

no wayyyyyyyy

#

bruu

#

i feel stupid now

pale vessel
#

I don't think Discord.js v13 likes IDs as numbers anyway

slender wagon
#

i am thinking of moving to ts

#

would it be better

feral aspen
slender wagon
feral aspen
slender wagon
#

i did it worked

feral aspen
#

Great.

slender wagon
#

thx both of u

delicate shore
#

Hi guys

#

I need help

#

Problem is

#

there is no error.

#

I have problem with my code for a Firefox extension, I tried debugging as well, in-fact I have been debugging from last 4 hours but still cannot figure out what the issue is.

delicate shore
delicate shore
delicate shore
slender wagon
#

what package are u using

split hazel
#

because 32 bit environments will fuck themselves

lunar cove
#
  client.user.setPresence({
    status: "idle",
    game: {
      name: "Send your Emote",
      type: "LISTENING"
    }
  });```Is this wrong ?
lyric mountain
#

Wouldn't be better to also send what error u got?

slender wagon
#
.setName('p')
        .setDescription('Post a message'),
        options: [
            {
              name: 'textId',
              description: 'Text Id.',
              required: true,
              type: String,
            }
        ],
    async execute(interaction) {

is there a reason why the bot aint showing me the options

lyric mountain
#

That syntax looks very wrong

peak mason
#

.addUserOption(options) maybe

proven lantern
#

i am editing a message and getting a 200 response, but the message isn't being edited

#
const axios = require("axios");
const discordTokens = require("../discord/discord.json");
const editMessage = async ({application_id, channelId, messageId, embeds}) => {
    const res = await axios.patch(`https://discord.com/api/v9/channels/${channelId}/messages/${messageId}`, {
        embeds
    }, {
        headers: {
            Authorization: `Bot ${discordTokens[application_id]}`
        }
    });
    console.log(res)
}
module.exports = editMessage;```
#

the message id and channel id are correct

#

the message is unchanged

#

is discord broken?

#

i have the manage messages permissions added for the bot

surreal sage
#

How can you make a function argument show properties from a other class?

#

Like for example the Discord.js message class

proven lantern
surreal sage
#

I'm aware but as class

#

Like for example

#

I want to run a function when the messageCreate event is called

proven lantern
#

put in class name instead of string

surreal sage
#

thanks!

proven lantern
#

here's an example

surreal sage
proven lantern
#

you might need to create the class in javascript

#

like a clone of the class

#

Discord.js uses typescript so im not sure what will happen there

#

the creator of json advises against using the class keyword

#

make classes like this js const x = function(spec = {}) { const {get, stuff} = spec; const publicFunc = () => { privateFunc(); }; const privateFunc = () => { console.log("hello") }; return Object.freeze({ publicFunc }) } const y = new x(); y.publicFunc();

cinder patio
#

Are you living in 2012?

#

there's absolutely no advantage to this

#

only makes your code messier

proven lantern
#

object.freeze makes it so you cant mutate the object

#

so no confusion about what the object is

cinder patio
proven lantern
#

do classes work exactly the same way as in java? i hope there is no confusion there

#

only classes needed are map and array

cinder patio
#

classes in javascript are just syntactic sugar and telling people not to use them is the same as telling them to write uglier code

proven lantern
#

classes are ugly. that just exposes it

cinder patio
#

beauty is subjective, though you'll have to make some very good arguments to make me see the beauty in the snippet you sent

proven lantern
#

you dont need to build classes and think that way

#

like you dont need to make a base class and extend it

#

and think of the whole structure up front

#

and get it wrong

#

Why is discord telling me it edited the message when it's not being edited

#

Is this endpoint broken? ```js
https://discord.com/api/v9/channels/${channelId}/messages/${messageId}

#

why discord!

#

can someone try editing a message with their bot?

const axios = require("axios");
const channelId = "";
const messageId = "";
const discordToken = "";
const res = await axios.patch(`https://discord.com/api/v9/channels/${channelId}/messages/${messageId}`, {
    embeds:[{title:"asdfad", description:"asdfasdf"}]
}, {
    headers: {
        Authorization: `Bot ${discordToken}`
    }
});
console.log(res)```
pale vessel
#

Isn't it js { data: { embeds :[{ title:"asdfad", description:"asdfasdf" }] } }?

#

Ah, never mind

proven lantern
#

yeah, not for the patch. that always tricks me too

quartz kindle
#

does axios.patch do json by default?

proven lantern
#

yeah

#

it was a permissions issue, but it wasn't returning an error

#

the bot should always have permission to edit it's own message

#

and if it doesn't discord should tell me

quartz kindle
#

weird

stiff lynx
#

How can I awaitMessages in a slash command?

solemn latch
#

probably best to not await messages unless you have the message content intent at this point. we are not too too far from it being required to get messages

lyric mountain
#

imagine the chaos that'll ensue after the lock

proven lantern
#

i cant wait

stray seal
#

What is better, Watchbot or Statcord for getting Status and stuff.

lyric mountain
#

discord hq after april

proven lantern
#

not anymore

stiff lynx
#

If I use the object in slash commands a partner message is too big

lyric mountain
#

ask for a file maybe

stiff lynx
#

the only way is to collect it

lyric mountain
#

a .txt file

stiff lynx
#

I want to code a partnership bot lol

lyric mountain
#

hmm...by "status" you mean "bot is online/offline"?

lyric mountain
#

about the bot right?

stray seal
#

What is better?

stray seal
lyric mountain
#

statcord ig

#

although I'd make my own tracker

quaint wasp
#

hey. This thing, returns me an array of objects.
I tryed to do <array>.length, but it returns undefined. js deleteAmount = await message.channel.messages.fetch({ limit: parseInt(args[0]) }) console.log(deleteAmount.length) returns: undefined

#

wait

#

nvm

stray seal
#

@lyric mountain so, which one would you use?

quaint wasp
#

I sent it but never logged it

stray seal
#

Ight

#

Imma use BOTH

#

xD

lyric mountain
#

I prefer not to use third-party whenever possible

#

such trackers are quite easy to make

#

most of it is just styling

stray seal
lyric mountain
#

yet another reason to try

stiff lynx
#

what are you guys talking 'bout?

lyric mountain
#

the only way to become a good coder is trying

stiff lynx
lyric mountain
#

just ask the user to embed a .txt file with desired partnership message

stiff lynx
stiff lynx
lyric mountain
#

embed as in attach a file

stiff lynx
#

and then how can I send this message to other servers?

lyric mountain
#

it's really just a styled json visualizer

lyric mountain
#

{"time": "data"}

stray seal
#

What are Shards?

quartz kindle
#

sharp pieces of something

#

a shard of ice, a shard of glass, a shard of discord

#

:^)

stray seal
#

On Discord Bots?

quartz kindle
#

yes

#

essentially, it lets you split your bot into multiple connections

stray seal
#

Do I need it?

quartz kindle
#

only if your bot is big

#

sharding is recommended at 1500 guilds and mandatory at 2500 guilds

quaint wasp
#

how do you find the everyone role in a server ?

#

ping in reply

#

never mind

quartz kindle
#

always mind

split hazel
#

SDA(TGHJIOQWÂŁENGWED()"Q{PTKWEAMLSKN235235231V(ÂŁW)Q%UIÂŁQ(F)

#
  • life of an operating system dev if you understand i will be happy
woeful pike
#

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

stray seal
lyric mountain
ancient yoke
#

Can I attempt to submit my bot on top.gg in it's "alpha" stage, or should I let other Discord users test it out to see if it works before apptempting to sumbit my bot?

wheat mesa
#

wtf this gif is 32mb lmfao

eternal osprey
#
let prop1;
let prop2;
let prop3
setTimeout(() => {
  de9 = true
}, 60000);
  const keys1 = Object.keys(carddatabase)
 prop1 = keys1[Math.floor(Math.random() * keys1.length)]
  g1 = prop1
  const keys2 = Object.keys(carddatabase)
   prop2 = keys2[Math.floor(Math.random() * keys2.length)]
  g2 = prop2
  const keys3 = Object.keys(carddatabase)
   prop3 = keys3[Math.floor(Math.random() * keys3.length)]
  g3 = prop3```how would i keep on generating till prop1 for exampele, is a property w/o an a in the name
#

i was thinking about a simple if statement and then a new generating

wheat mesa
#

You could just do like ```ts
const keys1WithoutA = Object.keys(carddatabase).filter(x => !x.includes("a"));
prop1 = ...

wicked pivot
#

I don't understand why it met me like that?

#

embeds[0].description: This field is required

wheat mesa
#

then you need a description

#

you're probably sending an embed with a blank description of some sort

wicked pivot
wheat mesa
#

¯_(ツ)_/¯

quaint wasp
#

hey, so for permission change in v13

#

now instead of KICK_MEMBERS

#

or BAN_MEMBERS

#

its like Permissions.FLAGS.SEND_MESSAGES

#

does it mean you only need to change and add permissions.FLAGS. infront of them or is it different for some other permissions?

#

Ping in replies

wheat mesa
quaint wasp
#

alright

round cove
#

Is it possible to put local images into an embed anymore?

lyric mountain
#

I guess so, just use the attachment://name.ext format

spark flint
round cove
#

Within the setImage method?

#

The embed sends fine with no errors but no image is with it. So that's why I ask.

delicate zephyr
#

shows you how to there ^^

round cove
#

Right.

#
    const attachment = new MessageAttachment(
      'assets/vivi_commands.png',
      'banner.png'
    );
    const embed = new MessageEmbed()
      .setTitle(`Hello World`)
      .setDescription('Going to make a tutorial here.')
      .setImage('attachment://banner.png');

    interaction.reply({
      embeds: [embed],
      attachments: [attachment],
    });``` Current code, which doesn't seem different from what the API docs want.
#

Is Discord trolling or soemthing lol

#

I absolutely cannot get this to work lmao.

delicate zephyr
#

but try importing the buffer of the file with fs

#

and pass that to MessageAttachment

#

and see if that works

#

kinda like this

#

where data = the files buffer

round cove
#

I created a normal buffer variable with node's buffer but I GUESS I can try FS

delicate zephyr
#

Oh

#
const attachment = new MessageAttachment(
  'assets/vivi_commands.png',
  'banner.png'
);

this technically wouldn't work?

round cove
#

Again I've tried this,

#

But I'll see if FS will work.

delicate zephyr
round cove
#

And I've done all sorts of paths

delicate zephyr
#

I'll whip up a test bot a sec and see if I can get it to work

round cove
#

yeah no

#

It can find the file and the file is there

#

It just doesn't send????????

short pilot
round cove
#

I HAD TO DEFER IT??

#

Discord just took ten years to receive the stupid image

#

Presumably because it's large.

delicate zephyr
#

I got it to work

#
client.on('message', async (msg) => {
  const data = await fs.readFile('./image.png')
  if (msg.guild.id === '817548193410580511' && !msg.author.bot) {
    const image = new discord.MessageAttachment(
      data,
      'banner.png'
    )
    const embed = new discord.MessageEmbed()
    embed.setImage('attachment://banner.png')
    await msg.channel.send({ embed: embed, files: [image] })
  }
})
#

you shouldnt have to defer it at all

#

you just have to attach it as a file to the message so the embed knows what file it is

round cove
#

I'm doing slash commands, Discord wanted it defered.

#

So unless you wanna test slash command for that too.

delicate zephyr
#

I do, and Ive been doing the same thing with the libless version

#

¯_(ツ)_/¯

round cove
#

Wonder what happens if I give it an image that isn't 40320420mb

quartz kindle
#

generally speaking, you should always defer if your code is async

#

because usually you wont have control over how long async things like files and networks will take

delicate zephyr
#

I mean fair

round cove
#

Yeah it's the size of the file that was the issue.

#

Also fs methods aren't async methods so unless I sleep the program

delicate zephyr
#

they can be?

quartz kindle
#

i mean

delicate zephyr
round cove
#

Can deferring have raceconditions?

quartz kindle
#

fs is i/o bound, so its either async or blocking, both of which should be deferred

round cove
#

I thought deferring means it has to take more than 3-5 seconds?

#

Or was it just if it does take that long you have to defer.

quartz kindle
#

interactions are like a webhook that discord sends to you. they make a request to you and wait for a response, so to not keep them waiting too long, they abort the request after 3 seconds

#

so you have 3 seconds to respond to the request they make

round cove
#

Ah.

quartz kindle
#

if you dont know how long your code will take to generate a response, its better to give them an immediate response and then follow it up later

#

thats what deferring is

round cove
#

Right.

#

Then yeah. I guess in this case with variable image sizes I probably should just defer.

#

Alright thanks for explaining guys. I never actually took the time to understand the new interaction stuff ;p

lyric mountain
#

I mean, not even discord understood 'em yet

quaint wasp
#

..

#

How the heck do you check perms now in Discord.js ?

#
ReferenceError: Permissions is not defined
    at Object.execute (C:\My Projects\ella\v13-ella-main\v13-ella-main\commands\settings\setmute.js:8:54)```
#

permissions.has still gives of the same error

round cove
#

Did you import Permissions lol

quaint wasp
#

?!

#

Isnt it litilary built in tho?

#

still need help solving the problem btw

earnest phoenix
#

help plz

#

how to fix it*

#

when i just start

#

it shows this msg

quaint wasp
#

create a script -_-

earnest phoenix
#

yeh

quaint wasp
#

in package.json

earnest phoenix
#

i ahve

#

have*

quaint wasp
#

or.. whatever your main file name is.

#

yep.

#

if can simple use node . if you just specify the path from json to the main file and it will autmaticly start that file

#

u can use npm

earnest phoenix
#

see

quaint wasp
#

if u add the script

#

add "start": "node ." in scripts

earnest phoenix
quaint wasp
#

then try npm start and it should start the program.

earnest phoenix
quaint wasp
#

? no

#

its a script

#

so.. no

earnest phoenix
#

so where?

quaint wasp
#

or at least I've never tried so

#

lol

earnest phoenix
#

under test?

quaint wasp
#

yeah

earnest phoenix
#

yeah ok

quaint wasp
#

under or on top of tests

earnest phoenix
quaint wasp
#

oh lolll

#

hover over it

#

it should give u the error

earnest phoenix
#

yeah

quaint wasp
#

try to solve it your self, if no work than ping me

earnest phoenix
quaint wasp
#

alr.

#

just add ,

boreal iron
#

Not needed to add node . as script
node . will call the value of the key "main" in your case index.js

quaint wasp
#

after test

quaint wasp
earnest phoenix
#

done

quaint wasp
#

👍

#

try now

earnest phoenix
boreal iron
#

Which will call node .

earnest phoenix
#

working

quaint wasp
#

yep.

boreal iron
#

Which you can call directly

quaint wasp
#

wait...

#

nvm

#

if you call it something like A it will be 👍

round cove
#

Yikes.

quaint wasp
#

I would like to ruin that and ask how tf do I check perms

boreal iron
#

cmd /c cmd /c cmd /c notepad.exe

round cove
quaint wasp
#

what packagee

#

the discord.js it self?

round cove
#

yes

quaint wasp
#

oh........

#

rapidly checking the upgrading from v12 to v13 docs..

round cove
#

import { Permissions } from 'discord.js';

quaint wasp
#

this ?

round cove
#

You still have to import it.

#

Or require

quaint wasp
#

also...

#

is it required to have the P and FLAGS in full cap bc when I was changing it I accidently changed all of em to just low..

round cove
#

Well yeah.

quaint wasp
#

welp.... there goes me wasting onather 30 minutes of my life fixing onather (out of multiple today) mistake.

#

welp that was quick..

round cove
#

Assuming you know that args is a string array then yes you can do args[0].toLowerCase()

#

Locale is localization

#

Like your language.

boreal iron
round cove
#

You're not in a browser so it doesn't matter.

round cove
#

They were clearly asking fi they could lowercase them.

boreal iron
quaint wasp
round cove
#

You can do Discord.Permissions if you require the whole package as Discord

quaint wasp
#

alright

#

thanks

boreal iron
#

Which database?

#

For SQL either using SELECT count(*) FROM database using count as property of the result or just accessing num_rows which should be part of the result

quaint wasp
#

hold up- dont say I also need the perms thing for this bc its not built in to the thing..

#

It wouldnt make since tbh.

boreal iron
#

me represents a guild member which can be checked for permissions, so nothing wrong with it

#

But something is completely wrong regarding the indentation

delicate shore
#

I keep getting this error on Mozilla but my code works fine on chrome

#
browser.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
  // read changeInfo data and do something with it
  // like send the new url to contentscripts.js
  if (changeInfo.url) {
    browser.tabs.sendMessage(tabId, {
      message: "progressbar",
      url: changeInfo.url,
    });
  }
});

Line which is getting the error:

    browser.tabs.sendMessage(tabId, {
earnest phoenix
#

and I have 69 brain cell

if (/^discord$/i.test(args[0]));
whole surge
#

hey anyone wanna help me in making About Us content?
dm me

stiff lynx
#

I want to do a send in all server command where:

-User: /command
-Bot: 'Send the test that you want to share'
-User: Text
-Bot: 'Text received and send '

But I don't get how to do it

earnest phoenix
#

that'll get you rate limited

#

pls someone send me code to leave all guilds

#

of python

#

this is not stackoverflow

stiff lynx
earnest phoenix
#

you're sending a message to every single guild the bot is in

stiff lynx
#

This is what I want to do

#

not every single guild, the guild that saved data of a channel in mongo

little anvil
#

pika

earnest phoenix
#

chu

little anvil
#

mew

earnest phoenix
cinder wasp
#

how to do this?

nova basin
#

Help me pls

earnest phoenix
slender thistle
earnest phoenix
pale vessel
earnest phoenix
#

ok idk

#

thats why i quit coding

cinder wasp
#

lol

stiff lynx
#

wot lol

slender thistle
earnest phoenix
#

and i will be back to discord when i learn coding nicely

earnest phoenix
cinder wasp
#

whats the error

#

?

earnest phoenix
cinder wasp
#

code?

#

command?

#

what u trying to do

slender thistle
#

An instance of discord.Client contains a property guilds, which is a list of Guild instances. Those Guild instances have a .leave() method.

cinder wasp
#

oh u want to leave all the guilds?

#

from ur bot?

slender thistle
#

So, if you want to leave ALL guilds your bot is in, you want to iterate over <Client>.guilds where <Client> is an instantiated Client, and then call .leave() on every item. Keep in mind that it is a coroutine, so you will have to await it.

earnest phoenix
#
i want my bot to leave all the server it is in 
and i dont wanna delete it
slender thistle
#

Did you read/understand what I explained?

nova basin
# nova basin Help me pls
const fs = require('fs');
const guilds = require('../data/guilds');

const commands = new Map();

const fileNames = fs.readdirSync('./commands');
for (let fileName of fileNames) {
  const Command = require(`../commands/${fileName}`);
   const command = new Command();
  if (!command.name) continue;

  commands.set(command.name, command);
}
console.log(`Loaded ${commands.size} commands`);

async function handleCommand(msg) {
  const savedGuild = await guilds.get(msg.guild.id);
  const prefix = savedGuild.general.prefix;

  const channelIsBlacklisted = savedGuild.general.blacklistedChannelIds.includes(msg.channel.id);
  if (channelIsBlacklisted) return;

  if (!msg.content.startsWith(prefix)) return;

  const name = msg.content
    .split(' ')[0]
    .slice(prefix.length);

  const args = msg.content
    .split(' ')
    .slice(1);

  const command = commands.get(name);
  try {
    await command?.execute(msg, ...args);
  }
  catch (error) {
    await msg.channel.send(`⚠ ${error?.message ?? 'Unknown error.'}`);
  }
  return command;
}

module.exports.handleCommand = handleCommand;
module.exports.commands = commands;  
slender thistle
#

What does ```js
require(../commands/${fileName});

return?
nova basin
earnest phoenix
#

huh

earnest phoenix
#

i just wrote my own code and it worked

cinder wasp
earnest phoenix
#

i wrote my own

#

bruh

#

it left 125 servers in just 5 sec

#

so bye bye

slender thistle
# earnest phoenix i didnt understood anything
client = discord.Client()  # Instance of Client

# It is optimal to use the on_ready event for leaving all guilds your bot is in.
# However, it is possible to do it via a command.
@client.event
async def on_ready():
    # Each element in client.guilds is a Guild object. We will simply use a variable `guild` to "point at it".
    for guild in client.guilds:
        # Every `Guild` object has a .leave() method that, as you could've guessed, leaves the guild the object points to.
        # Once you call the method, you need to await it.
        await guild.leave()
cinder wasp
#

nice

#

i also got that though

slender thistle
#

Abstracting away the part with running...
... welp.

earnest phoenix
#

thats my code

slender thistle
#

Well, that works too, I guess

earnest phoenix
#

yep

#

its 0 server now

#

i am leaving all servers too

stiff lynx
#

In a database I've stored guildId and a channel Id how con I send a message in the channel of all the guild stored?

boreal iron
#

Select and query all the guilds you need, loop through the result and send a message to the channel each iteration of the loop

#

But keep in mind mass messaging may be considered as spam

stiff lynx
#

but how I extract the documents from the database?

earnest phoenix
#

I want to set my category on the top but the category has been set on the bottom.. is not position 1 ?

brisk lance
#

can anyone help me to integrate my bot with a rest api

#

I am using nodejs

#

if anyone know how, ping me

stiff lynx
brisk lance
#

bruh

#

an api which can be consumed using http requests like get,post etc

boreal iron
#

Well log your args and see

delicate zephyr
#

just do if args.length < 1 return sendmessage('give me argus you dingus')

#

what

#

thats like

#

the actual way to do it?

#

if there are no args

#

youre going to run into issues

#
if (args[0]?.toLowerCase() === "discord" && args[1]?.toLowerCase() === "moderator") {
#

would also work

boreal iron
#

You can, yes

stiff lynx
# boreal iron That depends on your database
  {
    _id: new ObjectId("619a30fed932cbdf8a2925bb"),
    serverID: '846752749555286027',
    channelID: '910152861277650964',
    userID: '658234646932357140',
    __v: 0
  },
  {
    _id: new ObjectId("619b7a694d9214c7ba798b1a"),
    serverID: '757896200320974899',
    channelID: '838769630960812093',
    userID: '658234646932357140',
    __v: 0
  }
]```

Extracted, now how can I send  the same messages in this 2 channels?
boreal iron
stiff lynx
boreal iron
#

for(const item of array)
{
console.log(item.channelID);
}

stiff lynx
#

sorry 😩

stiff lynx
#

something like this?

boreal iron
#

Not need to overcomplicate things

#

Just use a for of loop

#

As I wrote

#

array is your result and you can call the var row whatever you like

rancid token
#

How can I do this part, but I'm having this problem because I searched for this feature but I can't find it

stiff lynx
#

in guildMemberAdd event how can I check if the member is a BOT?

if(member === bot) return?

delicate zephyr
#

member.bot

quartz kindle
#

member.user.bot

earnest phoenix
delicate zephyr
#

dunno then

boreal iron
#

@quartz kindle 8 hours wasted of using sqldump directly to the remote location, inserting only 256 million rows in that timeframe

earnest phoenix
#

what in the actual fuck

boreal iron
#

Im really gonna give rsync a try

quartz kindle
#

xD

earnest phoenix
#

what was in your db that needed 256000000 rows

quartz kindle
#

his db is like 6 billion rows

boreal iron
#

Turns out watching the process list sqldump sends a fucking single insert request for every row

#

4 Billion

quartz kindle
#

xD

earnest phoenix
boreal iron
#

Figured out rsync can sync to remote locations, too

#

Let’s hope that’s faster

#

According to the docs I’m okay with just moving the database folder for InnoDBs or MyiSAM

stiff lynx
#

How can I check if the interaction.user is inside my support server?

I want to do this command in every guild, but you can execute it only if u r inside my support server

boreal iron
#

Well then register the command only in your guild

#

But displaying commands globally if you can’t use them seems nonsense

stiff lynx
quartz kindle
#

get the user id for the interaction

#

get the guild object for your guild

#

check if guild.members.fetch(userid) works or throws an error

stiff lynx
#

something like this?

quartz kindle
#

.cache.get()

boreal iron
#

Also userid doesn’t exist

quartz kindle
#

const member = await guild.members.fetch(user).catch(() => null)

boreal iron
#

Since you defined it as user

stiff lynx
stiff lynx
quartz kindle
#

yes

#

fetch is a promise, so it has to be awaited

#

if the user is not found, it throws an error, so you have to catch it

stiff lynx
lyric mountain
#

I saw that catch null

lunar cove
#

How can I change channel name ?
I created a bot which displays total bans in status, now I would like to show that as channel name instead of status as I would like to add another channel for kick count too

stiff lynx
#

KuuHaKu this seems correct?

quartz kindle
#

it will work

#

because console.log returns undefined, so the !member check will work

quartz kindle
#

so you'll be limited to updating it very slowly

lunar cove
quartz kindle
#

for a particular channel

lunar cove
#

I would be fine with it being updated every 5-10 minutes

quartz kindle
#

if you're using discord.js pretty sure channels have a .setName() method

lunar cove
#

Ohh lemme check the docs once

lunar cove
quartz kindle
#

you dont need to fetch channels, unless you manually disabled channel caching

quartz kindle
#

edit() is the base method, setName() uses edit() internally, its just a shortcut

lunar cove
#

Ohh, so how can I get the channel object so I can apply this method on it ?

quartz kindle
#

yes

lunar cove
#

Umm, how can I get it ?😅

#

message.channel needs message to be sent, what I'm trying is to automatically update the channel name every 10 minutes.

PS : I would be using Voice Channel for this

#

Ohh I will try this

#

But this would return boolean , right ?

#

Yep

boreal iron
lunar cove
boreal iron
#

The parameter is a boolean

#

MY GOSH

#

IT RETURNS A CHANNEL PROMISE

quartz kindle
#

lmao

lunar cove
#

ohh

#

😅

quartz kindle
#

you dont need either of that

#

just use client.channels.cache.get(channelid)

lunar cove
boreal iron
#

Yeah channels are cached anyways

lunar cove
#

Thanks everyone it worked !!
Especially tim msh_hughug

pale vessel
#

did you just spoil tensura to me @lunar cove

#

oh my god

pale vessel
#

can people put normal names and not those characters

#

it makes me google them

#

and I get spoiled

boreal iron
#

did you just spoil tensura to me

Please speak in an human understandable language!

lunar cove
#

One last thing, I want to have a similar channel for kicks too, ban was easy, I got the hang of it using docs, bans are stored in discord so we can get them.

For kicks I plan to detect the kick and then keep the count in database. But how can I get the trigger for kick ?

boreal iron
#

When you kick the member yourself or just by listening to if somebody got kicked?

#

The event guildMemberRemove contains the guild member object.

lunar cove
#

By bot

boreal iron
#

There's a property for guild member objects called deleted

#

Whether the member has been removed from the guild

#

That might be true if someone has been removed (not left)

lunar cove
#

Ohh saw that

#

And in case he left ?

#

false

boreal iron
#

Probably

lunar cove
#

Also this will then have banned members included too ?

boreal iron
#

Test it out, I'm not sure but I guess so regarding the description

#

There's an own event for banned members

lunar cove
#

Yeah I used that already, but if it includes bans, I would need to subtract bans from this to get kicks

boreal iron
#

Not sure if both events being fired

#

Create a listener for both events and ban a member and you will know

lunar cove
#

Let me try that

boreal iron
#

Just 4 files to move, Tim
Let's see if rsync can do the job at an acceptable speed

boreal iron
#

That's a lot faster than generating it or dumping the old to the new one

#

should have done that in the first place

quartz kindle
#

xD

boreal iron
#

the speed is just weird... should go up to 65MB in theory

#

but stuck at < 20 MB

#

est 7h for the smaller file

#

at least it seems to be reliable

#

OH OH OH MOVING TO 30 MB/s

#

ahhh nvm

quartz kindle
#

xD

#

welp, it depends on the files being transferred and the transfer options, as well as disk speeds and network speeds

#

it probably also has the overhead of a few checks and controls

#

plus the transfer protocol it uses

boreal iron
#

prioritized the server as real time tranfer in the router, helps a littble bit

sudden linden
#

đ™đ˜Ÿ äčˆ Glitch Editz, You just leveled up to level 1!

grim aspen
#

@rose warren

quartz kindle
#

wtf

boreal iron
#

great

quartz kindle
#

lmao

boreal iron
#

he level up himself

grim aspen
#

confirmed selfbot

boreal iron
#

Let's pray the ISP can keep up my internet for the next, hmm 16h

quartz kindle
#

rsync should support resuming

boreal iron
#

ahh good to know

delicate zephyr
alpine niche
#

...

boreal iron
#

Should have started the process in screen freerealestate

#

imagine accidentally closing the command prompt

solemn latch
#

Tf

#

I didn't send that

boreal iron
#

selfbot

#

Ban incoming, Woo

earnest phoenix
#

Imagine my bot has 5K of servers and each server has a "Test" channel.
If my bot EDIT every day at 00:00 the show name for all servers, will it be rated?

boreal iron
lunar cove
#

Btw I found out this is discord.js guidebook ```js
client.on('guildMemberRemove', async member => {
const fetchedLogs = await member.guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_KICK',
});
// Since there's only 1 audit log entry in this collection, grab the first one
const kickLog = fetchedLogs.entries.first();

// Perform a coherence check to make sure that there's *something*
if (!kickLog) return console.log(`${member.user.tag} left the guild, most likely of their own will.`);

// Now grab the user object of the person who kicked the member
// Also grab the target of this action to double-check things
const { executor, target } = kickLog;

// Update the output with a bit more information
// Also run a check to make sure that the log returned was for the same kicked member
if (target.id === member.id) {
    console.log(`${member.user.tag} left the guild; kicked by ${executor.tag}?`);
} else {
    console.log(`${member.user.tag} left the guild, audit log fetch was inconclusive.`);
}

});``` to record kicking a member.

Here I wonder if there's a raid and auto-kick starts, will it be able to record that fast or will miss some entries ?

opaque seal
lunar cove
#

Umm, may I know the advantage of that ?

delicate zephyr
opaque seal
#

What does the msg look like?

lunar cove
delicate zephyr
boreal iron
delicate zephyr
boreal iron
#

Hmm did you disable mentions in your client options?

delicate zephyr
#

i'm not using discord.js

#

just so ya know

#

I'm using no lib

#

just based http requests

#

hence why im confused

boreal iron
#

Hmm why do you actually need to ping the user if it’s supposed to ping everyone anyways?

delicate zephyr
#

it's not pinging everyone

#

I need it to ping that specific user but it's not working even without that object

boreal iron
#

Hmm then add parse: ["everyone"] to the object

#

To see if that even pings somebody

#

Or better

delicate zephyr
#

nope

boreal iron
#

parse: ["everyone", "users"]

delicate zephyr
#

nope

boreal iron
#

Hoe wtf

#

Not sure then

#

Saw people complaining about the same issue days ago

lunar cove
#

Umm, how can I record kicks using that ?

boreal iron
delicate zephyr
boreal iron
#

Ah nvm

#

According to the docs anything is right

#

But parse can’t contain users, if you specify users as I can see now

solemn latch
boreal iron
#

you knew that would happen

lunar cove
#

Umm, I can't find something related to that, is that even possible ?

boreal iron
#

What about the events we were speaking about before?

quartz kindle
#

there is no way to differentiate a kick from a leave, unless you check audit logs

boreal iron
#

What does the property deleted mean then?

quartz kindle
#

that the object is still in the cache for some reason

#

even though its not in the api anymore

boreal iron
#

ah okay

quartz kindle
#

or if you hold a reference to it in a variable for example

boreal iron
#

yeah makes sense

delicate zephyr
#

they dont support pinging after a defer

#

just like they dont support after an edit

boreal iron
#

Ah okay, damn didn't thought about that one

#

I had that issue myself lol

#

Needed to figure out, too I had to specify the message options when deferring the message as well

quartz kindle
#

you cant ping people when you defer? lmao

boreal iron
#

Ah you can

#

But you need to specify it in the options when deferring the message

#

Adding the ping later when editing the initial message, doesn't work

#

Same goes for ephemeral messages

boreal iron
#

Yee I got the same issue

#

one sec

delicate zephyr
#

what options do I have to pass to the deferred message

boreal iron
#

did defer the interaction via. deferReply() and was wondering why ephemeral: true as message option was ignored later via. editReply()

#

Found out a while of trying the message options need to be applied when deferring the reply, not in the reply itself

delicate zephyr
#

yea but with regards to pinging tho

#

even then it still wont ping you?

boreal iron
#

errr... sending the message option in when deferring doesn't work for pings?

delicate zephyr
boreal iron
#

deferReply({ allow_mentions: ... })

delicate zephyr
#

not by the looks of it

boreal iron
#

lemme test it real quick

delicate zephyr
#

because they're treating deferring as a edit

boreal iron
#

Oh yeah I see there's no message option regarding mentions

#

Doesn't support base message options

delicate zephyr
#

yup

boreal iron
#

Well then defer the reply and send a follow up message and remove the inital message at the same time

#

follow up messages support mentions

delicate zephyr
#

that's just irritating though

boreal iron
#

yeah indeed

delicate zephyr
#

Guess I'll just have to keep it how it is until discord make it so you can ping in a deferr

boreal iron
#

I wonder why that's not supported anyway

delicate zephyr
#

same

boreal iron
#

If something takes a while anyways a ping is a good idea if it's done

quartz kindle
#

it should be

#

unless its a bug

delicate zephyr
#

Seems like a bug

quartz kindle
#

the docs clearly show allowed_mentions as a valid field in an interaction response object

delicate zephyr
#

because I cant get a deferred message to ping

boreal iron
#

Lemme check the dev docs again

quartz kindle
#

does the mention work properly?

#

it just doesnt ping?

delicate zephyr
#

Yep

boreal iron
#

hmm

#

While interaction responses and followups are webhooks, they respect @everyone's ability to ping @everyone / @here . Nonetheless if your application responds with user data, you should still use allowed_mentions to filter which mentions in the content actually ping. Other differences include the ability to send named links in the message content (text).

#

No word about deferred messages

delicate zephyr
#

Following up a deferred message uses the /webhooks/ endpoint

#

(I will be cleaning this up before you scree)

boreal iron
#

The allowed_mentions field of the edit request controls how this happens. If there is no explicit allowed_mentions in the edit request, the content will be parsed with default allowances, that is, without regard to whether or not an allowed_mentions was present in the request that originally created the message

#

So.. it should be supported, yeah

delicate zephyr
#

but it's not working?

boreal iron
#

Tim is probably right, seems to be a bug then

delicate zephyr
#

am I gonna have to like contact a ddev then wearyfire

boreal iron
#

Tell them you want some cash before sharing a major game breaking bug

delicate zephyr
#

no

#

lol

boreal iron
#

I also wonder how long it still takes until they push slash command nesting

#

I mean April is not that far away anymore

wooden ember
#

anyone know how you would change a channel name in d.js?

boreal iron
#

anyway... can confirm it's not working for me, too

glacial vapor
#

almost ran out of hours so i had to add a CC to get those extra 450 hours per month lol

boreal iron
#

money to rent a server will solve all your issues

glacial vapor
#

thats true

#

but without money its hard

quartz kindle
#

google's free tier is way better than heroku btw

boreal iron
#

well if there's no reliable "friend" you can host your stuff, yes it is

glacial vapor
#

isnt the google free tier just a free trial

wheat mesa
#

oracle's free tier is way better than heroku

#

always free

boreal iron
#

And there's the Java user again

#

Promoting Java services

wheat mesa
#

I don't use java I swear!

glacial vapor
small tangle
lunar cove
#

when compared to AWS

quartz kindle
wheat mesa
#

it's always free, 24/7

glacial vapor
#

im unable to use AWS free tier because it requires bank verification with my card

lunar cove
#

But how's the setup complexicity and uptime ?

wheat mesa
#

if you go over the limit for bandwidth it just shuts off instead of charging you

cinder patio
#

"free forever" and "bonus 12 both free trial" don't make much in the same sentence lol

lunar cove
sharp bridge
#

any1 knows why this line of bug gives me an error? im new to bot developing and i followed a guide on yt but cant understand my mistake.

client.run(os.getenv('TOKEN'))

quartz kindle
#

they give you 300 bucks worth of credits that expire after 12 months, you can use them for anything. after they expire, you can continue using the free forever stuff

lunar cove
#

Btw in your opinion oracle/AWS/Heroku and then comes Replit/GLitch, which one is good for small single server bot ?

earnest phoenix
lunar cove
#

Better performance ?

delicate zephyr
#

@quartz kindle @boreal iron turns out it's treated as an editted message in the api backend

earnest phoenix
#

use a free host then move on to a paid one

sharp bridge
#

i made a new class and said TOKEN = (token) isnt that considered definding?

earnest phoenix
earnest phoenix
#

in a separate env file

lunar cove
boreal iron
delicate zephyr
#

Just asking in ddevs

lunar cove
boreal iron
delicate zephyr
#

but yea

quartz kindle
delicate zephyr
#

I'm writing a feature request now

lunar cove
delicate zephyr
#

Nah, I got pissed off with interaction followups

boreal iron
#

Yeah that's not really a solution, just useless work

sharp bridge
lunar cove
#

Tim / FakE ?

boreal iron
#

huh what? I didn't follow your messages

delicate zephyr
boreal iron
#

👍

lunar cove
#

SO that lead to me asking this

So should I increase the limit to avoid the api limits violation ?

delicate zephyr
#

you wont hit an api violation

#

just abide by ratelimits and you'll be fine

lunar cove
delicate zephyr
#

technically d.js does it for you

lunar cove
#
client.on('guildMemberRemove', async member => {
    const fetchedLogs = await member.guild.fetchAuditLogs({
        limit: 1,
        type: 'MEMBER_KICK',
    });
    // Since there's only 1 audit log entry in this collection, grab the first one
    const kickLog = fetchedLogs.entries.first();
    // Perform a coherence check to make sure that there's *something*
    if (!kickLog) return console.log(`${member.user.tag} left the guild, most likely of their own will.`);
    // Now grab the user object of the person who kicked the member
    // Also grab the target of this action to double-check things
    const { executor, target } = kickLog;
    // Update the output with a bit more information
    // Also run a check to make sure that the log returned was for the same kicked member
    if (target.id === member.id) {
        console.log(`${member.user.tag} left the guild; kicked by ${executor.tag}?`);
    } else {
        console.log(`${member.user.tag} left the guild, audit log fetch was inconclusive.`);
    }
});```Code
boreal iron
#

You could either fetch them frequently or just fetch them if you receive a guildRemoveMember event

delicate zephyr
#

it has ratelimit logic built it

lunar cove
#

In case of raid will the ratelimits be hit ?
Like kicking100 accounts in a minute ?

lunar cove
boreal iron
#

Banning should be a different event

lunar cove
#

sorry I meant kicks

boreal iron
#

You said you wanna try that out

lunar cove
#

Ban is easy

boreal iron
#

it has ratelimit logic built it

lunar cove
#

I can't test a raid 😅

boreal iron
#

djs should queue your requests in case of a rate limit iirc

lunar cove
#

Ohh cool, so I won't have any issues of rate limit and nor the issue of missing something

boreal iron
#

usually not, no

lunar cove
#

Thanks

#

Btw anyone here used Railway for free hosting?
https://railway.app/

Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

wheat mesa
#

seems like it's not very good at all

#

(For free tier at least)

lunar cove
# wheat mesa (For free tier at least)

I actually use replit rn, but the code is public so I want to shift, and guild size is just 600 so I don't wanna buy a paid VPS/hosting also I'm learning so it's best to do on free ones

wheat mesa
#

yeah but that free tier is probably even worse than replit lol

#

use a free tier like google or oracle

lunar cove
pale vessel
#

A year is quite a long time

boreal iron
#

at least to grow and figure out new options later on

quartz kindle
#

google has a free forever machine with 1gb ram

#

but it charges for network usage above 1gb per month

#

after the 12 months expire

#

plus some tax depending on the country you're from

lunar cove
quartz kindle
#

i was paying like 10 cents per month

#

when i was on google

lunar cove
#

for network charges ?

quartz kindle
#

yes

lunar cove
quartz kindle
#

at that time it was like 1500 servers

lunar cove
#

Damn !!

#

I will try google then, but ain't oracle offering looks better, may I know why you avoided it ?

solemn latch
#

iirc oracle has canceled others VPS's without notice, some have mentioned being charged unexpectedly

lunar cove
#

ohh so google is safe

earnest phoenix
lunar cove
quartz kindle
#

google's has 2 cpus now, oracle only has 1

#

also oracle wasnt a thing yet back then

#

and google's only had 500mb ram when i was using it

#

now they upgraded it to 1gb ram and 2 cpus

wheat mesa
earnest phoenix
# lunar cove where ?

no, i was talking about the image, they asked that in the verification process but idk

wheat mesa
#

I wouldn't use oracle for anything other than free tier tbh

lunar cove
quartz kindle
#

yes

#

its a fractional cpu tho

#

you have 2 cpus, but they are shared with other machines, they are not dedicated cores

boreal iron
quartz kindle
#

still way better than many other things like glitch heroku

lunar cove
#

Hey noob question but can I have two client.on() ?

earnest phoenix
#

i have a lastUsed timestamp, i have to check if the user last used 30 days ago and is not in a server with the bot and delete his data. I need a structure

quartz kindle
#

but its not good practice to have the same ones multiple times

#

use them for different ones

lunar cove
#

Nah like I have one for message , another for guildMemberRemove and so on

quartz kindle
#

yes

boreal iron
lunar cove
# quartz kindle yes

Also can you point me the link to that google one, homepage is looking confusing to me😅

wheat mesa
#

Not saying he's lying but seems a little bit suspicious that they would charge his card for no reason

#

They don't take payments through cards directly

#

They take payments through paypal

#

They only use your card to charge that $1 "verification" thing and refund it when you sign up

lunar cove
#

Google free tier also requires card info ?

quartz kindle
earnest phoenix
#

i don't know the part where i need to get the user and check if it's in a server because i have to check one by one all the lastUsed timestamps in the db and get only the 30d ones

wheat mesa
#

Like I said I wouldn't use oracle's VPSs for anything other than free tier

lunar cove
quartz kindle
#

i said 2 cpus, not 2gb ram

boreal iron
#

you already said a lot of stuff today

wooden ember
#

i know there is a limit on how many times you can change the name of a channel but it there a limit on how many diferent channels you can rename in a sertain amount of time?

#

cus i have a list of channel that get renamed based on wether a server is online or not but idk how to slow down a for loop

solemn latch
#

youd likely want to test that yourself tbh, its very likely limited per guild

wooden ember
#

bruh

#

ok next question: how to slow down a for loop

solemn latch
#

that type of ratelimit is dynamic, meaning some bots get higher ratelimits than others

wooden ember
#

lol

solemn latch
#

probably will want to use an interval not a for loop

wooden ember
#

but you cant continuasly loop through an array though can you? only iterate through the values once

#

wait are you on about setinterval? cuz i thought that was removed in newer versions of d.js

solemn latch
#

djs has nothing to do with setinterval

#

setinterval is built into js

wheat mesa
#

^^

wooden ember
#

coulda swarn i saw they removed something like that in the patch notes or somthing

wheat mesa
#

that's a js thing

solemn latch
#

nah, they cannot do anything to that

wheat mesa
#

Nothing to do with djs

wooden ember
#

fair enough

solemn latch
#

I wonder if its possible to remove js features with a library 👀

#

no idea why you would do that, but still

proven lantern
#

it is

#

prototype langauge

#

only one

solemn latch
#

ultimate troll library, super useful in every way but remove some random feature of js

#

and dont document it

proven lantern
#

redux is kinda like that

#

but it tell you the rules

#

no mutation

solemn latch
#

ah

proven lantern
#

the first time i wrote reducers i had no idea what i was doing

#

its always good to study

#

that's what i learned

#

i could have saved so much time

wooden ember
#

mmm welp i looked through the docs and i cant see where it said they removed it

#

must have just read it wrong

#

but im sure it was there cuz it said setinteval and settimout where removed since the encouraged bad practice or something

quartz kindle
#

they removed it from the client

#

discord.js used to have its own client.setTimout and client.setInterval

#

that was tied to the client instance, so if/when you did client.destroy() it would also stop all the timeouts and intervals created with it

wooden ember
#

aaah fair enough

solemn latch
#

Right

wooden ember
#

ah redid the whole thing with setinterval and it works alot better thx guys

boreal iron
#

should be under engine

#

in package

blissful falcon
#

how do i make my bot need some perms when its invited? (nodejs)

blissful falcon
boreal iron
#

err wut?

boreal iron
#

LIMIT supports an offset

#

SELECT * FROM database LIMIT 11,10

#

how would i get number 11-20

lyric mountain
#

or SELECT * FROM database LIMIT 10 OFFSET 11 depending on db

earnest phoenix
#

How i can invite @pliant gorge bot to my server?

proud swift
#

i added my bot it was offline now online how can i add my bot again

earnest phoenix
#

Hi want too know which software good for coding chrome or Microsoft

earnest phoenix
#

Meant Computer application

wheat mesa
#

That's what an IDE is, but I'm not sure what you're asking

earnest phoenix
#

What is better IDE to do coding on

wheat mesa
#

Depends on what language you want to use

solemn latch
#

depends on your preferences too

wheat mesa
#

^

earnest phoenix
#

Am English

wheat mesa
#

No...

#

Programming languages

earnest phoenix
#

English

wheat mesa
woeful pike
#

10/10 troll

solemn latch
#

I've never heard of the English programming language

earnest phoenix
#

Am new too this

wheat mesa
#

we're speaking it rn wym

solemn latch
wheat mesa
#

If you don't have access to JetBrains IDEs, I'd recommend Visual Studio Community for C-style languages like C#, C++, C, etc, but for javascript/python I'd recommend Visual Studio Code

solemn latch
#

Visual studio code is pretty nice. No major complaints from me

wheat mesa
#

But if you have access to JetBrains IDEs then those are usually the way to go (depending on preferences, I prefer visual studio code for javascript and that type of stuff)

earnest phoenix
#

Perfect thanks also am not a troll

#

Sorry for pubblicate my bot on top.gg?

wheat mesa
#

Visual Studio Code can be annoying to set up for lower-level languages since it's basically a text editor with some extra features but overall I really like the simplicity

earnest phoenix
#

Idk why the would say that

earnest phoenix
solemn latch
wheat mesa
solemn latch
#

Ah

earnest phoenix
#

Thanks

#

@solemn latch I can promise you am not Troll

solemn latch
#

Simple misunderstanding.
Typically most people know what programming languages are before looking for a code editor.

#

No big deal

earnest phoenix
#

Just new too this I have learning disability so processing take bit time for me

boreal iron
#

Notepad++ perfect since >10y

wheat mesa
#

Dw about it

#

Just takes some time to learn

earnest phoenix
#

Am not going be removed am I

wheat mesa
#

Nope

earnest phoenix
#

Thanks guys 🙂 for help

wheat mesa
#

👍 gl!

woeful pike
#

why is heize putting her album names in rustdocs

round cove
#

God this is so nice

#

Thank you cpp gods

delicate zephyr
boreal iron
#

If you don’t use a lib can’t you just ACK the interaction (to not let fail) and respond with a simple message in the interaction used channel

#

I see you just send a message but I think you don’t actually need the interaction response at all by just ACK it

#

For example instead of defer it with the loading state (bot is thinking) just acknowledging it and for example instead indicate a bot is typing action until the message is send

#

Might also be a smart solution

delicate zephyr
#

it just fails if you do that

boreal iron
delicate zephyr
#

yea

boreal iron
#

Responding with a pong

delicate zephyr
#

type 1

#

just doesnt

boreal iron
#

Ah was typing didn’t see your message

delicate zephyr
#

I mean

#

I could also just delete the message instead

boreal iron
#

Defer it and delete it, yeah

#

Might also be a good idea

#

Might make sense even when deleting to keep it an ephemeral message in cases a rate limit takes in place

#

But I thought you can just ACK it

#

Hmm weird


#

Maybe that’s a feature for the future when Discord sends requests frequently to show your app as online

#

If it doesn’t have the bot scope anymore

lyric mountain
boreal iron
#

Yeah they never heard of nowrap I guess

delicate zephyr
#

cleaner

boreal iron
#

Absolutely yeah

#

Still a shame you can’t ping in the edit but yeah
 that’s how it is

green kestrel
#

i came up with an awesome D++ slogan lol