#development

1 messages · Page 713 of 1

earnest phoenix
#

not too bothered abt a fix right now tbh, I'd be happy if they just didnt show up in the console

valid frigate
#

ok

#

simply read the error

#

it says "can't send messages to this user" this means they aren't accepting dms from server members

#

so you could encompass your code in a try/catch block

#

so these errors dont appear in your console/you can send error messages back to discord

wooden lance
#

Apparently channel isn't defined, but it is, or I'm just an idiot. Running discord.JS. The error:

    at Object.module.exports.run (/root/DiscordBotApp/commands/tempmute.js:38:36)
    at Client.client.on.message (/root/DiscordBotApp/server.js:178:17)
    at Client.emit (events.js:198:13)
    at MessageCreateHandler.handle (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
    at WebSocket.onMessage (/root/DiscordBotApp/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:198:13)
    at Receiver.receiverOnMessage (/root/DiscordBotApp/node_modules/ws/lib/websocket.js:789:20)
(node:1283) DeprecationWarning: Collection#find: pass a function instead
(node:1283) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
    at item.request.gen.end (/root/DiscordBotApp/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
    at then (/root/DiscordBotApp/node_modules/snekfetch/src/index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)

and the piece of code:

  try{
    message.guild.channels.forEach(channel, id)
      channel.overwritePermissions(tomute, {
        SEND_MESSAGES: false,
        ADD_REACTIONS: false
      });
  }catch(e){
    console.log(e.stack);
  };

Thanks in advance!

earnest phoenix
#

the thing is its sending the message and the users are receiving the message, so it obviously can send a message to the person so im stumped @valid frigate

#

and, will do, ty

sudden geyser
#

@wooden lance call it as an actual function

wooden lance
#

?

sudden geyser
#

forEach takes a function as it's first arg

wooden lance
#

so what would i change it to?

#

im still quite a beginner at js

gritty bolt
#

any reason my bot could be going offline randomly after a couple of minutes?

#

no error or anything

#

it just goes offline and comes back on once i restart it

#

then repeats

grim aspen
#

what are you using to host it @gritty bolt

gritty bolt
#

aws ec2

#

but it happens on my pc too

wooden lance
#

you using something like screen?

gritty bolt
#

nodejs

grim aspen
#

did you look at the console?

wooden lance
#

when you close the terminal connection?

gritty bolt
#

and it usually runs on a forever instance

grim aspen
#

ah

#

use pm2

gritty bolt
#

yeah ive looked without forever

#

nothing shows up

#

same issue

grim aspen
#

install pm2

wooden lance
#

hmmmm

grim aspen
#

pm2 start {bot's main file}

wooden lance
#

^

gritty bolt
#

yea but thats not the issue

grim aspen
#

it will then stay online unless it has unexpected downtime

gritty bolt
#

it happens without forever

grim aspen
#

oh

gritty bolt
#

like it just turned off

#

nothing in console

#

it just turns off

wooden lance
#

weird

gritty bolt
#

ikr

earnest phoenix
#
//ON DM MESSAGE REPLY
client.on('message', msg => {
  try{
  if (msg.channel.type == "dm") {
    msg.author.send ("TEST MESSAGE",);
    return;
    
  }
  }
  catch(err) {
      
  }
});

So this is what I've got so far, but errors keep showing up in console
I tried adding

catch(err) {
console.log ("ERROR TEST")
}

but that didnt show up at all, any idea whats going on?

#

the user dm'ing the bot gets the "Test Message" from the bot, and nothing else which is expected, but the console logs it as message unable to be sent to user

(node:26812) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
    at item.request.gen.end (F:\desktop\Dappers Bot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15)
    at then (F:\desktop\Dappers Bot\node_modules\snekfetch\src\index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:26812) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:26812) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
quartz kindle
#

the user either has the bot blocked, or he does not allow dms from people who are not friends

wooden lance
#

Using discordjs and for some reason channel.overwritePermissions(tomute).delete(); is not working. Apparently it's not a function! Anyone know why it's not working?

#

wait

#

crap need to use .get lol

jolly ridge
#

.

wooden lance
#

ok it's apparently undefined. wow im crap at this

jolly ridge
#

What is certified bot developer.

#

Or Certified Developer whatever.

west spoke
sudden geyser
#

@wooden lance try {...} catch (ex) {...} won't work in async calls/promises. You'll need to await or .catch it

wooden lance
#

i realised that. i removed it.

#
    at textChannels2.forEach (/root/DiscordBotApp/commands/tempmute.js:102:55)
    at Map.forEach (<anonymous>)
    at Timeout._onTimeout (/root/DiscordBotApp/commands/tempmute.js:101:21)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
(node:2144) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
    let textChannels2 = message.guild.channels.filter(channel => channel.type === 'text');
    if (textChannels2.every(channel => channel.permissionOverwrites.get(tomute.id))) {
      textChannels2.forEach(async (channel, id) => {
        await channel.permissionOverwrites.get(tomute).delete();
      });
    }
earnest phoenix
#

@quartz kindle
thing is, the bot is sending the message and the user is receiving it, but it still shows that error in the console?

west spoke
#

@wooden lance permissionOverwrites isn't a message object I dong believe and from what it seems, this code will abuse the api

sudden geyser
#

you're trying to get a member object when the keys are snowflakes

wooden lance
#

rip looks like not going to be using that for muting then

earnest phoenix
#

Yup can someone help me for change presence of my bot
From play to watch ? (node.js)

#
client.on('ready', () => {

    setInterval(function () {

        var statut = [
            `Faites s!help pour afficher l'aide.`,
            `${client.guilds.array().length} serveurs. | Préfix du bot s!`,
            `Préfix du bot s!`,
            `${client.users.size} utilisateurs. | Préfix du bot s!`
        ];

        var random = Math.floor(Math.random() * (statut.length));

        client.user.setPresence({
            game: {
                name: statut[random],
                type: 3
            },
        });
    }, 12000);
});
#

type 3 is watching but not working 😐

sudden geyser
#

it's activity not game | edit: let me check some more

#

are you on stable or master? You could pass the string name of the activity instead of number

earnest phoenix
#

I do not understand

#

stable or master?

west spoke
#

@earnest phoenix I would set the delay to around 20000 at least

#

12 seconds is too fast

earnest phoenix
#

it's already done yes

#

but I can not switch to WATCHING

amber fractal
#

12 seconds is the absolute minimum

west spoke
#

just to be safe

earnest phoenix
#
client.on('ready', () => {

    setInterval(function () {

        var statut = [
            `Faites .help pour afficher l'aide`,
            `${client.guilds.array().length} serveurs.`,
            `${client.users.filter(u => !u.bot).size} utilisateurs.`
        ];
        var view = [
            `STREAMING`,
            `WATCHING`,
            `WATCHING`
        ];

        var random = Math.floor(Math.random() * (statut.length));

        client.user.setPresence({
            game: {
                name: statut[random],
                type: view[random]
            },
        });
    }, 120000);
});
#

not working too

earnest phoenix
#

ping me if you have to help 🙂

#
client.user.setActivity('TEXT', { url: 'URL', type: 'WATCHING' } );

@earnest phoenix

#

thats what I've been using to set watching

#

yup i know that but with intervalfunction it's possible ?

#

for look like mine

#

I had a similar thing before

#

I am currently looking for it

#

idk if ittl work ,I'm still pretty new, but try this

client.on('ready', () => {

    setInterval(function () {

        var statut = [
            `Faites .help pour afficher l'aide`,
            `${client.guilds.array().length} serveurs.`,
            `${client.users.filter(u => !u.bot).size} utilisateurs.`
        ];
        var view = [
            `STREAMING`,
            `WATCHING`,
            `WATCHING`
        ];

        //var random = Math.floor(Math.random() * (statut.length));


    var viewrandom = view[Math.floor(Math.random() * answers.length)];
    var statutrandom = status[Math.floor(Math.random() * answers.length)];

        client.user.setPresence({
            game: {
                name: statutrandom,
                type: viewrandom
            },
        });
    }, 120000);
});

#

no clue if ittl actually work tho

#

I'm going to try

#

@modest basalt

#

not working

#

@earnest phoenix 😐

#

oof, one sec

#

yup it's not easy xd

#

it's like 3 days i try to fix many bugs on my bot like this one

#

he work but not like i want '-'

#

okay so i think client.user.setPresence only works for like, Online, Idle, Do not Disturb, and Offline

try this?

client.on('ready', () => {

    setInterval(function () {

        var statut = [
            `Faites .help pour afficher l'aide`,
            `${client.guilds.array().length} serveurs.`,
            `${client.users.filter(u => !u.bot).size} utilisateurs.`
        ];
        var view = [
            `STREAMING`,
            `WATCHING`,
            `WATCHING`
        ];

        //var random = Math.floor(Math.random() * (statut.length));


    var viewrandom = view[Math.floor(Math.random() * answers.length)];
    var statutrandom = status[Math.floor(Math.random() * answers.length)];

    client.user.setActivity(statutrandom, { type: viewrandom })
            },
        });
    }, 120000);
});

#

@modest basalt

#

nop

warm marsh
#

That changes it every 2 mins.

#

You will have to wait 2 mins before it's status will update.

steel patrol
#

hi, I have a question on connections. To send messages via eg curl your bot needs to authorize via the gateway. Since I can send curl messages after using discord.js, I suppose that plugin authorized for me .

#

now is this authorization permanent for that bot or will it expire?

slim heart
#

Well using discordjs it doesn’t activate until you connect to the gateway. You can do it through curl with just using the bots token in the authorization header

earnest phoenix
#

you don't need to go through the gatway to send messages i think

#

messages are rest requests

#

i'm curious now going to test it out

steel patrol
#

but the strange thing is that the curl wasn't working with a 40001 error until I made a discord.js app for the same bot, after which it was working

earnest phoenix
#

yeah you don't need to through the gateway to send a message

steel patrol
#

mmm okay

#

I thought so because the docs say Before using this endpoint, you must connect to and identify with a gateway at least once.

earnest phoenix
#

they might mean once in a lifetime of the application by that

#

i'm using an API wrapper here but it shouldn't make a difference between curl requests because it's just REST

steel patrol
#

ok thx

earnest phoenix
#

Hi how can i detect when a new bot is adding on server and auto ban this bot if he's not in whitlist ?

#

ping me to answer

slim heart
#

Not allowing people you can’t trust to add bots

sage bobcat
#

One message removed from a suspended account.

slim heart
#

Well in each command you can just add an aliases array and when you find commands u can get the command from collection and if it doesn’t exist then search for it using the aliases array

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slim heart
#

Yes

earnest phoenix
#

that should be it

#

oh?

slim heart
#

the command handler would have have to deal with finding the aliases

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
frozen cradle
#

hi

earnest phoenix
#

How do I make a system that gives a random number between 500 and 1500 (js)

unique nimbus
#

Math.random

quartz kindle
#

^

unique nimbus
#

I don't know js but I know about that

#

Math.random(500,1500)

#

that should work

quartz kindle
#

I dont think so

unique nimbus
#

hmm

mossy vine
#

it wont

earnest phoenix
#

It was not

quartz kindle
#

Math.random gives you a float betwren 0 and 1

unique nimbus
#

oh

quartz kindle
#

In js

earnest phoenix
#

Math.floor?

mossy vine
#

Math.floor(Math.random() * max) + min

quartz kindle
#

^

mossy vine
#
/**
 * Returns a random number between two values
 * @param {number} smallNumber - The minimum returned value
 * @param {number} bigNumber - The maximum returned value
 */
exports.randomBetween = (i, j) => {
    let s = Math.floor(Math.random() * j) + i;
    return s
}```
earnest phoenix
#

Oh thanks

earnest phoenix
#

@mossy vine if i put this code main file its will work?

mossy vine
#

@earnest phoenix if you are placing it in the file you want to use it in, replace exports. with const . if you are placing it a different file, make sure to import it

earnest phoenix
#

client not work?

mossy vine
#

what

#

uh

#

i guess it would

earnest phoenix
#

client.randomBetween

mossy vine
#

no idea why you would do that tho

earnest phoenix
#

i tried it's saying function

quartz kindle
#

You add it to client like that

#

Then when you want to use it, you do client.randomBetween(50,100) for exanple

tranquil drum
#

You could also put

function randomBetween(i, j) {
    let s = Math.floor(Math.random() * j) + i
    return s
}

somewhere and call it like normal

mossy vine
#

i also said that

warm marsh
#

There is no need to create a variable just return the Math.floor or use an arrow function and do js const randomBetween = (low, high) => Math.floor(Math.random() * high) + low;

fluid coral
#

How do I make a Discord bot on mobile?

earnest phoenix
#

you don't

#

thanks for coming to my ted talk

warm marsh
#

You could.

#

Dependant on OS though.

fluid coral
#

I'm on android

warm marsh
#

There is a few things you could use.

#

@fluid coral Do you intend on coding this bot?

fluid coral
#

Not really

vestal axle
warm marsh
#

Then I don't know.

vestal axle
#

okay

warm marsh
#

@vestal axle I was talking to @fluid coral.

west spoke
#

@vestal axle that's fine. Run the bot

earnest phoenix
#

this is;

#

client.guilds.filter(x => x.memberCount < 15).leave() true?

#

you can't use a method that's on an object on a collection of objects

slender thistle
#

Python:
Is it a bad idea to create own subclass list with a method to return the list's length

earnest phoenix
#

@earnest phoenix how i can?

#

loop through the collection

golden herald
#

Just a question for discord.py, how do you check if a bot has perms?

slender thistle
#

Yours or another?

golden herald
#

?

slender thistle
#

Which bot are you talking about?

golden herald
#

my bot

slender thistle
#

For permissions that could be overriden by channel overwrites, use guild.permissions_for(guild.me)

golden herald
#

wait what?

slender thistle
#

For overall guild permissions you use Member.guild_permissions

#

Hm?

golden herald
#

um ok, I was on about if the bot has certain perms on a server

#

how to check which ones they got for commands

#

Ik it is to do w/ @earnest phoenix_has_permissions but it doesn't seem to be working

slender thistle
#

Show how you are using it

golden herald
#

ingore the "and"

slender thistle
#

Separate them with commas, not ands

golden herald
#

ik just done that

#

if I don't give it kick perms, the bot will still kick

slender thistle
#

It can't kick without the permission

#

You probably gave it admin permission

#

Also checking for admin perm as well as other ones is pointless

golden herald
#

oh ok

wide ruin
#

how long is a bot token?

#

just in characters

earnest phoenix
#

no specific length

#

what do you want to do

#

Hey

#

+eval client.guilds.filter(x => x.memberCount < 10).forEach(x=>{x.leave()});

#

this

#

true?

#

👍

#

:D!

#

:d

#

?

#

what mean

#

this

#

@earnest phoenix is that original?

#

tag in dapi

#

probably made by one of the members

#

ah

earnest phoenix
#

What exactly is your error?

lunar crystal
#

Sorry put the wrong image weirdsip

earnest phoenix
lunar crystal
earnest phoenix
#

well

#

have you checked to see if the file is in that directory

#

You could also use path to find the directory for extra measurements or uploading the image to something like imgur and just putting the image link

lunar crystal
#

I saw on discord.js that we have to put (['../assets/images.jpg']

#

oki thx

earnest phoenix
#

No problem GWlegacyBlobThumbsUp

#

I say using imgur is honestly just easier and removing attachFiles and only using setImage with the image link

#

you also save bandwidth

#

Yeah so it isn't uploading the image every time the command is executed

#

I've got a <div> in between two other <div>s, is there a way I can automatically center it?

<div style="width:40%;height:4vw;margin:auto;">
        <a href="[redacted for brevity]">
            <button class="hlink iabInviteAdmin hButton" 
            style="float:left;"> 
                Invite to Discord (Administrator) 
            </button>
        </a>
        <a href="[redacted for brevity]">
            <button class="hlink iabInviteLow hButton"> 
                Invite to Discord (Lower)
            </button> 
        </a>
        <a href="[redacted for brevity]">
            <button class="hlink iabInviteAdmin hButton" 
            style="float:right"> 
                iab Discord Server
            </button> 
        </a>
        </div>
lunar crystal
#

.setURL('My-url') I guess ?

opaque eagle
#

Is there any way to run multiple "setIntervals" at the same time?

#

I want to run things almost like cron jobs but much more often, like a couple times per minute

#

but ya know JS is single threaded

vocal phoenix
#
        return new Promise(resolve => setTimeout(resolve, seconds*1000));
    }```
Inside a loop?
earnest phoenix
#

I've got a <div> in between two other <div>s, is there a way I can automatically center it?
please learn how to use css flexbox that snippet is a disaster notlikenoot

#

yeah I just offloaded most of that style garbage to css

#

I think disaster really defines my command reference lmao

#

but I'm getting there

dreamy arch
opaque eagle
#

I want to run setIntervals like these simultaneously```js
setInterval(async () => {
await fetch('https://an-api-here/', { method: 'POST', body: { blah_blah_blah } })
console.log('(1): Done again or whatever')
}, 1000 * 30)

setInterval(async () => {
await fetch('https://another-api-here/', { method: 'POST', body: { blah_blah_blah } })
console.log('(2): Done again or whatever')
}, 1000 * 15)```

#

@vocal phoenix

dreamy arch
#

I use this site way too often

tranquil drum
#

make the div inline-block i think

#

the child div

dreamy arch
#

depends on which browser versions you need to support

tranquil drum
#

and text-align: center on parent

earnest phoenix
#

my god zaop

#

that is a godsend

#

thank you so much

dreamy arch
#

you're very welcome

hushed berry
#

wrap your child in a block

#

a concrete block

vocal phoenix
#

@opaque eagle

    while(true){
        //use globals or outer scope variables to break the loop if necessary
        functionHandle();
        await this.wait(secondsBetweenCalls);
    }
}
async wait(seconds){
    return new Promise(resolve => setTimeout(resolve, seconds*1000));
}```
Try defining those functions then pass them into a function like this one.
#

Come to think of it, you should be able to pass in an anonymous function as well.

earnest phoenix
#

#LambdaGang

tight mountain
#

is there a function that shows when your bot joined the guild the command was fired on? I want to have it in the info command

earnest phoenix
tight mountain
#

I want something like message.member.joinedAt but for the client, and not the user

earnest phoenix
vocal phoenix
#

@earnest phoenix Why is the header font size smaller than the bulk text font size?

#

@tight mountain Not sure what you're asking.

earnest phoenix
#

For the parameters and description headers?

vocal phoenix
#

Yeah.

earnest phoenix
#

They're not really supposed to stand out as much as the information

#

I feel like having them be like h3 size or something would be emphasizing the header a bit too much

vocal phoenix
#

Looks odd to me.

hushed berry
#

@tight mountain get the bots member and get the join time of that

tight mountain
#

@vocal phoenix message.member.joinedAt would return a time and date for when the person who sent the command joined, but I want to have the time and date for when the bot joined the server

#

o

golden herald
#

This is a question that will make or break my bot: so I need this to be before the bot permissions check, how do I do this?

vocal phoenix
#

Why do you want it before the permission check?

high lava
#

Order of operations. It runs from top to bottom

#

You just have it first

earnest phoenix
#

Jaylon why

manic basalt
#

is it possible to make the check in wait_for in discord.py async, when I try to await the function it returns an error

vocal phoenix
#
            return true```
green kestrel
#

@golden herald whats that on the bottom line of your screenshot?

#

just wondering what elliotid, jayid etc are, and why theyre hard coded into the source code 🙂

earnest phoenix
#

@green kestrel probably ids for the owners/developers of the bot

#

considering the first one says kiyanid

green kestrel
#

i figured, i was dropping a not so subtle hint that it's not really a good coding style and that there may be better ways

#

😉

earnest phoenix
#

but it really isn't a make or break deal for it

#

its just a couple of ids

tight mountain
#

Trying to make bot send a message every few hours or so. I keep getting this error when trying to find a guild/channel. ``` client.guilds.get('627296126537564162').channels.get('627296126537564164').s
end("test")
^

TypeError: Cannot read property 'channels' of undefined
at Timeout._onTimeout (C:\Users\Kerigan\Desktop\Hello\bot.js:95:44)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)```

#

Still get same error

grim aspen
#

i was wrong fuck me

tight mountain
#

I copy pasted it from my other bot, i dont see why it isnt working

lament meteor
#

try to check if the guild exists when u get it

tulip tundra
#

actually

#

you can only define the channel

dusk cargo
#

How to JavaScript kick Command please help me

tulip tundra
#

like

channel.send('message')```
#

@tight mountain

dusk cargo
#

@tulip tundra bro please provide clear massage command in discord.js in prefix change😭 😋 😅

tulip tundra
#

search how bulkDelete works

dusk cargo
#

Yes

#

In java script provide me

#

Real command

#

@tulip tundra

tulip tundra
#

i already told you how

#

search it yourself

winter basalt
#

is help command better in DM or just straight up text in server?

dusk cargo
#

But not working command

#

All command fake not real command in online

#

Please provide me real command

tulip tundra
#

@winter basalt your bot won't get approved if its dm

winter basalt
#

ohh ok

#

btw is there a maxinum limit of messages in embed?

tulip tundra
#

yes

loud salmon
#

@tulip tundra smh it will

vocal phoenix
#

25 fields is the limit.

loud salmon
#

@winter basalt both work but i prefer help commands in-server

#

im sure its down to personal preference

#

🤷

winter basalt
#

mm ok

loud salmon
#

@dusk cargo we do not spoon feed code here

winter basalt
#

thanks for the asnwer

loud salmon
#

np

tulip tundra
#

my bad then

#

wrong ping

lunar crystal
#

Why is my bot taking a lot of time to upoad my imgur link ?

#

Is this because of me ?

cursive dagger
#

Code?

earnest phoenix
#

hello

#

i wanted to make a game bot but don't know to make it

#

anyone help me ??

languid dragon
#

anyone here use Dart?

twilit rapids
#

I use a dartboard

languid dragon
earnest phoenix
#

😂

unreal junco
#

error:
(node:94466) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'avatarURL' of undefined
code:

.setAuthor(member.displayName || message.author.username, member.user.avatarURL || message.author.displayAvatarURL)
languid dragon
#

member.user is unedfined probably (just a guess tho)

unreal junco
#

oh oops

#

wrong code

languid dragon
#

lmao

unreal junco
#

done

#
.setAuthor(member.displayName || message.author.username, member.user.avatarURL || message.author.displayAvatarURL)
#

it works with @mention but comes with error for no mention

slim heart
#

Well that just means you have to redefine member if it’s not in a mention, make sure you’re getting member again rather than a user cuz user.user doesn’t exist

amber fractal
#

displayName is never not defined. Unless member isnt defined. So no point in having the other cases

cerulean salmon
#

any one can give me idea how to store users previous nick names ( last 10 nick names )

#

?

sudden geyser
#

an array list?

amber fractal
#

You'd have to update a database on name change

cerulean salmon
#

if i use array list ,then i need 2d array ?

amber fractal
#

MegaThonk why would you need a 2d array. If anything it should be an object with an array of nicknames mapped to their id

cerulean salmon
#

👍

green kestrel
#

im currently working on a web dashboard for my bot

#

is there anything obvious that most people overlook when doing this, that i should watch out for and avoid, or do?

earnest phoenix
#

My question is why that top bar takes up a quarter of the screen

sudden geyser
#

that's how headers be sometimes

#

dbl's takes up like 60%

earnest phoenix
#

that's kinda different tho

#

dbl's has multiple useful functions

#

with that one I can see a single button in the top right

sudden geyser
#

hmm

earnest phoenix
#

Maybe if the header had something a bit more going on aesthetically or something, it would look a bit more alive, similar to how dbl has that little image on the right

west spoke
#

^

cerulean salmon
#

its possible to get data from google sheet ?

#

via bot

amber fractal
#

Google has an extensive api

green kestrel
#

thanks for the tips @earnest phoenix ive shortened the header

#

better?

civic scroll
#

hi

sudden geyser
#

hello

civic scroll
#

i have a bit trouble with the mongoose

#

the bot can't write to database

#

idk if the url is right

#

is there anyone who can help me with the mongoose?

#

just used it for the first time and idk how that works

amber fractal
#

I would recommend mongodb over mongoose as it's the native driver, but that's more of a preference

civic scroll
#

i'm confused and not understand it all

lunar crystal
earnest phoenix
#

you spelled attachment wrong in your code

lunar crystal
#

Good one *

earnest phoenix
#

ok

#

then

#

that's not a direct link to the image

#

visit the link in your browser, right click the image and copy the image url

lunar crystal
#

Ok tx 😄

civic scroll
#

idk mongoose or mongodb

#

i need some help

lunar crystal
#

It works ! pogey

civic scroll
#

me not

#

the database

torpid cave
#

Im Not Sure If This Is The Best Channel To Do This, But On The Website For The Discord Bot List, It Is Making Me Sign In Through My Old Account. And I Cant Seem To Sign In Through The Website Through This Account. Is There A Way To Fix This?

earnest phoenix
#

Uhm

#

discord > log out

#

and try aigan

#

(on website)

torpid cave
#

Ok

alpine marlin
#

Hello, do you know any anime API for Discord bots?

earnest phoenix
#

hol on

#

@alpine marlin

alpine marlin
#

Thx bro

jade thistle
#

Skipper, the best answerer of questions

torpid cave
#

Oh

#

Tysm

tight mountain
#

@tulip tundra ```setInterval(function(){channel.send("test")}, 10000);
^

TypeError: Cannot read property 'send' of undefined```

#

get different error

#

heres the code var channel = client.channels.get('630431103051890701') setInterval(function(){channel.send("test")}, 10000);

amber fractal
#

the channel wasnt found

tight mountain
#

But why? It's on the server, and it has permission to send to the channel

cold canyon
#

does anyone know python bot hosting services

#

idc if they arent free

mossy vine
#

uhm

#

a vps

cold canyon
#

ok

#

but where should i get the vps

cold canyon
#

i was browsing a1 vpss bcause i live in austria

#

lemme check galaxygate

#

@slender thistle does galaxygate support python

slender thistle
#

They're literally your usual machines

#

they are not limited to a certain programming language

cold canyon
#

@slender thistle does galaxygate support mac

#

or linux

#

when it comes to deploying and running apps

eternal mesa
#

@cold canyon most providers support linuz

slender thistle
cold canyon
#

i give up on vps

earnest phoenix
#

you shouldn't host debug builds on your vps anyways

#

compile them and then host

#

you can even dockerize

slim heart
#

Vectors is just a fancy name for arrays?

slender thistle
#

{a1,a2, ..., an}

scarlet phoenix
#

I would reccomend docker, it makes it so easy and quick to deploy. Worth the learning curve

mossy vine
#

wouldnt docker be overkill for a simple discord bot

snow urchin
mossy vine
#

how could i rewrite this code to not use eval and still have the same result?

const render = (html, args) => {
    start = html.search(/{{/)
    end = html.search(/}}/)
    between = html.substring(start, end + 2)
    evalThis = html.substring(start + 2, end)
    html = html.replace(between, eval(evalThis))
    console.log(html)
}

render('<h1>Hello, {{args.user}}!</h1>', { user: 'Cyber28' })```
crystal saffron
#

.... parsing html with javascript

my god

west spoke
#

It's not that hard

#

just use dummy <style> tags

#

as a marker for where to parse

dusky marsh
#

is there any way to attach a database connection to the sharding manager so that each instance of the client can access the database connection without having a db connection per shard

mossy vine
#

@crystal saffron @west spoke i know there are better ways to handle the parsing, but what about not using eval?

valid frigate
#

each client needs a database connection because they are seperate processes

#

unless you use something like ipc to tell the master process that you wanna do X and wait for Y response, it isn't possible

vagrant bison
shy glen
#

@vagrant bison What? how does this relate to the top.gg API?

vagrant bison
#

does not matter...

heavy marsh
#

What permission do you need to unban a person?

#

like in general

slender thistle
#

same as for ban

earnest phoenix
#

^

slender thistle
#

BAN_MEMBERS

heavy marsh
#

ooh ok thanks

earnest phoenix
#

or in number 4

heavy marsh
#

number 4?

earnest phoenix
#

If you dont use the name but a integer

#

then you use 4

heavy marsh
#

ooh

#

ok

earnest phoenix
#

how to add role to all ppl in the server without getting rate limited in discord.js?

#

@earnest phoenix sry for ping but can u help me?

mossy vine
#

respect the rate limits

earnest phoenix
#

but theres for sure a way

#

There is no way to do it

#

Expect getting banned from discord for adding a role to like 20k users at once

#

in antispambot they have it

mossy vine
#

yes there is, dont send enough requests to hit rate limits

#

wait between each request

earnest phoenix
#

^

#

wait how much time

vocal phoenix
#

@mossy vine Have you tried nested template literals?

mossy vine
#

5 sec should more than enough

earnest phoenix
#

i wanna respect the rate limits thats why im asking

mossy vine
#

@vocal phoenix wdym

earnest phoenix
#

5 sec between one user?

mossy vine
#

yeah

earnest phoenix
#

ok

#

how do i make a for loop and wait 5 seconds before im sending the next request?

#

like im doing .foreach

#

how do i wait 5 seconds

mossy vine
#

await a promise that resolves in a setTimeout

#

wait no

#

i dont think that will work

late hill
#

Use a regular for loop

#

You can await promises in there

shy glen
#

Or just use setInterval

vocal phoenix
#

@mossy vine
I was thinking something like this:

    html = String.raw`${ `${html}` }`;
    return html;
}

var x = render('<h1>Hello, ${args.user}!</h1>', { user: 'u' });```
but that doesn't work. If you only have keys that don't have subobjects 
```const render = (strings, ...keys) => {
  return (function(...values) {
    var dict = values[values.length - 1] || {};
    var result = [strings[0]];
    keys.forEach(function(key, i) {
      var value = Number.isInteger(key) ? values[key] : dict[key];
      result.push(value, strings[i + 1]);
    });
    return result.join('');
  });
}

var exampleClosure = render`<h1>Hello, ${'user'}!</h1>`;
console.log(exampleClosure([], {user: 'username'}));```
from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals will work.
earnest phoenix
#

Hey, why it tells "message" is not definied?

#

All commands work

#

S

#

But this idk, won't get "message"

lusty ridge
#

Help

#

when I try to add the smoogle translate bot to my server, it doesn’t show the “Authorize” button. Any one have insight on why this happens / how to fix?

#

<@&265158261945270273>

hushed berry
#
  • this isnt the support server for smoogle translate
  • if this was the right server, this would be the wrong channel
  • smoogle translate doesnt have any control over the authorization page -- that would be discord
  • dont ping the website admins unless stuff is on fire

to answer your question though, you sometimes need to scroll down. its a bit finnicky sometimes

@lusty ridge

lusty ridge
#

Riiiigt

#

Okay 👌

west spoke
#

web admin ping

#

god

tight mountain
#

still get ```setInterval(function(){channel.send("test")}, 10000);
^

TypeError: Cannot read property 'send' of undefined```

#

when i try to use var channel = client.channels.get('630431103051890701') setInterval(function(){channel.send("test")}, 10000);

#

I have tried different servers and different channels, still get same error

#

When I run it in glitch.com or something (i know glitch is a big no no), it works, but when I run it on local machine, it gives the error.

sudden geyser
#

the channel does not exist with that id or is not cached

warm marsh
#

@tight mountain that is gonna send "test" to the channel every 10 seconds.

manic basalt
#

Would anyone know a solution as to why this is showing up while launching my bot

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/getlimits.py:499: BytesWarning: Comparison between bytes and string
  self.dtype = numeric.dtype(int_type)

running python 3.6 with discord.py rewrite

slender thistle
#

Some part of code would help

#

wherever it is erroring out

vocal phoenix
#

By the looks of it, you're comparing an array of bytes to a string. It's probably giving you a warning because one is being implicity cast to the other, which can be a bad thing. Pic semi related.
@manic basalt

tacit stag
#

How to give an output of a link in discord dot js using markdown? Im trying to have the link be shortened down to a string, and i have already tried [SiteName](url)

slender thistle
#

Hyperlinks only work in embed contents

tacit stag
#

it is in an embed

#

this is my code:

if((args.includes('https://google.com'))) {
    site = 'Google';
    url = args[0];
  }
//Output it in an embed using [${site}](${url})
#

this didn't work

vocal phoenix
#

Use the author field of the embed.

slender thistle
#

Which field is that

vocal phoenix
#
if((args.includes('https://google.com'))) {
    site = 'Google';
    url = args[0];
    embed.setAuthor(site, null, url);
}```
slender thistle
#

Hyperlinks can be done in field values and descriptions

vocal phoenix
#

Does it display the whole link though or can you have some alt text that appears instead of the full link?

slender thistle
loud salmon
#

smh no shitposting

vocal phoenix
#

I didn't realize embeds have markdown. Why is it limited to embeds?

loud salmon
#

reasons

west spoke
#

Imagine rick rolling someone

#

they wouldnt be able to know

#

[Free robux111!1!](some link)

valid frigate
#

links are spoopy

#

that also shows up in embeds as a redirection warning

#

why cant humans use it as well smh

astral meteor
#

It looks correct, but it gives 2 errors.

if(!message.member.hasPermission("MANAGE_GUILD")) || if(!message.author.id == "596879758244053002")
        return message.channel.send("You do not have permission to run `setprefix`.");
late hill
#

Combine the 2 conditions in one if statement

#

Using ||

#

and it wouldn't be a bad idea to use === instead of == because the id should/will always be a string

astral meteor
#

fixed, thank you :)

valid frigate
#

also

#

a more efficient way of running permission checks like these is to have a message handler

#

sits in between your message event and the command, and does stuff like verify permissions etc

#

export a prop in your help object like permissions: ["MANAGE_GUILD"]

short forge
#

raspberry pi, latest raspbian if that helps

#

and also i tried discord-leveling

vocal phoenix
#
Perhaps you should add the directory containing `pixman-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pixman-1' found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp```
Make sure pixman-1 is installed and location is defined in PKG_CONFIG_PATH.
amber junco
short forge
#

Idk

quartz kindle
#

It failed to get prebuilt binaries, so it needs to be built from source

#

Building from source requires all packages listed in their npm/github page in the building from source section for your operating system

#

For example, for ubuntu, you need to install the following packages (in ubuntu using apt, not on npm) build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev

wheat jolt
#

does someone know a good vps hosting provider?

wheat jolt
#

i wanna get rid of arubacloud

#

thanks

short forge
#

Ok thanks

#

There is a section on the package on how to get from source

#

👍

modest remnant
#

Any one have music bot spriti python programming language

#

@everyone

earnest phoenix
#

Uhm

#

@modest remnant 1. We cant @everyone 2. its aiganst rules lol

west raptor
#

You know I always find it funny

Has a hacker/coder pfp

Can't even code their own shit

cursive dagger
#

^ ikr

west raptor
#

So no, @modest remnant

#

We will not be giving you links or code for a music bot in python

earnest phoenix
#

Is there a way to get bots with a prefix in the api?
(javascript / node.js)
Like to get all bots with a specific prefix

#

(The api = dbl api)

quartz kindle
#

i think you can use this

earnest phoenix
#

problem is

#

oh wait

#

the problem is i cant find a option to get the bots with a prefix

mossy vine
#

yeah iirc there is no way for regular users to access all bots with 1 endpoint

quartz kindle
#

the api says there is

#

let me test

quartz kindle
#

yup, there is

#

there are 2908 bots with ! prefix

#

example searching for a! prefix:

#

you can get up to 500 bots per request (but you get a number showing the total amount of matches regardless, and you can navigate them by offset)

#

and you can search by several fields

earnest phoenix
#

and how can i?

#

I tried to find but i couldnt

#

@quartz kindle

#

so what sorting method do i have to use

quartz kindle
#

you have to make an https GET request to top.gg/api/bots with the query parameters you want, and your dbl token in the authorization header

#

for example https://top.gg/api/bots?limit=50&search=prefix:a!

earnest phoenix
#

Thanks

#

so on the api this would be

#

wait

#

dbl.getBots({ prefix: 'a!', limit: 100 })

quartz kindle
#

no...

earnest phoenix
#

im dumb

quartz kindle
#

you need to make an http request yourself

#

you cant use the library

earnest phoenix
#

Ok

quartz kindle
#

wait actually you can

earnest phoenix
#

i saw that and i tried to do it with query prefix: 'b.'

#

but

#

it returns

#

all

#

bots on dbl

solemn harness
#

give me complete guide on dblapi

pliant iron
#
dbl.webhook.on('vote', vote => {
  
  let upvoteLogChannel = client.channels.get("634779916575178762");
  
  upvotesDB.add(vote.user.id, 1)
  
  upvoteLogChannel.send(`**${vote.user} upvoted the bot.**`);
  console.log(`User with ID ${vote.user} just voted!`);
  
});```
#

Nothing?

#

happens

solemn harness
#

lo

#

lol

quartz kindle
#

@earnest phoenix use query.search

earnest phoenix
#

thanks

quartz kindle
#

@pliant iron is your webhook configured correctly?

pliant iron
#

I believe so

quartz kindle
#

did you configure it in your bot's edit page?

pliant iron
#

yeah

#

I gave it a webhook link and made a token for it

quartz kindle
#

what link did you give it?

pliant iron
#

The webhook link I made in the server

quartz kindle
#

which is?

pliant iron
#

Wait I think I defined it wrong

#
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });```
quartz kindle
#

ok, and what url did you put in the website?

pliant iron
#

Do I put the bot's api token there and the second underlined thing as the webhook token?

quartz kindle
#

yes

#

the code is correct

pliant iron
#

ohhh

quartz kindle
#

but the url you put in the website might not be

#

yup, thats wrong

pliant iron
#

Oh

quartz kindle
#

i mean, you can do that

#

but that will send it directly to a discord webhook

#

not to your bot

#

and probably is not compatible with discord webhooks

pliant iron
#

What am I meant to do?

quartz kindle
#

the webhook needs to find your bot

#

your bot opens a webserver in port 5000

#

so depending on where and how your bot is hosted

#

or something similar

pliant iron
#

Hold up

quartz kindle
#

if you're running in glitch or heroku, or you have your bot running behind some proxy, you will need to use something different

pliant iron
#

It logged this http://0.0.0.0:5000/dblwebhook

quartz kindle
#

yes, 0.0.0.0 is a null adress, its the same as saying "this machine"

#

its not an actual address

pliant iron
#

oh

quartz kindle
#

you need its public ip address address

pliant iron
#

I use glitch

quartz kindle
#

where is your bot hosted?

#

glitch is different

#

or something like that, i dont remember

pliant iron
#

Is it the project link?

#
or
https://exvay-bot.glitch.me```
quartz kindle
#

then try https://exvay-bot.glitch.me and set up your dbl.webhook with port 3000

#

gtlch only alows you to use port 3000

#

afaik

#

{ webhookPort: 5000, webhookAuth: 'password' });

#

webhookPort 3000

pliant iron
#

right

#

that is correct?

#

Because I get this error

#
const dbl = new DBL('token', { webhookPort: 3000, webhookAuth: 'authpasshere' });```

```events.js:183

      throw er; // Unhandled 'error' event

      ^

Error: listen EADDRINUSE :::3000

    at Server.setupListenHandle [as _listen2] (net.js:1360:14)

    at listenInCluster (net.js:1401:12)

    at Server.listen (net.js:1485:7)

    at DBLWebhook._startWebhook (/rbd/pnpm-volume/b8b6183b-9298-4f5f-8951-dee24b437c0c/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/webhook.js:45:18)

    at new DBLWebhook (/rbd/pnpm-volume/b8b6183b-9298-4f5f-8951-dee24b437c0c/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/webhook.js:27:12)

    at new DBLAPI (/rbd/pnpm-volume/b8b6183b-9298-4f5f-8951-dee24b437c0c/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/index.js:69:22)

at Object.<anonymous> (

:13)

    at Module._compile (module.js:653:30)

    at Object.Module._extensions..js (module.js:664:10)

    at Module.load (module.js:566:32)```
#

@quartz kindle That error comes when the port is 3000

west spoke
#

Perhaps rerouting to a self-hosted site and return that with node?

#

Or maybe force a reload through the http request?

astral meteor
#
                message.guild.channels.forEach(async (channel, id) => {
                    await channel.overwritePermission(muterole, {
                        MANAGE_CHANNELS: false,
                        SEND_MESSAGES: false,
                        ADD_REACTIONS: false,
                        CONNECT: false
                    });

It says channel.overwritePermission is not a function in console, what's the error?

late hill
#

It's overwritePermissions

heavy marsh
#

Is it possible to stop a user from editing his/her message!

earnest phoenix
#

no

amber fractal
quartz kindle
#

@pliant iron try webhookPort: 80, and in dbl https://exvay-bot.glitch.me:3000

#

wait, no

#

that wont work either

#

do you have anything else running in port 3000?

#

oh wait, you have the uptime bot on port 3000 no?

#

thats the problem

#

you need to remove the uptime robot

#

or you need to connect dbl to the existing server that uptime robot creates

#
const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });```
pliant iron
#

aight

tranquil drum
#

why can't i convert a json string into a map with js?

#

nvm got it

earnest phoenix
#

What's perfered Linux or Windows for running my bot?

#

linux

#

to legally run a bot on a windows server you would have to buy a windows license

#

I already have Windows server

#

Licenses

#

Regardless why would Linux be better?

jade thistle
#

it is safer

earnest phoenix
#

linux has standardization, no bloatware, it's more common in the general career path of a developer and many deving systems are designed to run on linux

tranquil drum
#

system usage headroom

mossy vine
#

and linux also has awesome developer tools

tranquil drum
#

i do deployments to a dokku instance on a debian server which means deployments and database linking etc. is just a single command

unique nimbus
#

Are you a developer?
Linux Better

Are you a gamer?
Windows Better atm

earnest phoenix
#

that's dumb logic

tranquil drum
#

but i dev on windows lol

#

and macos sometimes

mossy vine
#

dumb logic but pretty accurate

earnest phoenix
#

you use a platform for what you need it for, not on what you are

tranquil drum
#

i am a human

unique nimbus
#

I am a gaming youtuber, I will use Linux which has less gaming support

earnest phoenix
#

that's what all AI say, teemaw 👀

tranquil drum
#

i am not an ai

mossy vine
#

there are also quite a few youtube channels that do linux gaming

unique nimbus
#

ye

tranquil drum
#

👀

unique nimbus
#

I will not move fully to Linux until my main games work on linux

mossy vine
#

fair

tranquil drum
#

i couldn't imagine my main machine being linux

unique nimbus
#

I could

jade thistle
#

i can

unique nimbus
#

I have it on my laptop

#

as my main OS

jade thistle
#

kk

unique nimbus
#

as it is for office work not for gaming

tranquil drum
#

ya my laptop has macos for that reason

mossy vine
#

i switched to linux only a few months ago

unique nimbus
#

yeet

mossy vine
#

not regretting it. if i have any ms office work to do, i borrow my moms laptop which is running windows. otherwise, linux is perfect

unique nimbus
#

Office Online

tranquil drum
#

lol exactly

earnest phoenix
#

yeah office online exists

unique nimbus
#

also Libreoffice works with docx

tranquil drum
#

although i use office on my ipad

#

nah third party docx support is yikes

#

same with pptx

unique nimbus
#

I mean Libreoffice works fine for me

tranquil drum
#

i actually need to import pptx into powerpoint then export to pdf for it to work

mossy vine
#

the license we get for free as students dont seem to work with office online, and parents have licenses from their schools so whatever

tranquil drum
#

lol weird my student license works fine

unique nimbus
#

Login to your account and it will work

mossy vine
#

office online is just prompting me to bUy PrEmIuM

tranquil drum
#

i actually just dont think i would enjoy using linux on my primary machine from all the extra work i would have to do

#

and all the sacrifices i'd have to make running third party software

unique nimbus
#

Libreoffice is normally preinstalled so there is your office

earnest phoenix
#

my school email comes packed with licenses for a lot of microsoft products

tranquil drum
#

hell even on my macbook i miss windows lol

unique nimbus
#

Thunderbird is preinstalled on some distros

#

which is an email client

#

if I remember correctly

tranquil drum
#

imma be honest most of the time i use office on my ipad anyway

#

and email too

unique nimbus
#

yes

tranquil drum
#

does adobe creative cloud work on linux?

unique nimbus
#

No

#

Well no support

tranquil drum
#

lol it's also a hassle trying to find alternatives for software you're already accustom to and then becoming fluent in the alternatives

unique nimbus
#

ye

tranquil drum
#

also works the other way though cause i do a lot of dev on unix environments

topaz sphinx
#

anyone proficent at discord api

unique nimbus
#

Gimp is good for a photoshop copy if I remember correctly

topaz sphinx
#

i wanna know every type format thats allowed in discord embedding

earnest phoenix
#

in what context

#

as in, bot sending an embed? where? the image field?

topaz sphinx
#

if i put in an embed referring to a link

#

as thumbnail

#

such as image

#

video

tranquil drum
#

@unique nimbus ya problem there is having to learn a whole new image editor

earnest phoenix
#

you are only allowed to use standard image formats

unique nimbus
#

true

topaz sphinx
#

what are the standard image formats

#

is there any video formats allowed

earnest phoenix
#

(a)png/jpg/gif...

#

no

topaz sphinx
#

mildly dissapointed but its good enough smh

earnest phoenix
#

you're not allowed to put videos in embeds for obvious reasons

topaz sphinx
#

what reasons?

earnest phoenix
#

ear rape/nsfw

topaz sphinx
#

cant you abuse it just as easily outside of an embed

earnest phoenix
#

by sending a video link yeah

#

discord TM

tranquil drum
#

you could just send a video link then right?

topaz sphinx
#

idek what their decision is well

#

no video it is ASwanttodie

#

i'll bypass it by making the bot send it outside of embeds

earnest phoenix
#

Lib: Discord.js
Has anyone a idea how i can change the guild icon the command was executed in?

#

Because i cant happen to find anything releated

mossy vine
#

stable or master?

earnest phoenix
#

v12

mossy vine
earnest phoenix
#

Thanks

topaz fjord
#

someone saying appreciative of docs

#

that's a first

restive light
#

hello all

#

how to make code to read every last messages from a guild?

#

if (msg.content === 'Julia')

#

for example like if message contains anything

opaque eagle
#

Do you want to check if a message ends with a specific string? @restive light

restive light
#

no i want to check every messages about anything

#

i want deliver last messages to my another server with my bot

opaque eagle
#

I'm confused about what you mean by "last messages"

restive light
#

basically if someone sends a message then send same message to x server

earnest phoenix
#

message event -> get the channel you want to forward the message to -> send the message's content to the channel

restive light
#

yes

#

can i get a sample code of it?

#

i complicated my codes while im trying it

earnest phoenix
#

no, you can't

#

browse the docs and try to logically connect what i just said to the terms in docs

#

every method, event and property is thoroughly described

restive light
#

why im the only one who cant get any sample codes here

#

still everybody gets samples when they wants

earnest phoenix
#

where did you get that fact from

restive light
#

i see many ones asked and people wrote samples to them

earnest phoenix
#

ok, you saw

#

this server has a no spoonfeeding rule, so no, not everyone will get spoonfed the code

#

people are encouraged to do their own research because it will stick with them more than just giving them the premade code to copy paste

restive light
#

man i didnt say "can you write corrected code for me?" i wrote sample code

#

with explains

earnest phoenix
restive light
#

whatever its

#

but this channels should be removed

#

nobody helps anyone

mossy vine
#

lmao

restive light
#

-Can you show me a sample?
go search google

slender thistle
#

That would be incorrect

restive light
#

learning is showing some basic samples

slender thistle
#

You were given the logical actions to apply in order to get the desired result

#

for an average developer willing to at least learn, that should be enough by itself

restive light
#

yes you are right but giving a sample is easy to learn i think

#

like maths

earnest phoenix
#

maths is not comparable to using a programming library

#

maths is a term comparable to a language

slender thistle
#

Not sure why you would need an example to get a channel from cache

restive light
#

Oke i solved my problem: if (receivedMessage.content.includes(""))

slender thistle
#

Why would you need an if statement

lofty hamlet
#

?

slender thistle
#

not you

lofty hamlet
#

Not me oh ok

quartz kindle
#

@restive light you dont need that lol

#

if you want to process all messages, just remove that if block all together

#

// before
if(message.content === "something") {
    message.something
}

// after
message.something```
slender thistle
#

Conditional algorithms be always true PagChemp

quartz kindle
#

@lofty hamlet you would need to change that loop from string building to array building. another way is to create a position variable and fill it up if the user id matches

lofty hamlet
#

@quartz kindle ok ok you can explain me or send me and explain ? :d

quartz kindle
#

for example ```js
let content = ""
let position; // this

            try {
                for (let i = 0; i < 10; i++) {
                    let user = bot.users.get(lvl[i].ID.split('_')[1])
        if(user.id === message.author.id) { position = set position here } // this
        if(position) { user has a position in this list } // this
                    content += `${i + 1}. __${db.get(`MV3_${user.id}.pseudo`)}__ - **${lvl[i].data.nombre}**\n`
                }
            } catch (err) {
                console.log(err)
            }```
lofty hamlet
#

Mmmh

stable pollen
#

Hey, I'm using Eris with TypeScript and when I'm trying to import Eris using import Eris from "eris", I get the following error for the Eris constructor:

This expression is not constructable.
Type 'typeof import("eris")' has no construct signatures.

I'm relatively new to TypeScript and also tried looking for open source projects that use TypeScript in combination with eris in attempt to solve this issue myself, sadly without any luck.
Any idea what I'm doing wrong?

lofty hamlet
#

I do change what @quartz kindle ?

quartz kindle
#

@stable pollen did you try import { Eris } from "eris"?

lofty hamlet
#

🤔

stable pollen
#

that gives me Module '"eris"' has no exported member 'Eris'.

lofty hamlet
#

position = set position here
user has a position in this list

I do change this for what ?

quartz kindle
#

@lofty hamlet whatever you want to show, i dont know what data do you have in your database

lofty hamlet
#

This :

quartz kindle
#

if you want to show only the number, you can probably just use the loop index

lofty hamlet
#

?

#

Look

stable pollen
#

@quartz kindle Got help from people on another server, apparently I need to do import { Client } from "eris"

quartz kindle
#

@stable pollen how about import { Client } from "eris"?

lofty hamlet
#

🙂

quartz kindle
#

lmao

#

i was about to say that

lofty hamlet
#

Me ?

quartz kindle
#

no, marvin

lofty hamlet
#

Oh ok :issou:

quartz kindle
#

where do you want to write the position?

lofty hamlet
#

In embed

#

In footer

quartz kindle
#

ok, so then do what i said

#

let position;

#

in the loop, if the current user is the same as the author, define the position

lofty hamlet
#

Mmh

#

You can edit my command and send and explain i'm tirtred and i'm backa man when i'm tirred

quartz kindle
#

im not gonna do it for you

lofty hamlet
#

:issou:

quartz kindle
#
// this is a loop. on each step of the loop, the user is different. you need to check if the user that is currently being processed in the current step is the same as the author
                    for (let i = 0; i < 10; i++) {
                        let user = bot.users.get(lvl[i].ID.split('_')[1])
//
            if(user.id === message.author.id) {} // this will check if the user is the same as the author. if this is true, then you need to set the position in the variable outside, and use it in the footer
//
                        content += `${i + 1}. __${db.get(`MV3_${user.id}.pseudo`)}__ - **${lvl[i].data.nombre}**\n`
                    }```
lofty hamlet
#

But the author is not on the top 10

quartz kindle
#

if the author is not in the top 10, then you need to get its position from the database

lofty hamlet
#

How ?

quartz kindle
#

get it from lvl

#

lvl.find()

lofty hamlet
#

🤔

quartz kindle
lofty hamlet
#

Lvl.find mmh ok

quartz kindle
#

or .findIndex() assuming the array is already sorted, which it should be

lofty hamlet
#

I want just add in footer the position in the classment

#

You can just send me what i do make ?

#

The .find or loop ?

quartz kindle
#

lvl.findIndex()

lofty hamlet
#

?

#

Just findinedex ?

#

Here how i can use findindex ?

quartz kindle
lofty hamlet
#

Yeah but with quick db and my database

quartz kindle
#

you have lvl, thats your array

lofty hamlet
#

lvl.findIndex(message.author.username)

#

Oh no mmh

manic light
earnest phoenix
#

Does StreamReader.ReadLine in C# include a \n at the end?

amber fractal
#

@manic light db.fetch must not return a promise then.

manic light
amber fractal
#

idk what db your using so you'll need to read your db's docs

manic light
#

quick db

amber fractal
winter basalt
#

how do you add button thingy?

manic light
#

me ?

grizzled jackal
#

button thingy you gotta be more specific than that lol

tacit stag
#

How to delete a sent image in a specific channel using discord.js?

#
if(message.channel.name === "testing") {
    if(message.attachments.size > 0) {
      if(message.attachments.every(attachIsImage)) {

        let Attachment = (message.attachments).array()
        Attachment.forEach(function(attachment) {
          Attachment.delete();
        });
      }
    }
  }```
This doesn't seem to work
#

it stops working at Attachment.delete()

#

would just message.delete() work?

earnest phoenix
#

for discord.js
is there a way to set a specific userID for command permissions?
i might have missed it

#

I saw stuff about setting roles that can use three bot commands, but I only want a specific user to be able to use it

tacit stag
#

check to see if: javascript if(message.author.id == userID) { //if sender is userID, then run this code. }

#

thats for a specific command

earnest phoenix
#

Ye its only for one command

#

That's perfect, thanks

tacit stag
#

no problem

#

Is anyone here experienced with loading a bot onto heroku? I keep having error messages

earnest phoenix
#

Hey my bot uses search results to play song I was that it plays first song of search result

#

Like rythm

#

Can anyone help

tacit stag
#

I won't be much help, dont have much experience with that, but id love to hear the answer. Trying to make a bot that does webscraping on a specific site to output data, so this might help

fallow spire
#

I have a question, if my Bot Contains 2-3 Copy and Pasted Commands, is that ok?
I have 20 Selfmade Commands rn

earnest phoenix
#

i think that is the wrong channel but yes, i think it is

fallow spire
#

Ok ty

stray wasp
#

If I'm not mistaken everything in client.guilds.(guild).members.(member) is already cached?

earnest phoenix
#

?

#

how to make bot?

#

How to make it show the number of players in the game?

#

show the number where? in which game? @earnest phoenix

stray wasp
earnest phoenix
#

Game SCUM number of players on the server

stray wasp
earnest phoenix
#

you can scrape data from battlemetrics

#

yeah ^^

#

so um.. i can't make bot

stray wasp
#

whys that?

earnest phoenix
#

ok

#

@earnest phoenix

stray wasp
#

on chrome book?

earnest phoenix
#

Download vs code

#

Make a bot

#

with programming it

#

and then 3.

#

stop giving dumb instructions

#

Node index.js

stray wasp
#

bruv

#

Skipper

earnest phoenix
#

@earnest phoenix stop whatever you are doing

stray wasp
#

not helping

earnest phoenix
#

stop living? i would if i could ngl

stray wasp
#

mailchain is terrible to read

earnest phoenix
#

If he asks basic stuff like "How to make a bot" and then after reading faq still asks how to then i give him instructions how to

#

because they didn't read the faq

#

anyways

stray wasp
#

or even click that link

earnest phoenix
#

i um.. i not even how programming-

stray wasp
#

ok

#

go onto youtube

earnest phoenix
#

or just

#

read the damn faq because it describes everything

stray wasp
#

search up how to code js or python or whatever you want to learn

earnest phoenix
#

it tells you where to get started

#

i did-

#

just a reminder

stray wasp
#

FreeCodeCamp is normally a good channel

#

but can be boring

earnest phoenix
#

youtube channels are really bad for learning

#

shut up they sometimes are

stray wasp
#

or if your a alpha male you could read docs

earnest phoenix
stray wasp
#

nice embed

#

lul

earnest phoenix
#

.-.

#

w- well um- i can say i not highly understand English language and i'm from Poland so i guess i need learn English first..

#

half of the people here don't have english as their mother tongue either

#

i don't