#development

1 messages · Page 1943 of 1

wooden ember
#

but eh

#

i need sleep

quartz kindle
#

go slep

boreal iron
#

You don’t know you can download and run Pi OS on your own hardware?

solemn latch
#

isnt pi OS setup for arm?

boreal iron
#

I mean you spoke about RPIs and I about the OS and that has nothing to do with each other in the first place but I need to do stupid comments sometimes you know

quartz kindle
solemn latch
#

would it even perform well on x86

wooden ember
#

before i go I will leave you guys with this lovely image ove my dads 20 year old voip server that hasnt been cleaned in 15 years

#

gn people

quartz kindle
#

hahaha

solemn latch
#

gn

quartz kindle
#

give it a ||blow job||

boreal iron
#

That’s actually damn clean for 15y

#

You can’t imagine how my server looks after a few month in my garage

solemn latch
wooden ember
#

anyway slep time

quartz kindle
#

i use brushes used for painting, they work amazingly well

boreal iron
#

Omg vacuum cleaner on vents

#

I use gas

quartz kindle
boreal iron
#

No image?!

#

That’s what I use

quartz kindle
#

compressed air is also good, but it finishes very quickly

#

and doesnt remove the lower dust layers that are stuck to the surface

real phoenix
#

ok so my bot has Speak and Connect perms and still can't join my channel. Its a public channel that everyone can access

boreal iron
#

Imagine cleaning up under your bed freerealestate

real phoenix
quartz kindle
boreal iron
#

Man… first time bought some LED strips and shapes to pimp by rooms and it looks amazing

#

Always thought that’s just waste of money

clear marlin
#

oh shit i thought this was general chat

boreal iron
#

Nope… high end technical discussions

#

obviously

real phoenix
real phoenix
boreal iron
#

Not if you don’t provide your errors and associated code

earnest phoenix
#

Can you use buttons w/o a Interaction / Slash Command?

#

I mean it goes on the embed, but can you do like message.edit({ embeds:[test1] }) or something?

#

    message.reply({ embeds:[embed], components:[row] })

    
    const filter = (message1) => {
if(message1.user.id === message1.member.id) return true;
return message1.reply({ content: "You can't use this button" })

}
    
const collector = message.channel.createMessageComponentCollector({ filter, time: 15000 });
const wait = require('util').promisify(setTimeout);

collector.on('collect', async i => {
    if (i.customId === 'safety') {
        await wait(400);
await message.editReply(`Testing Edited`)    }

})```
I assume you can't do that? As it doesn't work for me `o-o`
boreal iron
#

Components always trigger an event when being used, except buttons acting as links

earnest phoenix
#

heh?

boreal iron
#

Huh?

earnest phoenix
#

huh is right. 🤣

boreal iron
#

You may wanna tell me what you mean in other words then

earnest phoenix
#

I'm just trynna edit the embed that was originally sent, but its not a slash command so wondering how to do that.

#

like usually I can do interaction.deferReply() then interaction.editReply idk how to do that much with just a normal prefix command.

boreal iron
#

Simply edit the message

earnest phoenix
#

message.edit?

boreal iron
#

Yeah

earnest phoenix
#

nvm

#

Yeah same error

#

    message.reply({ embeds:[embed], components:[row] })

    
    const filter = (message1) => {
if(message1.user.id === message1.member.id) return true;
return message1.reply({ content: "You can't use this button" })

}
    
const collector = message.channel.createMessageComponentCollector({ filter, time: 15000 });
const wait = require('util').promisify(setTimeout);

collector.on('collect', async i => {
    if (i.customId === 'safety') {
        await wait(400);
    const e1 = new MessageEmbed()
        .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic:true }))
.setDescription(`Testing`)
await i.edit({ embeds: [e1] })    }```
boreal iron
#

The interaction has a message property

#

And yeah you can’t edit messages of others but messages your bot sent

earnest phoenix
#

Hah, got it

#

I just figured out you can defer a message 🤣

#

Same thing as kinda a interaction

#

Wow, that opened my eyes a lot 🤣

boreal iron
#

You’re confusing me

#

Jumping from editing an embed to interactions to deferring messages

earnest phoenix
#

lol, yeah im good at confusing people 🤣

boreal iron
#

If you wanna keep the content but update the embeds simply use the properties of your interaction

#

interaction.message.edit({ content: interaction.message.content, embeds: [new_embeds] });

#

Same goes for if you wanna keep the components

#

Deferring and updating the message will only work for 15m

#

Editing the base message always works even if somebody uses the component a year after

#

(if you can edit a message after a year, not sure about that one tho)

earnest phoenix
#
const wait = require('util').promisify(setTimeout);

you can use timers/promise for this

#

or you can just use a normal setTimeout with an async callback

real phoenix
#

Music bot seems to not be able to connect to voice channels even tho it has the required perms
code:

@client.command()
async def play(ctx): #works
    try:
        if ctx.message.author.voice == None:
            return await ctx.send(embed=discord.Embed(description="You need to be in a voice channel to use this command!"))
            print("Issue: No Voice Channel")

        channel = ctx.message.author.voice.channel
        voice = discord.utils.get(ctx.guild.voice_channels, name=channel.name)
        voice_client = discord.utils.get(client.voice_clients, guild=ctx.guild)

        if channel == voice_client:
            return await ctx.send(embed=discord.Embed(description="I am already playing music in your voice channel!"))
        try:
            if voice_client == None:
                voice_client = await voice.connect()
            else:
                await voice_client.move_to(channel)
        except:
            return await ctx.send(embed=discord.Embed(description="I am unable to join your voice channel! Make sure I have permissions to `Connect` and `Speak`."))

        source = FFmpegPCMAudio("http://stream.rudolph.dbot.cc/proxy/oaktradi/stream",**FFMPEG_OPTIONS)
        voice_client.play(source)  # play the source]
        await ctx.guild.change_voice_state(channel=channel, self_deaf=True)


        embed = discord.Embed(description=f":christmastree: Now playing christmas music! :christmastree:")
        await ctx.send(embed=embed)
    except Exception as e:
        await ctx.reply("Something went wrong! Try `f!leave` and then try playing the music again. A common cause is me not being able to see the voice channel. If this problem percists, please dm a bot dev.")
        channel = client.get_channel(899416695914000465)
        await channel.send(embed=discord.Embed(title="Error!", description=f"`{e}`\nServer: `{ctx.guild.name}` ({ctx.guild.id})\nUser: `{ctx.author}` ({ctx.author.id})"))
worn sonnet
#

If a date is provided it must be a timezone-naive datetime representing UTC time.

#

What does this mean

#

Should I give datetime object with timezone or without timezone?

pale vessel
#

Without?

slender thistle
#

Naive means there's no information about the timezone

#

Timezone-aware is the opposite of that

worn sonnet
slender thistle
neat ingot
#

so assuming i am listening to the interactionCreate event for slash commands. whats the best way to temporarily provide support for the classic commands? like, should i listen for message events too and then parse them? or is there a cleaner way?

#

im guessing ill just have to listen for messageCreate's?

delicate zephyr
#

yea

#

for now you will

neat ingot
#

do i need to enable the intent for it atm too?

#

or is it ok to ignore that atm since ill be removing the listener before long anyway

delicate zephyr
#

nope not til april

neat ingot
#

sweet, ty ❤️

delicate zephyr
#

np

pale vessel
#

Also that semicolon does not belong there better_lollipop

#

Doesn't matter but still

neat ingot
#

i do tend to over use the semicolon lol

#

like, i know its not needed, but my brain makes me to it! 😢

#

yet there isnt one after the processCommand();

#

lol

#

#inconsistencies

#

side note: did have to add an intent there

tight holly
#

@pliant gorge

sly sierra
#

@tight holly

tight holly
pale vessel
#

Click the add to server button on the profile

thorny flume
#

is it possible to define a specific server for a specific shard?

quartz kindle
#

and probably not the way you imagine

#

like, if you have 4 shards, and the server you want is in shard 3, you cant magically move it to shard 1

split hazel
#

probably not connection wise

quartz kindle
#

but you can create a new special shard that only has that server in it and nothing else

thorny flume
#

How can I do this?

quartz kindle
#

it does not remove the server from the other shards tho

thorny flume
#

ok

split hazel
#

tim please spill the beans you got me curious

quartz kindle
#

use the sharding formula, for example discord.js has Discord.ShardClientUtil.GuildIdForShardId() or something like that

#

then get the shard id it would have, if you had 2 billion shards (basically the 32 bit integer limit)

#

and start a new shard with that shard id, and 2 billion shard count

split hazel
#

wait so discord doesn't randomly decide which server gets what shard

quartz kindle
#

nope

split hazel
#

ok that's news to me

quartz kindle
#
shard_id = (guild_id >> 22) % num_shards
split hazel
#

but then you could theoretically write your own sharder to have all premium servers in a special shard which the bot restarts every once a while to sync purchases

quartz kindle
#

yes you can

thorny flume
#

yes

quartz kindle
#

but if you have 100 premium guilds, you need 100 extra shards, which can be a hassle to manage

#

and there is always a risk of collisions

thorny flume
#

This is what I want

quartz kindle
#

its not guaranteed that that guild will be the only guild in that shard

split hazel
#

discord doesn't have to know you didn't make another shard for the guild:)

quartz kindle
#

nah they dont care

#

i use this method for developing purpose

#

for example when i run my bot in dev mode, it starts a single shard with only my guild in it

sly sierra
#

ahh

quartz kindle
#

so it connects instantly, instead of waiting for all 10k guilds to connect

#

and the production bot keeps running like normal at the same time

thorny flume
#

so i mean, when i split a server, will it spawn a new shard?

quartz kindle
#

imagine you have 4 shards and 4k guilds, 1k on each shard

thorny flume
#

ok

quartz kindle
#

before:
shard 1 -> 1k
shard 2 -> 1k
shard 3 -> 1k
shard 4 -> 1k

after:
shard 1 -> 1k
shard 2 -> 1k
shard 3 -> 1k
shard 4 -> 1k
shard 359374987 -> 1 guild

thorny flume
#

hm

quartz kindle
#

that 1 guild in shard 359374987 will be a duplicate guild, it will not be removed from the other shards

thorny flume
#

do you have any code examples?

thorny flume
quartz kindle
#
const n = 99999999;
const guild = "475847364758495069";
const shard = Discord.ShardClientUtil.shardIDForGuildID(guild, n);

const client = new Discord.Client({
  shards: [shard],
  shardCount: n
})

client.login(token);
quartz kindle
thorny flume
#

hm

thorny flume
#

lol

#

shardCount

quartz kindle
#

the total shardCount yes

#

the higher the number, the less chances of a collision happening (2 guilds who accidentally have the same shard id)

#

im not sure what is the maximum number discord accepts, but i believe its around 2 billion (the 32 bit integer limit)

thorny flume
#

hm

#

I'm looking to create a server. If the language of being "pt br" goes to another fragment and if it is "en us" it goes to another one, the same thing for Premium

quartz kindle
#

this method only allows you to isolate 1 guild per shard

thorny flume
#

hm

quartz kindle
#

you cannot put multiple guilds in the same shard

#

unless you're very lucky with collisions, then you can maybe put 2 or 3 max

thorny flume
#

hm... ok

earnest phoenix
#

Hey

drowsy flume
#

is there a good place to learn where to make a webhook to auto send votes into a channel?

supple oriole
#

ik Im dumb but like mongoose be saying query was already executed

#
 const channel = await message.mentions.channels.first();
    const guild1 = message.guild;
    let webhookid;
    let webhooktoken;
    await message.channel.createWebhook(guild1.name, {
        avatar: guild1.iconURL({ format: "png" })
      })
      .then(webhook => {
        webhookid = webhook.id;
        webhooktoken = webhook.token;
      });
   
    if (!channel)
      return message.channel
        .send(
          "I cannot find that channel. Please mention a channel within this server."
        )// if the user do not mention a channel
    
    await Guild.findOne(//will find data from database
      {
        guildID: message.guild.id
      },
      async (err, guild) => {
        if (err) console.error(err);
        if (!guild) {// what the bot should do if there is no data found for the server
          const newGuild = new Guild({
            _id: mongoose.Types.ObjectId(),
            guildID: message.guild.id,
            guildName: message.guild.name,
            logChannelID: channel.id,
            webhookid: webhookid,
            webhooktoken: webhooktoken
          });

          await newGuild
            .save() //save the data to database(mongodb)
            .then(result => console.log(result))
            .catch(err => console.error(err));

          return message.channel.send(
            `The log channel has been set to ${channel}`
          );
        } else {
          guild
            .updateOne({ //if data is found then update it with new one
              logChannelID: channel.id,
              webhooktoken: webhooktoken,
              webhookid: webhookid
            })
            .catch(err => console.error(err));

          return message.channel.send(
            `The log channel has been updated to ${channel}`
          );
        }
      }
split hazel
#

your help request has been denied

earnest phoenix
#

skill issue

earnest phoenix
manic osprey
#

I have done

split hazel
#

im guessing the new guild

manic osprey
#

Sad

supple oriole
manic osprey
#

Learn hangouts

supple oriole
#

been there forever e.e

supple oriole
split hazel
#

but where is the error coming from

#

is it coming from mongo or what

earnest phoenix
sly sierra
#

He didnt even make a spelling mistake

#

He's so cool.

supple oriole
split hazel
#

i will mind it

supple oriole
#

i just need help

#

✊ 😔

split hazel
#

so the error comes from here?

supple oriole
#

i hope so.

#

I have never used mongodb before

split hazel
#

you should setup some logging

supple oriole
#

this like my second time CH_DanceBoi

split hazel
#

mongoose does a lot of things in the background so they might not even be coming from that

supple oriole
#

o.

supple oriole
split hazel
#

as opposed to a pure mongodb driver which does whatever you tell it to do

supple oriole
#

there isnt any data from the server rn

#

so techincally yes, it's a new server.

split hazel
#

can you post the whole error

#

like the whole thing

supple oriole
#

ok

#
/home/runner/Kumigg-Bot-1/node_modules/mongoose/lib/helpers/query/wrapThunk.js:21
      const err = new MongooseError('Query was already executed: ' + str);
                  ^

MongooseError: Query was already executed: Log.findOne({ guildID: '847392973511327764' })
    at model.Query._wrappedThunk [as _findOne] (/home/runner/Kumigg-Bot-1/node_modules/mongoose/lib/helpers/query/wrapThunk.js:21:19)
    at /home/runner/Kumigg-Bot-1/node_modules/kareem/index.js:370:33
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  originalStack: 'Error\n' +
    '    at model.Query._wrappedThunk [as _findOne] (/home/runner/Kumigg-Bot-1/node_modules/mongoose/lib/helpers/query/wrapThunk.js:25:28)\n' +
    '    at /home/runner/Kumigg-Bot-1/node_modules/kareem/index.js:370:33\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:78:11)'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! kumi@2.0.0 start: `node .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the kumi@2.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-12-20T14_36_27_077Z-debug.log
split hazel
#

god nodejs errors are sometimes useless

supple oriole
#

fr

split hazel
#

can you replace instances of if (err) console.error(err); to throw err;

#

if you throw it instead of logging it it should give more details

#

wait no

supple oriole
#

a

split hazel
#

the bot crashes so it cant be these

supple oriole
split hazel
#

so when does the error occur

#

im gonna guess it happens at the findone

supple oriole
#

it doesnt go past this

#
    await Guild.findOne(//will find data from database
      {
        guildID: message.guild.id
      },
supple oriole
#

e.e

split hazel
#

so yeah

#

now we need to find out why it happens "twice"

supple oriole
#
    await Guild.findOne(//will find data from database
      {
        guildID: message.guild.id
      },
      async (err, guild) => {
        if (err) console.error(err);
        if (!guild) {// what the bot should do if there is no data found for the server
          const newGuild = new Guild({
            _id: mongoose.Types.ObjectId(),
            guildID: message.guild.id,
            guildName: message.guild.name,
            logChannelID: channel.id,
            webhookid: webhookid,
            webhooktoken: webhooktoken
          });
#

wouldn't it be this?

#

because it's making a new set of data while Im making one as well?

split hazel
#

i dont think that should be the case

#

will probably do nothing but can you use the newer async syntax instead of the old callback method

supple oriole
#

my brain is confusion rn

split hazel
#

const guild = await Guild.findOne({ guildID: message.guild.id }).exec();

#

instead of findOne({}, (err, guild) => {

})

supple oriole
#

well well well

#

would u look at that.

#

it solved it

#

but this came out

#
/home/runner/Kumigg-Bot-1/node_modules/discord.js/src/rest/RequestHandler.js:349
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Maximum number of webhooks reached (10)
    at RequestHandler.execute (/home/runner/Kumigg-Bot-1/node_modules/discord.js/src/rest/RequestHandler.js:349:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/runner/Kumigg-Bot-1/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
    at async TextChannel.createWebhook (/home/runner/Kumigg-Bot-1/node_modules/discord.js/src/structures/BaseGuildTextChannel.js:156:18)
    at async Object.run (/home/runner/Kumigg-Bot-1/commands/Configuration/setlogschannel.js:22:5) {
  method: 'post',
  path: '/channels/847392973511327768/webhooks',
  code: 30007,
  httpStatus: 400,
  requestData: { json: { name: 'Kumi.gg', avatar: null }, files: [] }
}
split hazel
#

now discord isnt happy

supple oriole
#

I just did the command

#

k!setlogs

#

didnt mention channels

split hazel
#

you should delete some of your webhooks

#

in the channel

#

and add checks in your code to reuse webhooks

#

but thats a whole another issue

supple oriole
#

bro

#

I didnt even see the webhooks

#

the bot been spamming webhooks

#

yep ok

#
  await channel.createWebhook(guild1.name, {
                  ^

TypeError: Cannot read property 'createWebhook' of undefined
    at Object.run (/home/runner/Kumigg-Bot-1/commands/Configuration/setlogschannel.js:22:19)
split hazel
#

ban the bot for spam

#

that means channel is undefined

supple oriole
#

yes

#

but I did define it

split hazel
#

you mentioned the channel right

supple oriole
#

it sent that without even mentioning the channel e.e

#

just k!setlogs

#

and that came out

#

my bot running on a nokia bricked up phone bruh

split hazel
#

yeah repl.it isnt much different from a nokia

woeful pike
#
const { id, token } = await channel.createWebhook(...)
supple oriole
#

WAIT

#

HUH

#

where is that

woeful pike
#

you're awaiting something with a then method that mutates an outside variable

#

instead of just assigning the result of the awaited promise

supple oriole
#

am confusion.

round cove
woeful pike
crimson vapor
#

Can’t you do “const { webhookId: id, webhookToken: token } = …” also?

woeful pike
#

the other way around

#

id: webhookId

crimson vapor
#

Ah alright

#

My favorite part of that code is the await .then

#

Yep

quartz kindle
#

no

crimson vapor
#

Iirc brain uses ip rotation and webhooks to get past global rate limits

round cove
split hazel
#

because they do a lot of that

crimson vapor
#

Not really

split hazel
#

they do

#

api docs

#

bids

#

watcher

#

many

crimson vapor
#

I mean still not that many

#

Plus those are constant

#

Unlike webhooks for logging or other purposes

#

Like censorbots resend or triviabot’s trivia questions

split hazel
#

sorry just my attempt at insulting you

earnest phoenix
#

@earnest phoenix i can help you explain a structure for it in vc

quartz kindle
#

create and use

earnest phoenix
#

kk

manic osprey
#

H

feral aspen
#

Hey all. 👋 I have this code and I want to create an object with a property named as options and set it as as the array named as allSettings, although, I want to rename the id property in the property of the array of objects and rename it to value. How can I achieve this?

const allSettings = [{ name: 'New Follower', id: 'newfollower' }, { name: 'New Follower', id: 'newfollower' }];
const object = { options: allSettings };

console.log(object, object.options);
earnest phoenix
#

client.on("guildMemberAdd", async (member) => {
console.log(member);
member is undefined

feral aspen
#

I didn't ask for a How to make a slash commands bot.?

earnest phoenix
feral aspen
#

I can tell you are listening..

earnest phoenix
#

dont you want slash command options?

feral aspen
earnest phoenix
#

yes probably misunderstand sorry

cinder patio
#

allSettings.map(setting => ({name: setting.name, value: setting.id }));

feral aspen
#

Thanks!

earnest phoenix
#

mh can i add custom emojis in select menu ?

#

bc when i put <:name:id> my bot doesn't replace by the emoji

wheat mesa
#

What’s channel

wheat mesa
#

Oh wait I didn’t see that

feral aspen
#

Nope, API Issue.

#

Although, what's the new feature releasing?

earnest phoenix
#

ngl the best way to get a message from a channel is just fetch to discord api manually because caching is annoying sometimes

solemn latch
#

best to just check if messages is defined then

earnest phoenix
#

would be the fastest workaround, not sure if it is the best

const existing = channel?.messages?.cache?.get(data.id);
if(!existing) return;
wheat mesa
#

Can pm2 run a compiled C++ executable?

lament rock
#

if it's through a console command, yes

wheat mesa
#

Alright

earnest phoenix
#

its v12 or v13 i think its v12

#

You need to upgrade to v13

#

isn't it v13?

earnest phoenix
#

anyone down to work on a python discord project?

sudden geyser
#

nah

amber bear
#

Bruh what sucks is I have a discord bot submitted for the website and I’m waiting, but the bot will be offline for 2 days ‘cause I’m moving houses Sadge

#

And I feel like it’s going to get declined while it’s offline

#

It’ll be offline from about the end of today till Thursday I’m pretty sure

modest maple
amber bear
#

So just put that in?

idle coral
#

My code;

@client.command(aliases=['ei','emoji'])
async def emojiinfo(self, ctx, emoji: discord.Emoji = None):
    if not emoji:
        return await ctx.invoke(self.bot.get_command('help'), entity='emojiinfo')

    try:
        emoji= await emoji.guild.fetch_emoji(emoji.id)
    except discord.NotFound:
        return await ctx.send("I could not find this emoji.")
    
    is_managed = 'Yes' if emoji.managed else 'No'
    is_animated = 'Yes' if emoji.animated else 'No'
    requires_colons = 'Yes' if emoji.requires_colons else 'No'
    creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')
    can_use_emoji= 'Everyone' if not emoji.roles else ' '.join(role.name for role in emoji.roles)

    description = f'''
    **General;**
    **- Name: {emoji.name}
    **- ID:** {emoji.id}
    **- URL:** [Link To Emoji]({emoji.url})
    **- Author:** {emoji.user.mention}
    **- Time Created:** {creaton_time}
    **- Usable By:** {can_use_emoji}

    **Other;**
    **- Animated:** {is_animated}
    **- Managed:** {is_managed}
    **- Requires Colons:** {requires_colons}
    **- Guild Name** {emoji.guild.name}
    '''

    embed = discord.Embed(title=f'**Emoji information for:** {emoji.name}', description=description, color=discord.Color.from_rgb(61, 31, 103))
    embed.set_thumbnail(url=emoji.url)
    await ctx.send(embed=embed)
#

Snippet from code with error;

        return await ctx.invoke(self.bot.get_command('help'), entity='emojiinfo')
#

Error;
Command raised an exception: AttributeError: 'str' object has no attribute 'invoke'

ashen lodge
#

Maybe removing the return word?

idle coral
#

I'll try.

spark flint
#

That won't help

#

It should be @commands.command iirc

#

because you're using cogs

ashen lodge
#

you're right

idle coral
#

Yeah that didn't help.

spark flint
#

Try ```py
@commands.command(aliases=['ei','emoji'])
async def emojiinfo(self, ctx, emoji: discord.Emoji = None):

idle coral
#

Isn't ctx a version of str?

spark flint
#

ctx means context

#

without cogs you dopy @client.command() async def emojiinfo(ctx, emoji:discord.Emoji=None):

#

but because you are using cogs, you need to pass self at the start

#

and because its cogs, you need to do @commands.command()

idle coral
#

All my commands though are @client.command()

spark flint
#

did you copy the emojiinfo command from elsewhere?

idle coral
#

a small portion from stackoverflow

spark flint
#

are you using cogs

#

or are all commands in the same file

idle coral
#

same file

spark flint
#

thats why

idle coral
ashen lodge
#

dont use self if you're using a unique file

spark flint
#
@client.command(aliases=['ei','emoji'])
async def emojiinfo(ctx, emoji: discord.Emoji = None):
    if not emoji:
        return await ctx.invoke(client.get_command('help'), entity='emojiinfo')```
idle coral
ashen lodge
#

give attention to what bun sent

idle coral
#

well that just messes up all things that contain self

ashen lodge
#

and how he replaced self.bot by client

idle coral
#

wait

#

no

#

yeah

spark flint
#

you're using client it seems

idle coral
#

i know

#

replace self with ctx?

#

that removed the error

ashen lodge
#

simply don't use self

#

if you aren't using cogs

spark flint
#

you don't need self

idle coral
#

Ok

spark flint
#

you've copied code from someone using cogs

idle coral
#

Ah

ashen lodge
#

btw, take a look on that if you're planning to expand your bot's commands

idle coral
#

I have one last question.

#

Is it normal for people to get snippets from Stackoverflow if they dont know how to do something

#

Or is it just me?

ashen lodge
#

completely normal

spark flint
#

i do that too

idle coral
#

Alright

ashen lodge
#

i like to take a look to know how other people solved the same issue

spark flint
#

same

idle coral
#

Thanks though, now I know something I didn't. You just helped me with two commands I made that don't work.

spark flint
idle coral
#

Because I looked at my other commands that have some things with self.

#

And put that self in those commands i made.

ashen lodge
#

no problem, we all learn things every day

idle coral
#

They don't work. So now I can go back and fix them.

spark flint
#

generally, you only really use self in cogs or anything that involves classes

ashen lodge
#

yep

idle coral
#

Okay..again thank you!

ashen lodge
#

glad to help :)

idle coral
#

I need some more help with my command.

#
        members = list(privateduos[matchid])
        user = discord.User(id=int(members[0]))
    is_managed = 'Yes' if emoji.managed else 'No'
    is_animated = 'Yes' if emoji.animated else 'No'
    creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')
#

wait

ashen lodge
#

i'm here

idle coral
#

yeah

#

error;

    members = list(privateduos[matchid])
                                       ^
TabError: inconsistent use of tabs and spaces in indentation
spark flint
#

i see the issue

idle coral
#

The indents.

spark flint
#
    members = list(privateduos[matchid])
    user = discord.User(id=int(members[0]))
    is_managed = 'Yes' if emoji.managed else 'No'
    is_animated = 'Yes' if emoji.animated else 'No'
    creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')```
#

yeah

idle coral
#

But I deleted those

#

And it still has the error

spark flint
#

then the rest is badly indented

#

try indenting is_managed and everything after that

idle coral
#

?

spark flint
#
        members = list(privateduos[matchid])
        user = discord.User(id=int(members[0]))
        is_managed = 'Yes' if emoji.managed else 'No'
        is_animated = 'Yes' if emoji.animated else 'No'
        creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')``` for example
idle coral
#

still error for user = discord.User(id=int(members[0]))

spark flint
#

then indent that maybe

#

its hard to tell without full code

idle coral
#

ive tried that

#

wait the top one also has an error

#

and what do you know, its the same error

ashen lodge
#

can you screenshoot the full code?

spark flint
#

you've indented user

idle coral
#

I will send it.

#

@client.command(aliases=['ei','emoji'])
async def emojiinfo(ctx, emoji: discord.Emoji = None):
    if not emoji:
        return await ctx.invoke(ctx.bot.get_command('help'), entity='emojiinfo')

    try:
        emoji= await emoji.guild.fetch_emoji(emoji.id)
    except discord.NotFound:
        return await ctx.send("I could not find this emoji.")
        members = list(privateduos[matchid])
        user = discord.User(id=int(members[0]))
        is_managed = 'Yes' if emoji.managed else 'No'
      is_animated = 'Yes' if emoji.animated else 'No'
      creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')
    

    description = f'''
    **General;**
    **- Name: {emoji.name}
    **- ID:** {emoji.id}
    **- URL:** [Link To Emoji]({emoji.url})
    **- Author:** {emoji.user.username}
    **- Time Created:** {creaton_time}
    **- Usable By:** {can_use_emoji}

    **Other;**
    **- Animated:** {is_animated}
    **- Managed:** {is_managed}
    **- Guild Name** {emoji.guild.name}
    '''

    embed = discord.Embed(title=f'**Emoji information for:** {emoji.name}', description=description, color=discord.Color.from_rgb(61, 31, 103))
    embed.set_thumbnail(url=emoji.url)
    await ctx.send(embed=embed)
ashen lodge
idle coral
#

a return statement

#

above that you mean?

ashen lodge
#

i mean this

#
except discord.NotFound:
        # This will execute
        return await ctx.send("I could not find this emoji.")

        # This no
        members = list(privateduos[matchid])
        user = discord.User(id=int(members[0]))
        is_managed = 'Yes' if emoji.managed else 'No'
      is_animated = 'Yes' if emoji.animated else 'No'
      creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')
idle coral
#

ok

ashen lodge
#
@client.command(aliases=['ei','emoji'])
async def emojiinfo(ctx, emoji: discord.Emoji = None):
    if not emoji:
        return await ctx.invoke(ctx.bot.get_command('help'), entity='emojiinfo')

    try:
        emoji= await emoji.guild.fetch_emoji(emoji.id)
    except discord.NotFound:
        return await ctx.send("I could not find this emoji.")

     members = list(privateduos[matchid])
     user = discord.User(id=int(members[0]))
     is_managed = 'Yes' if emoji.managed else 'No'
     is_animated = 'Yes' if emoji.animated else 'No'
     creaton_time = emoji.created_at.strftime('%I:% %p %B %d, %Y')
idle coral
#

I revoked return

ashen lodge
#

something like this

idle coral
#

ok

idle coral
#
    members = list(privateduos[matchid])
                                       ^
IndentationError: unindent does not match any outer indentation level
#

Ima try to remove return

ashen lodge
#

one question, what is privateduos exactly?

#

is a global variable?

idle coral
#

I actually don't know

#

I got it from stack overflow.

#

Because I forgot how to get user.

#

Because **- Author:** {emoji.user.username}

#

user needed to be defined

ashen lodge
#

are you sure on that?

idle coral
#

I will remove it.

ashen lodge
#

when you use emoji.user, user makes reference to the user who created the emoji, so you don't need explicitly to define it

#

you can use emoji.user.name

#

or emoji.user.mention to mention it

idle coral
#

But it had an error.

ashen lodge
#

let me see it

idle coral
#

ok

#

lemme paste my old code

#

Command raised an exception: AttributeError: 'NoneType' object has no attribute 'mention'

#

That's the error.

spark flint
#

what

#

why .user

#

emoji.user.mention

idle coral
#

Idk, what shall I put instead?

ashen lodge
#

"The user that created the emoji. This can only be retrieved using Guild.fetch_emoji() and having the manage_emojis permission." from discord.py docs

idle coral
#

dang

#

ok thank you again

#

still not understanding, still won't work

#

but i can hold it off

ashen lodge
#

not the last word on this, but take it easy when you get stucked

#

maybe looking up on other things helps you

sly sierra
#

@undone otter could you send me your bot id

undone otter
sly sierra
#

are you requesting any gateway intents

oak cliff
#

itsprobably because youre using intents your not verified for

#

if you read the whole error message it says that

sly sierra
#

You probably requested message intents and etc.

#

those take even longer

hidden gorge
#

Ever Time i run node deploy-commands.js I get this error

    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47```
#

How do I fix this?

solemn latch
#

its impossible to say without seeing the code

hidden gorge
#

Ok

#

@solemn latch this is the code


const commands = [
    new SlashCommandBuilder().setName('help').setDescription('Replies with All Commands')
  new SlashCommandBuilder().setName('botdev').setDescription('Replies with The Bot dev')
  new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
    new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
    new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
]
    .map(command => command.toJSON());

const rest = new REST({ version: '9' }).setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

solemn latch
hidden gorge
#

oh @solemn latch Where Do i put the commas?

solemn latch
#

in between each element

hidden gorge
#

Um

#

what

#

im confused

solemn latch
hidden gorge
#

oh

#

thanks

solemn latch
#

probably best to not copy paste things from the guide

hidden gorge
#

yeah prob not

#

@solemn latch I got another error

#

I got SyntaxError: Unexpected token '.' at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) at node:internal/main/run_main_module:17:47

solemn latch
#

I dont see it in your code ngl

hidden gorge
#

neither do i

undone otter
#

How can i disabled that one

oak cliff
#

then you'll need to contact discord

#

oh youre probably asking for the third one

#

the presence

#

disable that

undone otter
#

Ohhh

hidden gorge
#

@solemn latch Found the issue I had a , before a . in the same line thats why

undone otter
#

Tysm

hidden gorge
#

@solemn latch And I got ```/home/runner/Nodejs-16/deploy-commands.js:4
new SlashCommandBuilder().setName('help').setDescription('Replies with All Commands'),
^

ReferenceError: SlashCommandBuilder is not defined
at Object.<anonymous> (/home/runner/Nodejs-16/deploy-commands.js:4:6)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47```

solemn latch
#

looks like you didnt require the function

hidden gorge
#

ARE YOU KIDDING ME

#

I forgot how th to do that

solemn latch
#

its covered in the guide you copied from

hidden gorge
#

ok

sharp saddle
#

how shards work? (node.js)

sharp saddle
solemn latch
#

like the basics of shards? or like how to do them

sharp saddle
hidden gorge
sharp saddle
#

see docs

solemn latch
#

discord allows one connection to have 2500 guilds.
sharding makes your bot have many connections so you can go past 2500 guilds.

sharp saddle
solemn latch
#

it also allows multiple cpu threads to be used

hidden gorge
#

Wait @solemn latch Do I need to put const { SlashCommandBuilder } = require('@discordjs/builders'); in my index?

solemn latch
#

in the same file you got the error in

hidden gorge
#

ok

sharp saddle
#

deploy-commands.js

hidden gorge
#

@solemn latch

#

again

solemn latch
#

looks like you didnt require rest

hidden gorge
#

im looking that up

#

@solemn latch

  throw err;
  ^

Error: Cannot find module 'REST'
Require stack:
- /home/runner/Nodejs-16/deploy-commands.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/home/runner/Nodejs-16/deploy-commands.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/runner/Nodejs-16/deploy-commands.js' ]
}```
#

const { REST } = require('REST');

const commands = [
    new SlashCommandBuilder().setName('help').setDescription('Replies with All Commands'),
  new SlashCommandBuilder().setName('botdev').setDescription('Replies with The Bot dev'),
  new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
    new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
    new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
]
    .map(command => command.toJSON());

const rest = new REST({ version: '9' }).setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);```
solemn latch
#

discordjs has its own rest methods

hidden gorge
#

oh

#

so what do i do?

hidden gorge
#

@solemn latch sorry for pinging a lot

const rest = new REST({ version: '9' }).setToken(token);
                                                 ^

ReferenceError: token is not defined
    at Object.<anonymous> (/home/runner/Nodejs-16/deploy-commands.js:14:50)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47```
solemn latch
#

It might help to take some time to learn to read error messages, the past 4 errors have been the same error just in a different spot.

hidden gorge
#

Ok

solemn latch
#

not trying to be sassy, but I dont want to say the same sentence over and over 😔 been a long day

hidden gorge
#

Ok My last error Help ```Error: Cannot find module 'clientId'
Require stack:

  • /home/runner/Nodejs-16/deploy-commands.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/home/runner/Nodejs-16/deploy-commands.js:6:22)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/home/runner/Nodejs-16/deploy-commands.js' ]
    }```
#
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
                                         ^

ReferenceError: clientId is not defined
    at Object.<anonymous> (/home/runner/Nodejs-16/deploy-commands.js:19:42)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47```
sterile lantern
#

you fill those in yourself.

#

or define them

#

const abc = something;

#

const clientId = your_client_id;

quartz kindle
#

jeez

#

that was french bread to read

earnest phoenix
#

so this channel is for any kind of development right?

#
function renderBackground(x, y) {


  const backgroundX = MAP_SIZE / 2 - x + canvas.width / 2;
  const backgroundY = MAP_SIZE / 2 - y + canvas.height / 2;
 
  

context.drawImage(
    getAsset('bg.png'),
    backgroundX,
    backgroundY,
    MAP_SIZE / 10,
    backgroundX,
    backgroundY,
    MAP_SIZE / 2,
  );
  context.fillRect(0, 0, canvas.width, canvas.height);
}
``` I'm making a js 2d multiplayer game and i'm setting a custom background, but it doesn't appear
#

I used many methods but same

crimson vapor
#

first, you're making a function that uses context but having context scoped as a global variable, is that intended?

earnest phoenix
#

huh?

#
const canvas = document.getElementById('game-canvas');
const context = canvas.getContext('2d');
#

that's how i defined it at the first of my code

crimson vapor
#

I knew that was what you did

#

but did you know that you made a function that relied on it as a global variable?

earnest phoenix
#

i didn't know

#

then what do I change for it to work?

crimson vapor
#

you're calling the function, right?

earnest phoenix
crimson vapor
#

I assume you are

#

alright

#

what does getAsset return?

#

a buffer?

earnest phoenix
#

return the image

crimson vapor
#

alright

#

are you trying to set the background in a small area?

earnest phoenix
#

kinda

crimson vapor
#

does it work if you fill it in the entire area?

#

wait isnt that fillRect clearing the image?

earnest phoenix
#

It's clearing it?

crimson vapor
#

setting it to a solid color I guess

earnest phoenix
#

oh then i'll try removing it

proven lantern
#

i want to make a simple invite code generator that creates a string with a random adjective and random noun put together. is there a way to store an array of words in dynamodb and only get one value back from an array. should i just do this in memory?

earnest phoenix
#

I put it for a gradient color bg but now I wanted a custom one

proven lantern
#

nm i thought of a way

earnest phoenix
crimson vapor
#

does it work if you just do
context.drawImage(asset, canvas.width, canvas.height)

earnest phoenix
#

i'll try

#

nope

crimson vapor
#

are you filling the entire screens somewhere else after you draw the image?

#

also have you confirmed that the code actually can draw the image

earnest phoenix
#

i was in css but i removed it few hours ago, i'll check if i'm filling anywhere else

earnest phoenix
#

I tried with other images and same issue

crimson vapor
#

write some code to test it

earnest phoenix
#

ok

#

@crimson vapor ummm now works but bugs:

  1. It's not well drawed
  2. The background is too smal compared to map size
#

and when i put canvas.width and canvas.height, the bg dissapears

earnest phoenix
#

i want the image to move too ._. the spaceship's moving but the background is the same as started so it doesn't look like it's moving

full epoch
#

how to edit channel permissions in discord js v13 ?

#

i always got this error

    at Object.run (C:\Users\adity\Desktop\HighQ Handler\commands\Channel Manager\lock.js:20:25)
    at module.exports (C:\Users\adity\Desktop\HighQ Handler\events\guild\messageCreate.js:116:19)
    at Client.emit (node:events:394:28)
    at MessageCreateAction.handle (C:\Users\adity\Desktop\HighQ Handler\node_modules\discord.js\src\client\actions\MessageCreate.js:25:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\adity\Desktop\HighQ```
amber bear
amber bear
full epoch
amber bear
#

Oh channel permissions

full epoch
#

so

amber bear
#

Umm yeah have a look at the documentation it gives a decent overview as to what’s available and is pretty self explanatory

full epoch
amber bear
#

I’ll have a look real quick

full epoch
amber bear
#

You did import it right?

#

Make sure you did because it might error out if it isn’t imported

full epoch
amber bear
#

Aight, umm you could check the auto fill on vscode to see what’s available for the channel.x functions

#

And see if there’s something like channel.x.permissionX

full epoch
amber bear
#

Aight, we’ll Im outta ideas…

full epoch
#

yeah , same

amber bear
#

Maybe stack overflow is a good place to check as well

#

I frickin love stack overflow lol

full epoch
amber bear
#

Damn, maybe open a new one on stack overflow about it?

#

Wait

#

Is your discordjs fully up to date?

full epoch
amber bear
#

As well as node (just in case for node)

#

Is that latest?

full epoch
amber bear
#

Aight, yeah I’m now of no help, I don’t know, good luck tho, you’ll get there!

amber bear
#

I’ll have a look soon, funnily enough I’m in a car (backseat)

#

But I’m checking the docs and stuff

full epoch
#

haha xd

amber bear
#

And I’ll check vscode soon lol just in case

full epoch
#

16 hours elapsed in vscode

amber bear
#

Lol nice

#

Commitment

#

My bot got declined today too ‘cause it crashed, lol I’ll have to fix it soon too

amber bear
#

Yeah 😎

full epoch
#

i just want to updated my bot now

#

xd

amber bear
full epoch
#

now , i think i will go sleep

amber bear
#

Aight mate, good luck and sleep well

full epoch
quartz kindle
#

if you're on browser you can use requestAnimationFrame()

#

for example if you control your ship with the keyboard:
on key press -> update ship position -> requestAnimationFrame() -> update map position

lethal trout
#

https://srcb.in/mWct3C9TGC
see example for fname if i put a text like hi it will work
but if i put for fname if i put hi there it wont work

earnest phoenix
#

I have requestAnimationFrame where I animate the ship

slender wagon
#

is there a way i could set a timeout to fill a form on vanilla js clientside

#

like lets say i filled the form then i gotta wait 15 hours

earnest phoenix
# quartz kindle for example if you control your ship with the keyboard: on key press -> update s...
function renderMainMenu() {
  const t = Date.now() / 7500;
  const x = MAP_SIZE / 2 + 800 * Math.cos(t);
  const y = MAP_SIZE / 2 + 800 * Math.sin(t);
  renderBackground(x, y);
}

let renderInterval = requestAnimationFrame(renderMainMenu, 1000 / 60);


export function startRendering() {
  clearInterval(renderInterval);
  renderInterval = setInterval(render, 1000 / 60);
}


export function stopRendering() {
  clearInterval(renderInterval);
  renderInterval = setInterval(renderMainMenu, 1000 / 60);
}

```i used this one month ago (found on the saves file from replit)
#

doesn't work

woeful pike
#

the function you pass to RAF should call RAF again recursively

earnest phoenix
#

raf?

earnest phoenix
#

ok

#
let renderInterval = requestAnimationFrame(renderMainMenu, 1000 / 60);


export function startRendering() {
  cancelAnimationFrame(renderInterval);
  renderInterval = requestAnimationFrame(render, 1000 / 60);
}


export function stopRendering() {
  cancelAnimationFrame(renderInterval);
  renderInterval = requestAnimationFrame(renderMainMenu, 1000 / 60);
}
#

it black screens

#

should I cancel animation frame?

hasty lotus
#

Hi! I just had a question, I'm trying to handle DM with my bot, but when I send him a message the messageCreate event is not triggered. I tried adding partials, and I have the intent enabled. But I've noticed that when the bot sends me a message first, and the DM channel is cached the bot recieves the message. I know it is possible, as some bots offer the ability of having a support chat system in dm.

If any idea, please let me know and ping me ^^

quaint wasp
#

what in the actual fuck...

#

I've tryied switching the embeds

#

every single time

#

it would reply with the nope embed

#

no matter if there was an error or not

#

no matter if I've switched the yep and nope embeds

#

every time it'd reply with the nope

#

any ideas on whats wrong?

#

(ping in messages)

high crown
#

hey

#
 textarea.addEventListener('keydown', e => {

    if (e.enterKey) {
        sendMessage(e.target.value)
    }

});

#

can anyone tell me what's wrong here?

velvet jolt
#

@earnest phoenix what was u saying about replit?KEKW KEKW

woeful pike
slender wagon
#

60000 is this used as a minute in js

sly solar
#

How can I print data from mongodb to labels one by one in c#?

spark flint
#

does anyone know how the stripe api works

#

to generate a transaction

winter pasture
# spark flint to generate a transaction

What’s your need? They got some pretty decent api docs https://stripe.com/docs/api

Personally I would recommend using their ready made checkout page, that way you don’t need to deal with PCI, 3DS and you get better Radar insight due to their fingerprinting https://stripe.com/docs/payments/checkout

The quickest way to build conversion-optimized payment forms, hosted on Stripe.

spark flint
#

i've just gotta work out a way to verify if a paypal.me link works

winter pasture
spark flint
#

Alr

#

Checkout pages are probs easier yeah

earnest phoenix
#

can stripe handle crypto

#

my guess is no

spark flint
#

Nope

#

I’d look into possible crypto payment processors later on tho

#

Depends if people use this service

earnest phoenix
#

Coinbase commerce and coingate seem good

spark flint
#

Alr thanks

winter pasture
#

Isn’t PayPal also experimenting with Crypto?

spark flint
#

the service would be a landing page system with the landing page owner supplying the paypal email and/or stripe payment location

winter pasture
spark flint
#

Because I wouldn't actually be handling the transactions

earnest phoenix
spark flint
#

And, is it possible to generate a PayPal payment link from the payment recievers email?

#

or does it require api keys

winter pasture
spark flint
#

Its a developer donation page system

#

So for example I would own donatey.me/ben and that would give options for entering payment amount and ways of paying

winter pasture
#

Ah then you should definitely be using stipe connect. (https://stripe.com/docs/connect/standard-accounts)

That enables you as a platform to allow your users to create their own stripe account and give you access to it.

That also makes it so you are not liable for chargebacks and providing tax forms etc

#

One of the main risks of you taking stipe transactions then later redirect payments to the person is that if the “buyer” charged back the transaction, you are the one liable

spark flint
#

Thats why I would get the user to set their Stripe details/Login to stripe from the dashboard

#

So the money doesn't go into my stripe account, only the page owners

winter pasture
#

Yeah, I guess you could ask them for their API key/login details, but I think that would be risky.
If stripe sees a lot of logins from your device they would probably block login attempts. Also if you ask for APIKeys it could break if the user rotates their key

So I think Stripe connect would be the best. Would require some time to setup, but their docs should be straight forward (https://stripe.com/docs/connect)

spark flint
#

Well

#

What alternatives are there for card transactions?

#

Paypal seems simple (Paypal.me, might try find doc information on getting payment url from email)

earnest phoenix
spark flint
#

yeah

#

i'm looking into it now

earnest mural
#

yeah

spark flint
#

its more the best way of doing it

#

because it will need the developer to link their account

earnest phoenix
#

but every single payment provider has identity restrictions

spark flint
#

yeah

earnest phoenix
#

I can just put my btc address on my devpage tho

spark flint
#

yeah

#

thats what i'm thinking

#

for now support btc and eth

quaint wasp
spark flint
#

probs because you didn't log it

quaint wasp
#

True

quaint wasp
#

PayPal

#

Stric

#

Or what discord uses

spark flint
#

Stripe is good and all but won't work in this case

quaint wasp
#

Strip I think

#

Hmm

spark flint
#

Unless i figured out Stripe Connect

proven lantern
#

what's a good merchant rate now?

zenith knoll
#

im getting into using prettier and i have looked through the options page of their website, but cant seem to find an override for formatting if statements

For example,

if(statementA || statementB) return;

gets turned into

if (
  statementA ||
  statementB
)
  return;
#

my current prettierrc file is this:

trailingComma: 'es5'
tabWidth: 4
semi: true
singleQuote: true
useTabs: true
bracketSameLine: true
tribal crow
#

Hey! I have made an economy bot, and I want to improve my current /work command. Currently the /work command doesn't let you do anything except for paying you for a random amount of work-hours. I want it to be something like this with random questions and tasks:

Q: What letter is missing? You_ube

A: T

If the person's next message is T, it should respond with a message and give the money.

What is the best way of doing this?

sudden geyser
#

If you have the message intent, you could listen for the next message from the user and see if it's correct

#

In Discord.js, for example, you'd use collectors

#

For slash commands, there's none of that waiting stuff

#

You could make a subcommand for that, like /work answer ... ..., but it would probably be much harder.

tribal crow
#

ah, i see.

#

Ty for your advice :)

merry glade
#

Hello everyone, I am just about to fill out my verification for my bot and have asked myself the question, when or for what one needs the Message Content Intent?

sudden geyser
#

If your bot "has unique functionality that cannot be replicated or otherwise implemented with interactions", according to Discord.

tight scaffold
#

Hey guys, am using c#, can someone help me figure out what's making my bot use about 1-2gb per shard?

quartz kindle
#

you dont need it if all your commands are slash commands

tight scaffold
#

This is kinda ridiculous, 1.6gb on one shard

#

Only 673 servers on that shard

merry glade
tight scaffold
#

Anyone waiting

quartz kindle
#

never used d.net or c# in general, so idk how the library is structured

woeful pike
#

I think last I checked Miki uses 6gb on 350k servers yeriyikes

zenith knoll
#

is there a prettier alternative to the "curly" rule in eslint? in addition to my question here #development message

earnest mural
#

probably

quartz kindle
#

but look into caching, what d.net ia storing for you, if there are ways to customize it, etc

sudden geyser
quartz kindle
#

user.edge_followed_by.count?

#

and what does that console.log show?

spark flint
#

Use pastebin

#

Or similar

quartz kindle
#

^

spark flint
round cove
quartz kindle
#

result.user.edge_followed_by.count

green kestrel
#

there's significant overhead for the db layer to speed it all up

zenith knoll
simple stump
#

Can I delete a collected message?

message.channel
        .send("Please send your IGN.", { fetchReply: true })
        .then(() => {
          message.delete();
          message.channel
            .awaitMessages({ filter, max: 1, errors: ["time"] })
            .then((collected) => {
              collected.delete(); // ?
...
winter pasture
#

Could you try:

const Discord = require("discord.js");
const ig = require("instagram-scraping");

module.exports = {
  name: "insta",
  description: "name command",
  execute(message, args) {
    const userArg = args.slice(0).join(" ");

    ig.scrapeUserPage(String(userArg))
      .then(({ user }) => {
        const embed = new Discord.MessageEmbed();

        const name1 = user.full_name;
        const image1 = user.profile_pic_url;
        const followcount = user.edge_followed_by.count;
        const followingcount = user.edge_follow;

        embed
          .setTitle(`${name1}'s info` || "undefined")
          .setThumbnail(image1 || " ")
          .addField(followcount + "." || "none")
          .addField(followingcount + "." || "none");

        message.channel.send(embed);
      })
      .catch((error) => {
        console.log(error);
      });
  },
};

Not able to test code atm, but you where not calling .setTitle on the embed. If it errors, please send the error message

simple stump
#

collected.delete() doesnt work. mb i shouldve specified that

zenith knoll
#

is there no error message

#

like error type

#

or code thing

winter pasture
#

Yeah that is the error the instagram-scraping lib gives

zenith knoll
#

google?

winter pasture
#

So it is not the embedded or the code I provided above erroring

zenith knoll
#

instagram must tell you the different problems and solutions of scraping errror

#

the api must have a documentation right

winter pasture
#

I am getting the same error. Probably Instagram blocking the scraping calls
Contact the owner of the library, not your code

tribal crow
#

Quick question, how do i get the selected choice from a .addChoice()? (Slashcommands)

earnest phoenix
#

is it possible to add AI to javascript/html games?

#

or at least moving obstacles that follows you/random user

lament rock
#

It's possible to do anything in any language that's turing complete

earnest phoenix
#

ok

real phoenix
#

Using discord.py and I'm making a command to test buttons. However its returning an error that says the command doesn't exist.

import os
import discord
from discord.ext import commands, tasks
from discord_components import Button, Select, SelectOption, ComponentsBot
import datetime
from keep_alive import keep_alive

bot = ComponentsBot("!")

intents = discord.Intents.default()
intents.members = True
activity = discord.Activity(type=discord.ActivityType.watching, name="for March 12th")
client = commands.Bot(command_prefix="-", intents=intents, activity=activity)
token = os.environ['token'] 
client.remove_command("help")

@client.event
async def on_ready():
    print("Hello World!")
    print(f"Logged in as {client.user}")

@client.command
async def button(ctx):
    await ctx.send("Buttons!", components=[Button(label="Button", custom_id="button1")])
    interaction = await bot.wait_for(
        "button_click", check=lambda inter: inter.custom_id == "button1"
    )
    await interaction.send(content="Button Clicked")

keep_alive()
client.run(token)

error

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "button" is not found
earnest phoenix
#

can anyone help me to do a moving obstacle that follows the player until it hits him or the player hits the obstacle with the bullets

zenith knoll
#

if i enable the "guilds" intent, does that include every intent under the guilds section or do i need to enable every single one

#

like get every category main from this list

#

(guilds, guild_members, guild_bans, etc)

#

i remember they removed the "all" option from working right

pale vessel
#

yes

#

They're events

spark flint
#

so uh

#

what would be the best way to check a time difference in nodejs

quartz kindle
#

like between two times or different timezones?

spark flint
#

between two different times

quartz kindle
#

timestamp - timestamp

proven lantern
#

when is discord giving us forms

spark flint
#

atm i store using Date().getTime(); and get the current time and compare

#

but when it gets to 60 as the difference it resets to 0

quartz kindle
#

wut

#

how are you comparing it?

spark flint
#

savedtime-currenttime

quartz kindle
#

it cant possibly reset to 0

spark flint
#

oh

#

i'm so confused lol

quartz kindle
#

its literally two numbers in a subtraction

sudden geyser
spark flint
#
        const diff = check.when - now
        console.log(diff)```
#

it returns 60 and when i refresh page again it returns 0

#

1640131092228

#

it stores like that

quartz kindle
#

are you storing again on page refresh?

spark flint
#

nope

#

it just outputs current difference

#

it only stores the current time when i click submit

#

which is on an entirely different page and the time in the db is still the same

quartz kindle
#

console log check.when and now

#

individually

spark flint
#

ok

quartz kindle
#

thats literally not possible dafuq

spark flint
#

wait

#

i fixed it

#

somehow

sudden geyser
#

time is a bitch

boreal iron
#

True

simple stump
#

how would i get the second user mentioned?

sudden geyser
#

what library

crimson vapor
#

that doesn't really matter iirc because mentions aren't ordered the same way as they are appear in the message
in pretty sure you need to parse the message content
!command <@id> <@id> and grab the second one
I assume you aren't using slash commands

sudden geyser
#

some libraries will go out of their way to parse and grab the mentions for you

#

and some will order it by how they appear in the message

#

I think Discord.js orders it for example

boreal iron
#

Order as received from the API, not as they appear in the message content

sudden geyser
#

ah so it doesn't

boreal iron
#

Nope

simple stump
#

ah i see. aight thx

#

thats helpful

earnest phoenix
#
  let number = db.fetch(`numwarns_${message.guild.id}_${user1}`)
  let warnid1 = uuidv4() 
let warnid = db.fetch(`warnid_${message.guild.id}_${number}`)
  let reason =  db.fetch(`warnreason_${message.guild.id}_${warnid1}`)
  
db.add(`numwarns_${message.guild.id}_${user1}`, 1)
db.set(`warnid_${message.guild.id}_${number}`, warnid1)
db.set(`warnreason_${message.guild.id}_${warnid}`, reason)```
Am I doing this wrong?
#

Nvm

real phoenix
#

How do I get the number of text channels a server has with discord.py? discord.guilds.text_channels returns a list

spark flint
#

len(discord.guilds.text_channels)

real phoenix
#

ty

spark flint
#

Usually it would be len(ctx.guild.text_channels)

#

That gets it when you do a command

real phoenix
#

yeah ik

#

Also embed.set_thumbnail isn't working. Should I covert it to a string?

embed.set_thumbnail(ctx.Guild.icon_url)

error:

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_thumbnail() takes 1 positional argument but 2 were given
real phoenix
#

🤦‍♂️

#

ofc

golden path
earnest phoenix
real phoenix
#

yeah i already fixed it. Ty tho

earnest phoenix
neat ingot
#

So, I was improving my /info command, and I ended up writing a handy little module to convert md files info discord embed using this md file formatting:

# TITLE #
Some title

# COLOR #
RANDOM

# AUTHOR #
user.name, user.avatar, https://discord.com/

# THUMBNAIL #
bot.avatar

# DESCRIPTION #
Some description...

# FOOTER #
user.name, user.avatar

# FIELD #
label, string, true

# FIELDS #
label, string, true
label, string, true
label, string, true

# TIMESTAMP #
false```
The embed data is made dynamic using a simple object given when creating/sending the embed, like this: 
```js
    const md_data = EmbedMD.prepareMD('/directory/path.md');
    const embed = EmbedMD.getEmbed(md_data, {
        'bot.name': interaction.client.user.username,
        'bot.avatar': interaction.client.user.displayAvatarURL(),
        'user.name': interaction.user.username,
        'user.avatar': interaction.user.displayAvatarURL(),
    });
#

Anyway, wondering if i should release it as an actual module package? seems the kinda thing others might get a use from too (it requires/uses discord.js)

sly sierra
#

huh

sly sierra
#

go for it

#

looks pretty good

neat ingot
#

thanks. yea, it works fairly well. I have it reading an entire directory of md files, and then using the filenames as the choices for a command option. so i can do commands like /info about:somefilename and it automatically reads the file and parses it and junk

#

helps keep that command super neat at least 😄

sly sierra
#

dangg*

#

yea i would like to test it out when i can aswell

#

so def would be fun and a cool project

neat ingot
#

lol no worries, ill probably tidy it up and upload it in a little bit then, get some feedback on it 😄

sly sierra
#

Goodluck!

velvet jolt
#

cool 🤓🤓weirdsip

neat ingot
#

yea, i got that... and i was like... when did i verify my bot???

#

still cant figure out which bot was verified, or if it was 😄

velvet jolt
#

na mine is verified lmao

neat ingot
#

dont you get a verified bot dev badge thing?

velvet jolt
#

na

#

i verified my bot too late

neat ingot
#

awww, was that only the early verified people?

#

cause iw as totally meant to do mine back then

#

lmao

velvet jolt
#

ueah

#

yeah

neat ingot
#

fml in the ear

velvet jolt
#

ik

#

i verified it 1 month later

#

i guess so

#

lol

feral aspen
#

Is this not possible?

settings.settings = settings.settings.filter(x => x !== ({ id: setting }));
#

I'm trying to remove an object from an array that has an ID of setting which is a value like 0..

pale vessel
#

x.id !== setting?

feral aspen
#

.. and keep the rest.

pale vessel
#

Or JSON.stringify(x) !== JSON.stringify({ id: setting })

feral aspen
#

I can remove this object?

feral aspen
pale vessel
#

Ah

feral aspen
#

Yeah. Eyes

feral aspen
#

Nope, it's not removing. [{"id":"newfollower"}]

pale vessel
#

What's x?

#

An object is always going to be unique

feral aspen
pale vessel
#

You can't compare it like that

#

You have to serialize it

feral aspen
#

What do you mean?

pale vessel
feral aspen
pale vessel
#

JSON.stringify() turns the object to a string. so you can compare it with another serialized/stringified object

feral aspen
#

Although, there could be multiple objects in the array?

feral aspen
pale vessel
#

No, x is an object

feral aspen
#

OH, so x.id !== setting.

pale vessel
#

Yeah, that would be better

feral aspen
#

Sweet, it works. 👍

#

By the way, can this be simplified, more?

if (!hasToast) {
    inventory.inventory['toast'] = 1;
} else {
    inventory.inventory['toast']++;
};
pale vessel
#

inventory.inventory['toast'] = ihastoast ? ++inventory.inventory['toast'] : 1;

feral aspen
#

I have this code, and as you can see at if (!settings) return;, can I break out of the entirety of the Settings.findOne code and continue with the authorSocial.following = ... if no settings were found? Should I do this using promises?

pale vessel
#

Use await instead of callbacks or move all the code outside that callback inside the callback

feral aspen
#

Part of my learning process, could you tell me what you refer when you mention callback?

pale vessel
#

The function you provide to run after the library fetches data from the database

#

async (error, settings) => {}

feral aspen
#

Sweet, now when you stated await instead of callbacks, it means?

pale vessel
#
const data = await Settings.findOne({ userID: user.id });
if (!data) return;

authorSocial.following = ...;
...```
feral aspen
#

Well, alright. 👍

earnest phoenix
#

wow that looks so legit

#

i hope i dont get scammed

dry imp
#

damn bro 1 month free nitro omgpogey i hope its not a scam link

earnest phoenix
#

@solemn latch

neat ingot
#

@sly sierra Finally finished that module to convert md files into discord js embeds

#

feel free to critique, its my first actual published module 😄

sly sierra
#

alright ill give it a shot in a bit

#

in class atm

neat ingot
#

no rush 🙂

sand moth
#

hy

sly sierra
#

Hello

neat ingot
#

ew ts

#

dangit, im gonna have to write a ts version arent i

#

literally package been published for less than 5 minutes

#

lol

#

yea, but i dont generally bother with ts

#

eh, i could just add some comments for intellesense too

#

yea, i guess i can understand that

sly sierra
#

ah

#

calss is almost done

#

so i can finally test it

neat ingot
#

~ just updated the package with jsdoc comments, so it should give intellisense now 🙂

#

not quite ts, but im sure it will do 😄

hasty mulch
#

How do I force user input to be sentence case in Python?

neat ingot
#

eh, idk, im getting a random error now but i gotta run out lol, just @me if you get any issues, ill reply when i get home 🙂

quartz kindle
#

thats pretty much all you need

#

you dont need to actually write ts code

vale garden
#

hi

#

does anyone know what the http endpoint to getting a member's banner on a particular server is

#

nah thats not what im referring to

#

that is my global banner

#

hm

#

wait nvm in that case i could just inspect element and find out i guess

vale garden
pale vessel
#

for now it's under /users/:id/profile

#

which is for non-bot users only

vale garden
#

i mean under the endpoint you mentioned

pale vessel
#

they don't provide that

vale garden
#

or does it not work for bots yet

pale vessel
vale garden
#

thanks

pale vessel
#

user ones are exposed

#

nope

#

Give it some time

#

It rolled out recently

crimson vapor
#

I rolled out recently

covert scroll
#

Any arabic here !

full epoch
#

.

spark flint