#development

1 messages · Page 750 of 1

empty owl
#

you cant grab it from old messages

sudden geyser
#

pretty sure you can

empty owl
#

idk

#

but how do you get the embed content from a message

#

message.embeds returns object object soo

#

and message.embeds[0]

#

returns nothing

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sinful lotus
#

what is your shoukaku version

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.

#

One message removed from a suspended account.

sinful lotus
#

latest should be stable

#

even on dev

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

how to install Python 3 on glitch.com? Any console commands?

mossy vine
#

iirc its installed by default

earnest phoenix
#

no it has python 2 installed

#

It has 2.7 Installed

mossy vine
#

pip3 install -U discord.py?

earnest phoenix
#

won't work either

mossy vine
#

i dont think you can do anything then

earnest phoenix
#

does heroku Supports py3?

#

@mossy vine

mossy vine
#

i dont know if glitch allows you to install stuff, but just in case, run it with sudo

earnest phoenix
#

sudo install discord.py?

mossy vine
earnest phoenix
#

kk

modest maple
#

Just fyi D.py requires 3.5.5 or newer

#

Also wouldn't recommend either glitch of heroku

slender thistle
#

Wasn't it 3.5.3

modest maple
#

Thing it's been moved up now

#

Cuz of aiohttp update

slender thistle
#

I thought it was 3.5.3 after the aiohttp update

restive furnace
#

@fluid basin yes i know, but stable d.js better than d.js-commando

vital lark
#

stable discord.js

#

imo; discord.js stable's memory allocation is fucking huge

mossy vine
#

master is a lot better from what ive seen and heard

valid frigate
#

well the hype is real

#

it just works

amber fractal
#

It is way better than stable

earnest phoenix
#

how to run multiple scripts at the same time

valid frigate
#

deferring

#

?

earnest phoenix
#

@earnest phoenix what you mean

#

how to make command handlers in py

#

js

#

no i mean from additions like kick.js or ban.js

#

like those

west spoke
tulip wave
#

You use a command handler for that

west spoke
#

^

modest maple
#

thats not even necessarily a command handler

#

thats just basic programming

#

xD

tulip wave
#

@vital lark d.js allocation is huge ngl for sable and master

earnest phoenix
#

@tulip wave how old r u?

#

😳

modest maple
tulip wave
#

@earnest phoenix why you ask?

modest maple
#

dont pull no funny business jade, hes onto you skyPolice

tulip wave
#

Fug

earnest phoenix
#

never seen so much typos im one simple sentence

sage bobcat
#

One message removed from a suspended account.

modest maple
sage bobcat
#

One message removed from a suspended account.

tulip wave
#

Welcome to rain on your screen

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

LMAO

sage bobcat
#

One message removed from a suspended account.

tulip wave
#

You end up hitting q when you try type m

sage bobcat
#

One message removed from a suspended account.

tulip wave
#

Cuz that's how fucking water works on the screen

earnest phoenix
#

water sucks

modest maple
earnest phoenix
#

i once died cause of water.

sage bobcat
#

One message removed from a suspended account.

vital lark
#

@tulip wave it always has been

#

I've only really used Stable in 2017 and early 2018

restive furnace
#

d.js memory allocation small to jda

vital lark
#

ehh

#

JDA redid the cache issues

#

with v4

restive furnace
#

but still its smaller, cause 100 server d.js bot uses ~ 70mb ram and JDA ~ 100 mb

earnest phoenix
#

how to snipe (make snipe command)

vital lark
#

mmm

#

you basically make a message delete event and save it in a cache pool and get it from there

earnest phoenix
#

ok

vital lark
#

wdym it's broken

earnest phoenix
#

I'm not editing a single file since 3 hours

restive furnace
#

but if its still open in background

earnest phoenix
#

hi since i couldn't solve that sql backup for that JSON i use and save the prefix and log channel and my question is can emg be done somehow to set the language on the bot

#

because I want a community bot that can be used in multiple languages

#

pl -lang hun or eng or russian etc.....

#

if somebody knows how to solve it or how to save other languages, i would do it

mossy vine
#

lang hun pogey
but you could just save the chosen language in your db as you do with other data

earnest phoenix
#

but how do i tell her that tongue is dutch and that she writes it in her native language etc ...

earnest phoenix
#

how can I see how many times has an command been executed in d.js?

#

I have to code something myself?

modest maple
#

shocked yes just have a counter or somthing

earnest phoenix
#

oh:(

#

oh no imagine incrementing an int 😢

#

well, the solution is actually surprinsingly simple

#

all we have to do is not incrementing a int

modest maple
#

i mean it is just counting

earnest phoenix
#

what can happend to this little kounter

analog roost
#

welcome to america

earnest phoenix
#

?

#

this isn't america

#

this is dbl

#

not america

analog roost
#

😦

earnest phoenix
#

this is mars

#

yes, you're on mars

#

(no)

valid frigate
#

command counting is pretty simple

#

have a database that has two fields, command name and usage count

#

or collection/table depending on db type

earnest phoenix
#

erm

#

yes

tepid hedge
#
            if(!mutedRole) continue;

            if(Date.now() > time) {
                console.log(`${i} is now able to be unmuted!`);

                member.removeRole(mutedRole);
                delete bot.mutes[i];```
#

Even though its what should be used?

modest maple
#

removeRole isnt a thing in that code

#

caps? maybe

tepid hedge
#

its not I looked it up

#
member.removeRole(role).catch(console.error);```
#

thats whats on the web

sudden geyser
#

What did you define member as?

modest maple
#

either member or .removeRole is undefineed

tepid hedge
#

let member = guild.members.get(i);

#

believe its in error in my mutes.json because nobody is currently muted

#

which makes sense why it would fail because there is no role to take from anyone

sudden geyser
#

Maybe, is i an item from the json list?

tepid hedge
#

nevermind

#

its not an error in the mutes file

#

i is the ID it logs in the console when someone is unmuted

#

not sure what it is

#
        for(let i in bot.mutes) {
            let time = bot.mutes[i].time;
            let guildId = bot.mutes[i].guild;
            let guild = bot.guilds.get(guildId);
            let member = guild.members.get(i);
            let mutedRole = guild.roles.find(r => r.name === "Custom Ban");
            if(!mutedRole) continue;```
#

Not the full code

#

@modest maple tried what you said with caps, doesnt work

#

remove role is defined through const Discord = require("discord.js");

glad charm
#

Is mutes a list of ID's?

tepid hedge
#

bot.mutes?

glad charm
#

Obviously.

#

A map.

tepid hedge
#

Yes

#

I'm using liveshare to code from my pc to the vps

#

that's the only inaccessible file since it doesn't save

glad charm
#

What are you trying to do and what is the error?

#

OH member is undefined?

tepid hedge
#

let member = guild.members.get(i);

#

its supposed to remove a role

glad charm
#

Can you show me exact what mutes is?

earnest phoenix
#

incorrect capitalization, it's supposed to be removeRole

glad charm
#

I think you just need to destructor it assuming it's a map.

earnest phoenix
#

and yeah, it probably didn't find a member from the guild

glad charm
#

Well he had the correct cap.

#

Either way member is still undefined.

tepid hedge
#

I had the correct cap I was checking it earlier

earnest phoenix
#

because there was no member found

tepid hedge
#

I believe the problem is that the user that is mentioned doesnt have the role

glad charm
#
for(const [key, obj] of bot.mutes) {/* code */}``` is how I'd do it.
#

key being the id presummably.

tepid hedge
#

I fixed it

glad charm
#

OH neat

#

What was it.

tepid hedge
#

I went to the vps and emptied mutes.json

#

the user was already unmuted

#

so he didnt have the role anymore

#

but it thought he still did

earnest phoenix
#

consider moving to a proper database btw

glad charm
#

^

#

JSON files aren't the way to go.

#

Consider MySQL or Sqlite

#

For small/medium bots.

tepid hedge
#

Define small/medium

glad charm
#

Like, less than 2k servers?

grizzled raven
#

love how people dont know how to read error messages

glad charm
#

^

earnest phoenix
#

and if you don't want to learn SQL you can use ORMs such as Keyv and Sequelize

tepid hedge
#

im less than 2k servers but 116k members would I be fine?

glad charm
#

Yeah

tepid hedge
#

Ok ill look into it

glad charm
#

Seeing this server is about 76k of those members lol

#

And I doubt this server is using your bot. :^)

tepid hedge
#

its not in this server

glad charm
#

Oh?

tepid hedge
#

this is a seperate bot im working on

glad charm
#

Ooo

#

You should still be fine.

tepid hedge
#

ok

glad charm
#

I also doubt all 116k members will be getting muted etc.

#

Along with what other commands it has.

tepid hedge
#

True

earnest phoenix
#

Consider MySQL or Sqlite
avoid mysql, oracle 🤢

#

if you're going big scale, use postgres instead of mysql

glad charm
#

Postgres is good.

tepid hedge
#

time to learn how to setup a database

proper epoch
#

is there a better way to phrase this description? I'm not good at mouth speaks

#

it says 'shakes a magic 8 ball. You can use it inside conversations'

opaque eagle
#

How is that related to development tho

valid frigate
#

it's bot development

#

umbrella topic

opaque eagle
#

ok

#

that looks good

#

Although idk why you're including the prefix in the name

valid frigate
#

remove the "you can use it inside conversations"

#

change "shakes" to "shake"

proper epoch
#

okay thanks

#

also @opaque eagle what should I use? the commands ext?

opaque eagle
#

I'd check the prefix in your command handler instead of hard coding it into the command's name

proper epoch
#

what makes that better?

opaque eagle
#

if you wanted to change the prefix in the future, you can just change it in that one spot instead of changing it in every command

proper epoch
#

yeah, that's smart

opaque eagle
#

plus, it enables you to add a custom prefix feature in the future if you'd like

earnest phoenix
#

how would i get a reload command to work with multiple folders Ex: ./user./userinfo.js

atomic raven
#

Hey guys, I want to try making a discord bot for my server, Ive done some javascript and have the basics up and running.
Have a question about some code though! What I want the bot to do is that it read user input in a channel lets call it "numbers". Then users in discord type their number in the channel and I want the bot to add the amount of users with the same numbers.

empty owl
#

what

#

@atomic raven i dont get the last sentence

atomic raven
#

Ehm

#

Example, 5 people enter 2, 3 people enter 8 and 13 people enter 19

The bot should then type out how many people were in each instead of me manually counting how many in each.

A bonus would be for the bot to send 1 message per number and tell how many of each role have the number.

Example,

#2: 5 people, 1 Swede, 3 Danes, 1 Norse

8: 3 people, 3 Swedes

19: 13 people, 4 Danes, 7 Danes, 2 Norse

empty owl
#

well

#

you can get the message

#

then detect if it startsWith a number

#

then get the number

#

then add a digit to an array

#

then get the .size

#

then .send the number

#

thats how I would do it

#

im not completely sure that will workt ho lol

atomic raven
#

alright ill try that 🙂

empty owl
#

ok

distant plank
#

I have a doubt, I am creating a mute command, and if the mute time is specified a timeout is created, but I have another unmute command, but it is in another js file, is it possible to stop the timeout of the other js file?

empty owl
#

@distant plank just remove the role

#

let the timeout just clear itself

distant plank
#

@empty owl I hadn't thought about that xD

empty owl
#

lol

#

you dont really need to stop the timeout if there is no role

#

to remove

sudden geyser
#

you technically can, but it's more work than just letting it time out itself (e.g. save a list of timeouts then remove if unmuted)

earnest phoenix
#

can you make a bot stay in a voice channel 24/7

restive furnace
#

Yes, but the bot needs to be online 24/7, eg. if you using heroku/glitch there WILL come some downtime cause high usage of the services.

marble juniper
#

and sometimes glitch will uninstall a random module

#

if you don't ping it every 4 minutes

fading frigate
#

.

earnest phoenix
grizzled raven
#

for 12 hours lol

#

glitch 👏 doesnt 👏 run 👏 for 👏 more 👏 than 👏 12h

earnest phoenix
#

Well, with this extension it does

glad charm
#

The fuck is glitch

grizzled raven
#

ok

#

@earnest phoenix when your uptime reaches 15 hours tell me

earnest phoenix
#

Ok

#

you can't have 24h hosting and stability for free at the same time, pick one

earnest phoenix
#

Stability? Maybe. 24h "hosting"? Yes

#

Glitch is a little bit stable than discord API servers

green kestrel
#

cheap, stable, secure. pick 2.

earnest phoenix
#

Cheap yes

green kestrel
#

glitch comes under cheap and secure, imho

earnest phoenix
#

Secure yes (just have private project)

#

Stable...

green kestrel
#

it isnt stable, it has the 12 hour timeout and apart from that it has more outage than a dioreahh patient.

#

ive been here just over 2 months and iirc there have already been a ton of quite major glitch outages

#

i notice when there are some because a lot of the 'lesser' bot lists go down, as thats where theyre hosted

earnest phoenix
#

@glad charm a "IDE"

earnest phoenix
#

i want a phpmyadmin system where i save data eg prefix, xp, lvl, log channel etc ...

how can i solve it because i get to the connection part but i have to rewrite file and get it out of the table i am not really translating right now it is looking at data from a json file it works fine only if there is sql then i can handle it from web page ?

slender mountain
#

question:

I am having my bot react with random emojis from the client.emojis datastore, with:

var emojis = bot.emojis.map(emoji => emoji.id);
message.react(bot.emojis.find(emoji => emoji.id === emojis[getRandomInt(emojis.length)]));

However, sometimes it throws this error:

#

Any idea what might be causing this?
and what I can do to prevent it?
Sometimes throws this error as in sometimes it works fine and reacts and other times it breaks with this error

cinder patio
#

You need to pass an emoji, mot an emoji id afaik

#

try bot.emojis.random()

late hill
#

no reason to map, random and find

#

use random^^

atomic quarry
#

I'm having problems with line 105

cinder patio
#

and what are the problems?

atomic quarry
#

/home/runner/index.js:106
return message.channel.send({
^^^^^^

SyntaxError: Illegal return statement

late hill
#

not sure because large amount of code

#

But I think you might have closed the listener above that

#

Meaning your return statement is just "flying" there

atomic quarry
#

So how do I fix it?

late hill
#

Well

#

If that is the issue

#

By not closing the listener yet?

#

yeh

#

That is indeed the issue

atomic quarry
#

Ok

late hill
#

There's also an issue in your blacklist array

#

at the end

#

"id, id" instead of "id", "id"

#

Also

#

You probably wanna go ahead and put the blacklist stuff above the commands

#

As the point of the blacklist is that they wouldn't be able to use commands..

atomic quarry
#

Ok

#

Ok I ran the help command after I started the code so far it's working

earnest phoenix
#

i want to make a welcome message on this oylat that you can change and i went to json i have such a problem that i could do it to insert guild.name in json

#

that's not good, though

#

and I know what's the problem but I don't know how to fix it so I can get it get it in json

wicked pivot
#
const discord = require('discord.js')

module.exports = async (bot, channel, user) => {
    guild = user.guild

    let embed = new discord.RichEmbed()
    .setTitle("Un utilisateur à commencer à écrire :")
    .setDescription(`
Nom de l'utilisateur : ${user.username}

Channel où il à commencer à écrire : <#${channel.id}>`)
.setColor('#dc143c')
.setTimestamp()
.setFooter(`Logs serveur ${guild.name}`)

    bot.channels.get("657162338184724482").send(embed)
}```
#

help

late hill
#

Seeing as you're using user.guild which works fine, I assume user is a GuildMember and not a User, GuildMember doesn't have a username property.

#

As for the deleted channel, are you trying to log the channel the command was used in? It'll show as deleted-channel if you don't have access to that channel.

quartz kindle
#

@earnest phoenix you can do something like this "welcome to %GUILDNAME%" and save in json

#

and when you use it, you do jsonfile[guildId].joinmessage.replace("%GUILDNAME%",guild.name)

earnest phoenix
#

help

quartz kindle
#

.replace

earnest phoenix
#

where?

#
    let joinmessage = JSON.parse(fs.readFileSync("./setjoinmessage.json", "utf8"));
  if(!joinmessage[message.guild.id]) {
    joinmessage[message.guild.id] = {
        joinmessage: botconfig.joinmessage,
      };
  }
  let jmessage = joinmessage[message.guild.id].joinmessage
  message.guild.channels.get('656407826876596224').send(jmessage); 
});```
#

sorry now my brain doesn't cut much

quartz kindle
#

i already told you lol

earnest phoenix
#

now I'm just so stupid or no one knows where to put it? this line jsonfile[guildId].joinmessage.replace("%GUILDNAME%",guild.name)

#

@quartz kindle please help because it hurts me not to cut

#

full code

#

JSON name setjoinmessage.json

#

code

#

{"guild id":{"joinmessage":"> Üdvözölek a %GUILDNAME% Discord szerverén\n > Jó szórakozást kíván az \n > OTAMOON csapata"}}

#

index.js

#

code

#
    let joinmessage = JSON.parse(fs.readFileSync("./setjoinmessage.json", "utf8"));
  if(!joinmessage[message.guild.id]) {
    joinmessage[message.guild.id] = {
        joinmessage: botconfig.joinmessage,
      };
  }
  let jmessage = joinmessage[message.guild.id].joinmessage
  message.guild.channels.get('656407826876596224').send(jmessage); 
});```
#

anyone can help because I really don't understan

green kestrel
#

🥄

earnest phoenix
#

?

green kestrel
#

its a spoon. for spoonfeeding.

earnest phoenix
#

um okay

proper epoch
#

lol

west raptor
#

@earnest phoenix what's your native language

restive furnace
#

How I could split (on nodejs/d.js) message content into array like this message content is: halo | no yes and then the array would become : ["halo", "no yes"], i tried searching from mdn and stackoverflow but i didnt find the right one.

west raptor
#

.split(" | ")

restive furnace
#

lemme trr

west raptor
#

basic is

#

js

#

fucking mobile

earnest phoenix
#

@west raptor Hungary

west raptor
#

oh

earnest phoenix
#

hmm ?

restive furnace
#

i didnt mean that like it splits into arguments/params

#

i mean like the luca bot command kick -kick user reason | time

earnest phoenix
#

database or json backup which is better

west raptor
#

database

#

always

earnest phoenix
#

and which database eg: xlamppmysql linux server or mongodb linux server

west raptor
#

it really depends on your situation

#

mongodb might be the better in your situation

#

mongo has great support JavaScript

earnest phoenix
#

good because i don't know how to use install etc ..

#

you can give me some guidance

#

video?

earnest phoenix
#

thank 😛

surreal sage
#
    if (command === "avatar") {
        const rUser = message.mentions.users.first();
        if(rUser === null) {
        const authoravatar = message.author.avatarURL
        const authorusername = message.author.username
        const embed = new Discord.RichEmbed()
        .setAuthor(authorusername, authoravatar)
        .setFooter(`CDeveloper's Bot`)
        .setImage(authoravatar)
        .setTitle("Avatar Url")
        .setURL(authoravatar)
        .setColor('#ff1493')
        message.channel.send(embed)
        } else {
            const embed = new Discord.RichEmbed()
            .setAuthor(rUser.username, rUser.avatarURL)
            .setFooter(`CDeveloper's Bot`)
            .setImage(rUser.avatarURL)
            .setTitle("Avatar Url")
            .setURL(rUser.avatarURL)
            .setColor('#ff1493')
            message.channel.send(embed)
        }
    }``` it says "username" of user does not exists
#
(node:11) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'username' of undefined
at Client.<anonymous> (/home/container/bot.js:482:30)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:198:13)
(node:11) 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: 1)
(node:11) [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.```
#

its on the right position

#

and i just came out of nothing

#

eval does not work..

sudden geyser
#

did you mention anyone

surreal sage
#

no

#

author tag/username

sudden geyser
#

rUser would never be null as it doesn't return that

surreal sage
#

no

#

theres something wrong there

sudden geyser
#

that's not the issue

surreal sage
#

oh

#

oh y

sudden geyser
#

rUser would never be null as it doesn't return that

#

it's going to your else statement

surreal sage
#

ah

#

so no if null

#

just else {

#

?

sudden geyser
#

check if rUser exists, as it returned undefined if no user is mentioned

surreal sage
#

if (command === "avatar") {
const rUser = message.mentions.users.first();
if(rUser === null) {
const authoravatar = message.author.avatarURL
const authorusername = message.author.username
const embed = new Discord.RichEmbed()
.setAuthor(authorusername, authoravatar)
.setFooter(CDeveloper's Bot)
.setImage(authoravatar)
.setTitle("Avatar Url")
.setURL(authoravatar)
.setColor('#ff1493')
message.channel.send(embed)
} else {
const embed = new Discord.RichEmbed()
.setAuthor(rUser.username, rUser.avatarURL)
.setFooter(CDeveloper's Bot)
.setImage(rUser.avatarURL)
.setTitle("Avatar Url")
.setURL(rUser.avatarURL)
.setColor('#ff1493')
message.channel.send(embed)
}
}

#

oops

#

never mind that

#
    if (command === "avatar") {
        const rUser = message.mentions.users.first();
const embed = new Discord.RichEmbed()
            .setAuthor(rUser.username, rUser.avatarURL)
            .setFooter(`CDeveloper's Bot`)
            .setImage(rUser.avatarURL)
            .setTitle("Avatar Url")
            .setURL(rUser.avatarURL)
            .setColor('#ff1493')
            message.channel.send(embed)
        } else {
            const authorusername = message.author.username
        const embed = new Discord.RichEmbed()
        .setAuthor(authorusername, authoravatar)
        .setFooter(`CDeveloper's Bot`)
        .setImage(authoravatar)
        .setTitle("Avatar Url")
        .setURL(authoravatar)
        .setColor('#ff1493')
        message.channel.send(embed)
        }
    }``` this?
sudden geyser
#

nope, you still need that if statement

surreal sage
#

what to look at then? if rUser = true?

#

or something

#

i could use if args = null

#

so i add a const of args

sudden geyser
#

but you need to check if it exists by seeing if it equals undefined or using a truthly value

surreal sage
#

ah undefined

earnest phoenix
#

@surreal sage

let rUser = message.mentions.users.first() || message.author

surreal sage
#

what?

#

i dont need

earnest phoenix
#

@sudden geyser else he never learn.

sudden geyser
#

that's what you're doing

#

but okay

sage bobcat
#

One message removed from a suspended account.

sterile minnow
#

@surreal sage const authorusername = message.author.user.username

#

i think

surreal sage
#

no...

#

thats undefined

sterile minnow
surreal sage
#

lol

sterile minnow
#

a bot is online on mobile how can i do that too?

modest maple
#

Read the docs

mossy vine
#

is it even possible for bots

#

without doing sketchy shit

sterile minnow
#

I think

restive furnace
#

or if he does host it mobile or smh

wheat jolt
#

That doesn't exist

#

There's no mobile discord api

#

Only discord api

restive furnace
#

i mean like if it detects if its hosted on mobile

earnest phoenix
#

lol it doesn't detect anything

#

it's just an identifier you can send to the api to indicate the activity is on mobile

#

the mobile apps do it automatically in the behinds

wheat jolt
#

^

restive furnace
#

k

#

I might do my own custom lib xd

west raptor
#

why

#

you're just asking for a API ban

earnest phoenix
#

you're allowed to use the mobile indicator on bots

slender thistle
#

Does d.js Member inherit User so that devs could use <Member>.username or does that vary per version

wheat jolt
#

you have to use <Member>.user to get the <User>

restive furnace
#

How i can make the reason thingy work (on d.js-master) ``` message.guild.members.ban(user.id, { options: { days: 7, reason: a[1] }})

#

a[1] is the reason btw (and it does ban the user and a[1] isnt undefined)

glad charm
#

You shouldn't have to wrap it with options it should know that by default.

restive furnace
#

so just { days: 7, reason: a[1] }?

glad charm
#

YEah

restive furnace
#

k

glad charm
#

Also you ban on the guild and pass it the member.

#

Unless there's two ways to ban?

#

Lemmie check real quick

restive furnace
#

it wrkd, thank YOU.

#

theres 2 ways to van

glad charm
#

OH lol

#

neat

restive furnace
#

ban

glad charm
#

Yeah there is. 😄 Glad to help.

restive furnace
#

message.guild.members.find(... u.user.tag and u.user.tag ...) is very unstable on d.js 😞

glad charm
#

Unstable? What do you mean?

restive furnace
#

it sometimes picks random member even tho member exist in casesens

glad charm
#

I think your condition is messed up.

#

That's not a djs issue.

earnest phoenix
#

you can do guild.members.fetch().then((members => {members.find(i => i.d.k == "Which statement u will use")}))

restive furnace
#

maybe

earnest phoenix
#

more stable

#

but has a tiny bit of delay

#

just 1 ms or so but yeah

restive furnace
#

expect im on d.js-master and fetch() method is deleted.

earnest phoenix
#

no

#

its, like i mentioned, guild.members.fetch()

restive furnace
#

oh yea

earnest phoenix
#

not guild.fetchMembers()

modest maple
#

or is bycharm just having a moment

earnest phoenix
#
import { CrunchyRoll_Today } from CrunchyRoll``` js op
modest maple
#

xD

#

for some reason

#

it didnt want to pull it out of the folder that i was next to

#

so i moved it up one directory

#

and it worked

#

idk why

#

but somtimes weird things do weird things

sudden geyser
#

Not JS until you remove all form of snake case

earnest phoenix
#

kubernetes

valid frigate
#

that's why i call them k8s

earnest phoenix
#

2 hours into the k8s course

#

this is actually sicc

#

this man goes absurdly in depth explaining every command and what happens behind the scenes

#

cant recommend him enough

west raptor
#

@earnest phoenix never really looked into kubernetes, what is it

earnest phoenix
#

its a container management & automation & load balancing & networking of machines

west raptor
#

wew

earnest phoenix
#

that graph above he was explaining how the master (k8sapi) handles distribution of workload

#

like if i specify in the config to launch 10 instances of a bot, it will defautly start like 3 on each vm/machine or we could specify which pods / vms to run on in config

#

its really cool if your into like enterprise level scalability and architecture @west raptor

#

the full workflow is i push code to github -> it goes to travis ci for build & testing of images -> travis ci publishes to docker hub -> kubernetes handles the updating & distribution of containers across machines/vms and sets up networking & load balancing

#

so idealy i just push to github and bam badaboom it is distributed across all my servers andd scales as need be

west raptor
#

@earnest phoenix interesting, I'll check it out

#

thanks

earnest phoenix
#

yea its mega cool

#

if you dont know about a container software i recommend doing docker first though

#

since k8s is pretty much orchestration of containers and images etc

earnest phoenix
#

Hi is so I can put ranks on my discord

modest maple
#

What

#

More info needed

earnest phoenix
#

is you can has english properly

modest maple
#

Possibly in better English aswell

#

Damn cry u beat me to it

sage bobcat
#

One message removed from a suspended account.

west raptor
#

ok we get it

#

because everyone's english is perfect

tepid hedge
#

@earnest phoenix Your in the wrong place, that would be better suited for the general discord help server. This is focused around bot development

earnest phoenix
#

Were in need gelp

#

Help

slender mountain
west raptor
#

Anyway to fix this in vscode? All the deps are in the shell.nix could not compile `libc`. process didn't exit successfully: `/nix/store/a05a9mh9vyaj8gq559c5ymxr6i059hdh-rust/bin/rls --crate-name build_script_build /home/april/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.66/build.rs --color never --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=0b28db3be857b546 -C extra-filename=-0b28db3be857b546 --out-dir /home/april/dev/rust/rin/target/rls/debug/build/libc-0b28db3be857b546 -L dependency=/home/april/dev/rust/rin/target/rls/debug/deps --cap-lints allow --error-format=json --sysroot /nix/store/wcffbmgzlv3sk47h0lfvb86vy9ki42q3-rust-1.40.0-2019-12-16-73528e339` (exit code: 101) error: could not compile `cfg-if`. error: could not compile `lazy_static`. error: could not compile `autocfg`.

distant plank
#

Is it possible to import a variable into a module without constantly requiring it?
for example not having to be doing this

//Module.js
exports.logmsg = (msg,color) => {
console.log(msg + color)
}

//index.js

const log = require("Module.js")
//First function
log.logmsg(message,"BLUE")
//Second function 
log.logmsg(message,"RED")

that I don't have to be putting the "message" variable in the function

sudden geyser
#

You could make an instance through something like a class.

distant plank
#

how?

sudden geyser
#

if you're just making a helper function I'd rather keep passing the message as an arg, but if you want to have that log class have multiple methods like logging errors, you can use a class.

class logg {
  constructor() {
    this.message = message;
  }

  logmsg() {
    // logic here
  }
}```
vital lark
#

some people don't know what classes are

#

so we don't suggest them

#

because most bot devs just copy pasta and spam us with reference errors that x is undefined when they copieed it

zealous veldt
#

If it makes sense to use a class, there's no reason not to.

#

If the person doesn't know what a class is, explain it to them

sudden geyser
#

only one way to learn how to use classes blobworker

low wasp
#

👏 @dusk thorn

dusk thorn
#

@low wasp Want me to explain what I'm trying to accomplish so you understand?

low wasp
#

Yep

dusk thorn
#

That function that I posted works in a way that it sends a message and waits for the result from the person that issued the command that this function is used in. In this new case I need to change it to allow for another person to give it the answer it desires.

#

The command is to be issued by someone else then the person answering the question this function puts out is mentioned in the command

#

command @mentionPersonThatWillAnswerThisQuestion

low wasp
#

So you need to get the mentioned user and put that in the filter

dusk thorn
#

I'm not entirely certain on how I can go about that, I'm still kinda stupid when it comes to a lot of this stuff

low wasp
#

Get the mentioned user and the filter becomes m => m.author.id === <mentioned>.user.id

#

@dusk thorn

dusk thorn
#

well I can't have it lose it's previous purpose

#

it's used in other places

low wasp
#

You can send the filter through when you call the function

dusk thorn
#

Can you give an example of that because once again kinda oblivious to how

low wasp
#
let listenFilter = (m => m.author.id === mentioned.user.id)
 
waitor(message, text, listenFilter, etc)```
#

@dusk thorn

dusk thorn
#

I seen

#

How would I use listenFilter over the regular filter?

#

I only want it to be active when I call for it

low wasp
#

Ur function checks if filter is sent into the function and uses it

dusk thorn
#

I'm still completely oblivious, I'll ask my partner who actually made the function how they could do this GWchadThonkery

#

Tiny brain cannot figure out how dboatsOmegalul

low wasp
#

The function uses filter if it is passed into it when the function is called

waxen meteor
#

bruh so idlerpg is able to set their status to idle

#

how do I learn this secret technique

prime cliff
#

It's called read your lib docs LULW

valid frigate
#

unless ur lib name is d.py

slate wave
#

Is there any way to get the person who deleted a message from the messageDelete event on discord.js?

west raptor
#

message contains the user

#

Message#author

slate wave
#

Who sent the message not the person who deleted it

#

I want the person who deleted it

west raptor
#

yes 🙃

#

oh

#

fetch latest audit log ig

#

if there is none assume it was the user's own message

slate wave
#

so message.guild.fetchAuditLogs.first()

west raptor
#

fetchAuditLogs seems like it should be a method

#

it is

slate wave
#

Oof

slender thistle
#

@valid frigate

west raptor
slate wave
#

Thats what im on rn

valid frigate
#

from what i hear the library docs have a bad reputation lolw

slate wave
#

im just blind asf

west raptor
#

Guild#fetchAuditLogs() then the entries property

#

which is a collection

#

so first() should work

slender thistle
#

if you know how to use them

#

just like with any docs

slate wave
#

@west raptor Thanks, it was just js let logs = message.guild.fetchAuditLogs().then(logs => { let embed = new Discord.RichEmbed() .setTitle("Message Deleted!") .addField("Author:", message.author) .addField("Executor/Deleter:", logs.entries.first().executor) .addField("Content", message.content) logsChannel.send(embed); });

#

For future reference

merry thistle
#

I can't get a bit it has a false account in I can't get it to work

#

Bot

vital lark
#

what

restive furnace
#

msguathorbot ? "Yes" : "No"

#

^ on d.js

#

or eris

vital lark
#

Eris and discord.js are similar in getters

analog roost
#

discord.js personally is better

surreal sage
#

what is or in a statement like › || « and ‹

vital lark
#

what

#

or doesn't exist in JavaScript

surreal sage
#

oof

warm marsh
#

Or exists it just isn't written as or it uses the operator ||

mossy vine
#

^

warm marsh
#

Nvm too early for this

river tartan
#

I’m looking to have a bot to assign roles. Can anyone help me with this?

prime cliff
#

@river tartan you can use @opaque light it allows you to create reaction roles where you click a reaction to get a role

river tartan
#

@prime cliff alright. How do I get Zira?

prime cliff
river tartan
#

Got her. And how do I get the right roles?

prime cliff
earnest phoenix
#

@slate wave You should make a condition because when a person deletes their own message it's not in the logs.

river tartan
#

Thanks

earnest phoenix
#

help me

#
    //prefix lekérése
  let settprefix = JSON.parse(fs.readFileSync("./setprefix.json", "utf8"));
  if(!settprefix[message.guild.id]) {
    settprefix[message.guild.id] = {
          prefix: botconfig.prefix,
      };
  }
  let prefixs = settprefix[message.guild.id].prefix
  //prefix lekérése

  let nyetEmbed = new Discord.RichEmbed()
        .setColor('#ff5930')
        .setAuthor(`${botusername} - ERROR`, bot.user.displayAvatarURL)
        .setThumbnail(bot.user.displayAvatarURL)
        .setDescription(':no_entry: You do not have **permission** to use this command! :no_entry: \n\n For more information ' + prefixs + 'permission-help ');

    if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send({embed: nyetEmbed});
    if(!args[0]) return message.reply("Please read to welcoem msg-t");

    let joinmessage = JSON.parse(fs.readFileSync("./setjoinmessage.json", "utf8"));
    joinmessage[message.guild.id] = {
        joinmessage: args[0]
    };
    let jmsg = joinmessage[message.guild.id].joinmessage

    fs.writeFile("./setjoinmessage.json", JSON.stringify(joinmessage), (err) => {
        if(err) console.log(err);
    });
    let prefixEmbed = new Discord.RichEmbed()
        .setColor('#30a2ff')
        .setAuthor(`${botusername} - SetWelcomeMessage`, bot.user.displayAvatarURL)
        .setThumbnail(bot.user.displayAvatarURL)
        .setDescription(':white_check_mark: Successfully changed welcome message ``' + jmsg + '``   :white_check_mark:');
        message.channel.send({embed: prefixEmbed});
}
restive furnace
#

``

modest maple
#

' + jmsg + '

#

thats the issue

#

also i cant freaking send it cuz its triggering

#

grrr

earnest phoenix
#

setwelcome error

#

send just does not detect the whole welcome msg

#

only >

#

setwelcomemsg coomads

#

setwelcomemsg this will

#

Szerver welcome message:
>

#

someone looking at what can i send invite link to test server and see what's wrong with me

#

just write a dm

#

pls help me

restive furnace
#

args.join...

#

btw whats the diffence of eris and d.js? (expect eris is faster)

quartz kindle
#

They are not necessarily different in perfomance

#

Its just two different libraries that do the same things but differently

restive furnace
#

ok

quartz kindle
#

Both of them can be extended and hacked to increase performance

#

Also "performance" is relative, it can be ram usage, network usage, cpu usage, processing time, latency, etc...

modest maple
#

altho not advised unless u know what youre doing fully

river tartan
#

I’m figuring out how to use Zira. Which page of the manual is for members to request roles?

green kestrel
#

this is the wrong server for that, @river tartan

#

you need to find @opaque light support

#

although i use that bot and i didnt struggle to set it up

#

cant remember where the help is though

river tartan
#

Okay just trying to work things out on it

#

Found it thanks

wheat jolt
golden raven
#

im making a rich presence in discord.py which update the no of users for that i need help please

#

My code:

	game = discord.Game(f"@mention help | Listening to {len(client.users)}")
	await client.change_presence(status=discord.Status.online, activity=game)```

and created a loop task
`client.loop.create_task(loop_presence)`
winged thorn
#

So what's the problem

golden raven
#

it gives AssertionError

winged thorn
#

No it doesn't

#

There is no assert keyword

#

How can it possibly give that error

golden raven
#

i want to update the presence every 10mins that the no of users will also update

winged thorn
#

Can I see the error traceback

golden raven
#

Exception in default exception handler Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/asyncio/base_events.py", line 1285, in call_exception_handler self.default_exception_handler(context) File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/asyncio/base_events.py", line 1257, in default_exception_handler value = repr(value) File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/asyncio/base_tasks.py", line 15, in _task_repr_info coro = coroutines._format_coroutine(task._coro) File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/asyncio/coroutines.py", line 274, in _format_coroutine assert iscoroutine(coro) AssertionError

winged thorn
#

I suggest you use discord.py tasks instead of making it youself

#

That should fix it I think

golden raven
#

how?

#

before i put the presence in on_ready event, it doesn't update

modest maple
#

@golden raven you code is right but it needs the () after the subrutine

winged thorn
#
from discord.ext import tasks

@tasks.loop(minutes=10)
async def update_presence():
    ...

update_presence.start()```
#

Your code before won't loop btw

#

It will only run once

modest maple
#

theres no issue creating your own tasks

golden raven
#

@modest maple it gives

Task exception was never retrieved                          future: <Task finished coro=<loop_presence() done, defined at <string>:23> exception=AttributeError("'NoneType' object has no attribute 'change_presence'",)>                       Traceback (most recent call last):                            File "<string>", line 25, in loop_presence                  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/discord/client.py", line 874, in change_presence                                          await self.ws.change_presence(activity=activity, status=status, afk=afk)                                            AttributeError: 'NoneType' object has no attribute 'change_presence' ```
modest maple
#

send the code

#

again with the update

golden raven
#
	game = discord.Game(f"@mention help | Listening to {len(client.users)}")
	await client.change_presence(status=discord.Status.online, activity=game)```

`client.loop.create_task(loop_presence())`
modest maple
#

where have you put this in reference to the rest of the code?

winged thorn
#

You didn't wait for the bot to be ready I bet

#

You can't change the presence if the bot hasn't logged in yet

golden raven
#

@modest maple can't understand

modest maple
#

send the full code

#

rather than just the snipped

#

snippet*

golden raven
#

it contains 300lines

modest maple
#

Put it in a hastebin

winged thorn
#

Just put the create_task line in an on_ready listener

#

Tbh

modest maple
#

but it might be cuz its not in the on_ready event but seeing that its a NoneType it might be that its getting called before actually defining client

#

also are you using Bot or Client?

winged thorn
#

It's because the websocket is none before it logs in

#

Change presence is through the websocket so if you don't have a websocket yet...

golden raven
winged thorn
#

yh also client isn't defined yet

#

but my previous point is still correct

modest maple
#

he does define client

#

at the top

#

altho as a bot

#

which is

#

lil confusing

winged thorn
#

It's referenced in the presence change coro before being defined

golden raven
#

@winged thorn ok now i will change

winged thorn
#

Just move the Coro below where you define client

modest maple
#

move the loop creation under on_ready

#

and yh

#

also

winged thorn
#

And that ^

modest maple
#

move ur commands into a seperate file

winged thorn
#

Well he doesn't need to

golden raven
#

ok

winged thorn
#

It still works fine

modest maple
#

he doesnt need to but it saves alot of effort in the long run

winged thorn
#

Cogs are the answer

modest maple
#

so you dont end up with a multi thousand line file where finding anything takes 20 mins

#

and no

#

cogs are not

#

but what ever

#

xD

winged thorn
#

Hmmm

slender thistle
#

Cogs are actually cool until you stop auto-loading one on bot start and wonder why it's not working

modest maple
#

mhmm

#

doesnt help that most people dont know how they work in general tho

slender thistle
#

At some point you give up on explaining HOW it works and just let them figure out the ready code or let them suffer

modest maple
#

yh

#

welp i just got 2/3 of the way into organising a DB to realise i missed a column

#

FFFFFFFFFFFFFFF

slender thistle
#

mongo for life mmulu

modest maple
#

i use SQL

#

cuz i like

#

altho i dont

#

but i like it a bit

#

its usefull

restive furnace
#

NoSQL gut

modest maple
#

SQL Alchemy is G and Very useful

restive furnace
#

k

#

is it like sqlite/mysql/postgres etc. or just like orm on js

modest maple
#

well its like SQL xD

#

hence the name

#

but its used for APIs etc with Flask

restive furnace
#

k

#

django is postgres xd

#

(its another orm for py)

modest maple
#

ik

golden raven
#

@modest maple same error

modest maple
#
client.run(token)```
#

cuz thats still a thing

modest maple
#

got a bit of a weird SQL lite bug

#

its Saving changes when removing a row

#

but on reboot it goes back to how it was

#

Adding items is fine

#

but its not saving changed by the delete command?

#

even tho:

#

Release_Conn.commit()```
#

is working fine

#

nvm

#

i found it

#

fecek

marble juniper
#
var images = {
    sonic: {}
}

images.sonic = function () {
    let response = 'ok'
 try {
   require("axios").get('https://sonic-bot-api.glitch.me/api/v1/images/sonic').then(function (Response) {
       response = Response.data
   })
 } catch (err) {
    console.log(err)
 }
 return response
}


exports.images = images
#

this code is for my node module

#

it is supposed to get a random image from my api

#

with the axios module

#

which comes with the node module

#

but it returns nothing

late hill
#

Because the response is set in a .then()

next grove
#

Hello, very sorry I wanted to ask why mentions arent working on my code, as they used to about a week ago.

restive furnace
#

.then(var => {}) isnt enough? i think then wont accept function

next grove
#

But since then it is not working.

marble juniper
#

what else could I do then

restive furnace
#

make ur then into .then(res => {})

marble juniper
#

ok

#

im gonna try and see if it works now

late hill
#

@next grove mentions used to be <@userid> for regular members and <@!userid> for nicked members

#

One of the recent updates made it so that your mentions are changed to <@!userid>

marble juniper
#

because if I use axios.get and make it a property instead of a function it works normally

late hill
#

Which is probably not supported in your code

next grove
#

Oh okay thank you very much!

#

That is very helpful!

restive furnace
#

recent
its been it since like almost year alrdy

late hill
#

No

next grove
#

It was working a week ago but seems to be broken now.

#

So, I would call it recent. If that is the issue that is.

late hill
#

It changes mentions to <@!userid> since the markdown/emojis/mentions are shown in your editor

west raptor
#

@restive furnace No

#

on canary mentions are now <@!

late hill
#

Not just canary anymore

next grove
#

Yeah, okay thank you 🙂

restive furnace
#

on stable too

next grove
#

I will try that!

west raptor
#

oh on stable too

marble juniper
#

just check if it is either <@ id > or <@! id >

next grove
#

Yeah.

west raptor
#

<@id> should be invalid now

restive furnace
#

it seems many ppl has canary then cuz my bot has been recieving <@id> and <@!id> like ~ 4 months alrdy

late hill
#

It's still valid

#

But your editor changes it

restive furnace
#

<@id> = username
<@!id> = nickname

late hill
#

And sends it as <@!userid>

west raptor
#

<@! has been on mobile always

next grove
#

Okay, well I will try that 🙂 thanks.

west raptor
#

iirc

#

@late hillalso yeah I forgot you can do <@id> manually

late hill
#

Yes

#

It changes those too

west raptor
#

wish they would make it consistent across the board

#

wha

late hill
#

Bots can still send them like that

#

I tested around

#

Any mentions sent by users are changed into that format

#

unless they use a selfbot I guess

#

or outdated discord

marble juniper
#

ok so

#

I changed it now to js try { require("axios").get('https://sonic-bot-api.glitch.me/api/v1/images/sonic').then(res => { return res.data }) } catch (err) { console.log(err) }

#

but I still get nothing

vital lark
#

console log res.data

#

and see what it prints

marble juniper
#

it does print the url

#

like it should

#

but if I do console.log and the function

#

then it returns undefined

#

this is when I call the function

vital lark
#

hmm

marble juniper
#

and this is what is in the logs

vital lark
#

is the function async

#

I recommend doing const data = await <request> which <request> is the request thing

marble juniper
#

hmm ok

vital lark
#

try making the function async and use await and return the value from axios

#

and make the message event async and do await func() which func() is the function you're using asynchrously

marble juniper
#

images.sonic = async function () {
    
 try {
   await require("axios").get('https://sonic-bot-api.glitch.me/api/v1/images/sonic')
   .then(res => {
    console.log(res.data)
       return res.data
   })
 } catch (err) {
    console.log(err)
 }
}
#

something like this?

vital lark
#

not quite

#

do const res = await <request>

#

and then return the data (res.data)

#

<request> is the axios request

marble juniper
#
images.sonic = async function () {
 try {
   const res = await require("axios").get('https://sonic-bot-api.glitch.me/api/v1/images/sonic')
       return res.data
 } catch (err) {
    console.log(err)
 }
}
#

so this?

#

mk

#

well if I console.log it it does show the random image link even with sync function and not async

vital lark
#

yea

marble juniper
#

but ok

#

lets see

vital lark
#

you can do sonic.images.sonic().then((data) => console.log(data)) if you don't like using await

#

since sonic() is a Promise, you can use then to get the value

marble juniper
#

well I changed it now

#

lets hope it works

#

still doesn't return anything

#

when it console.log's the res.data its all working fine

#

execpt if I use return

restive furnace
#

cause promises are weird

#

same is happening to me

vital lark
#

it's not really "weird"

#

you're not doing it right

#

sometimes when you use then to return something, it can get tricky

marble juniper
#

ok

#

then promise worked

#

everythins is fine

restive furnace
#

when i try to fetch smh from my db and it returns promise so if i do db.fetch({ where: { id: ??? } })
and return that it wont work

vital lark
#

ur welcome linko 02love

restive furnace
#

xd

marble juniper
#

did return the image link

#

xd

#

im just bad at coding

#

thanks for the help!

vital lark
#

no problem 02love

tight ferry
#

okay, discord's redirect URI gives me aids

#

can someone please help me unravel the mystery of what redirect URI I need to use for people to login to me site using discord?

mossy vine
#

so you basically want to implement oauth?

tight ferry
#

yes, and I have done it before, worked fine then. But not working now for some reason

#

when I was locally testing, I used https://localhost/callback and that works... But when I try to put my actual website in there, it comes back with invalid OAuth2 redirect_uri after clicking the login button

vital lark
#

you need to add the redirect url for dev & prod instances in the OAuth2 tab of your application

tight ferry
#

this works on my forum page.... The second I switch to the other url it stops working. The URL is included in my config as well as the OAuth2 page

valid frigate
#

is the censoring mandatory, because it's kinda easy to see through it

tight ferry
#

well

valid frigate
#

also you can't redirect to localhost since discord can't see it

#

if that's what you meant

tight ferry
#

no

#

I was testing locally

valid frigate
#

what is the other url?

tight ferry
valid frigate
#

oh

tight ferry
#

I really need this to work and I have no idea why it won't

valid frigate
#

so you want to allow users to login via discord

#

in that case it's probably your callback endpoint that's at fault

#

do you have any site errors/logs?

tight ferry
#

nothing shows up when I try

valid frigate
#

see if you can get some kind of error to appear/console log the flow of your code

tight ferry
#

I have been, nothing shows up. It just says the bot client is ready, list is started and then nothing after that

tight ferry
#

I fixed it

#

added /callback at the end

valid frigate
#

lol

#

gj

tight ferry
#

I did that before and it did NOT work, now it does

#

thank you xD

valid frigate
#

because your code might have changed

#

np

tight ferry
#

maybe

mossy vine
#

is there actually any difference between print()/input() and stdout.write()/stdin.readline()?
as in
does print output to stdout?
does input read from stdin?
is there any performance impact?
(all this considering python 3.6)

quartz kindle
#

idk about python, but in node, writing to stdout doesnt automatically add new lines, while console logging does

#

does print() add new lines?

mossy vine
#

yes

quartz kindle
#

yeah then thats probably one of the differences

#

performance impact should basically be the same as appending a new line to a string

mossy vine
#

according to my teacher its a very significant impact, and the code testing thing does not recognize output from print

#

(which i call bullshit as it worked for us with print but eh)

quartz kindle
#

heres one of SO's answers

print 99
is equivalent to:

import sys
sys.stdout.write(str(99) + '\n')```
#

so basically conversion to string plus appending a new line

#

there seem to be a few more intricate differences too, depending on the py version, you can look at some answers in there

mossy vine
#

im only concerned about possible performance impact

#

the way the code is scored is that they first compile it to an executable, and run that

#

and appearently using print affects the performance of that?

quartz kindle
#

how much do you have to print?

mossy vine
#

1 line

#

in the entire code

#

or 3 max

#

but usually 1

quartz kindle
#

the difference should be negligible lol

#

but you can time your executable by running it in a linux terminal/bash

mossy vine
#

the thing is

#

noone knows what they use to compile it to an executable

#

cuz there are like a dozen tools for doing so

quartz kindle
#

welp

#

i dont think it will make a difference, but using std directly should be nanoseconds faster

mossy vine
#

nanoseconds

#

okay i will use it then lmao

quartz kindle
#

lmao

#

if you're only printing one thing, it doesnt really matter

#

printing multiple things is what actually hits performance

mossy vine
#

inputs however can be up to a few dozen lines

quartz kindle
#

idk the difference between input and stdin, you can probably google that

#

but generally input and print are wrappers around std, so they should provide several goodies and handle several situations that you would need to manually account for if you use std

lofty lagoon
#

heya I have a little problem with my code it say it an error line 21 but I dont find the error someone help

#

the script

earnest phoenix
#

stop coding on mobile

lofty lagoon
#

why

#

@earnest phoenix

earnest phoenix
#

because mobile is not a platform to develop on and you're bound to make syntax errors with a mobile keyboard

quartz kindle
#

message doesnt exist in that scope

lofty lagoon
#

message?

#

I dont understand @quartz kindle

quartz kindle
#

are you copy pasting code randomly?

lofty lagoon
#

nope

late hill
#

Not the only issue

mossy vine
#

do you even understand what your code does

quartz kindle
#

then you should understand that message doesnt exist there

late hill
#

random bitwise operator in there

mossy vine
#

probably supposed to be a ||

quartz kindle
#

im more intrigued by the random client.destroy() in there lul

lofty lagoon
mossy vine
#

lmaoooo

lofty lagoon
mossy vine
#

he left

quartz kindle
#

lmao

mossy vine
#

lets go back to our regularly scheduled program

#

of shitposting

#

i mean what

west raptor
#

Can someone help with this? I'm trying to return the first value of results except I keep getting this error ```
error[E0507]: cannot move out of index of std::vec::Vec<db::model::Guild>
--> src/db/mod.rs:46:5
|
46 | results[0]
| ^^^^^^^^^^ move occurs because value has type db::model::Guild, which does not implement the Copy trait

error: aborting due to previous error

For more information about this error, try rustc --explain E0507.
error: could not compile rin.

To learn more, run the command again with --verbose.```

#

here's the code ```rs
pub fn get_guild(guild_id: i64) -> model::Guild {
let connection = establish_connection();
let results = guilds.filter(id.eq(guild_id))
.load::model::Guild(&connection)
.expect("Error fetching guild");

results[0] 

}```

#

The only thing I could possibly think of that would cause this is &connection

#

except I don't know how to fix it

modest maple
#

according to stack overflow and a guess at the error:

#

it doesnt like the fact that the type of data used doesnt have the "copy" trait, Stack overflow seems to advise Borrowing rather than copy

#

but i have no idea about rust so thats about as much of a guess as i can do

west raptor
#

well im not copying nor borrowing

#

afaik

modest maple
#

no idea den aura_shrug somthing todo with copy

#

but i havent got round to learning rust

#

F

west raptor
#

I could implement Copy to guild except Guild has String values

modest maple
#

ig only one way to find out

#

might end up being a bit of trial and error tbh

west raptor
#

Well Strings are unknown as compile time thus can't be copied

west raptor
#

ended up fixing with results.into_iter().nth(0).unwrap() which just turns it into the iter, gets the first value in the iter and unwraps it

blissful scaffold
#

cannot move out of index of std::vec::Vec<db::model::Guild>
Could it be that results is empty?

west raptor
#

No

#

this is a compile time issue

#

not runtime

#

I still have to error handle if results is empty

#

which I really don't know how I'm going to do

blissful scaffold
#

would guild.filter.first work to get the first result?

#

i dont know rust so i might be completely off

west raptor
#

I don't beleive so

#

I tried to call .first() as first, no pun intended

blissful scaffold
#

Yeah, it would be pretty obvious to try that

modest maple
#
``` im scawrd
west raptor
#

huh?

modest maple
#

oh fucc

blissful scaffold
#

the length of an embed description?
sounds long enough for most things

modest maple
#

i made a search system

#

but turns out

#

crunchyroll gets people aswell

#

so it was grabbing 20000 results

#

:/

west raptor
#

Also anybody know how I could error handle this? I could check if the guild is in the database on message but that would be redundant and would slow down response times

summer torrent
#

How to make prefix as a word. Like vibi. I want to make like vibi help. But didn't work.

blissful scaffold
#

Did you try giving db::model::Guild the Copy trait?
I guess for some unknown weird reason it really wants to copy it somewhere deep inside there

west raptor
#

I can't

#

Guild holds a String type

blissful scaffold
#

hmm sorry then i dont think i can help =/

west raptor
#

which can't be copied because it's size is unknown at compile time

#

I meant what should I do to ensure the guild is in the database

#

I fixed the original issue i had

white sequoia
#

How can i add restriction channel ? 🤔

west raptor
#

.unwrap() can panic if it is a None type

#

but I want to ensure it will always be there without actually handling the error in the get_guild function

modest maple
#

@white sequoia read the docs, its managing channel permissions

#

@summer torrent It purely depends on how you handle prefix's and messages / commands

white sequoia
#

How do I make people able to use commands only for a particular channel, e.g. you can use this command only on #test

#

Chill can u give me code ? idk 🤷‍♂️

west raptor
#

No

#

we don't spoonfeed here

earnest phoenix
#

check the message channel's id against your desired id

blissful scaffold
#

every time someone uses the command check the ID of the channel where they use it and compare it to the channel ID of the channel where it is allowed to be used

#

So in many words what cry said in a few words

white sequoia
#

-,-,

modest maple
#

no spoonfeeed for u aura_shrug