#get channel id (fixed)

1 messages · Page 1 of 1 (latest)

tardy patio
pulsar prawn
#

I believe you have the same problem as I do

neon wigeon
#

i think, you need make someone like this:

const something = await interaction.guild.channels.create ....

console.log(something.id or something.channel.id)
tardy patio
#

id of that channel

#

but when i try to set result.id to targetchannel it doesnt work

neon wigeon
#

because

#

you need to fetch it?

#

wait

#
const channel = client.channels.cache.get('id');
tardy patio
#

i need to get it like this, or get channel id by its name

neon wigeon
#

let me investigate

tardy patio
#

ok

neon wigeon
#

i will create a command like your's on my bot to see

tardy patio
#

ok

#

and it didnt work

neon wigeon
#

you will probably have to fetch the roles

tardy patio
#

why roles?

neon wigeon
#

i will create a test role

#

role_mods_id

#

I don't know to what extent channels.create only accepts the role id

#

I'll see

#

I tell you something

tardy patio
#

its for support to see that channel and also for author

#

with this it says undefined

neon wigeon
#

yes i know that

#

I was just wondering if he accepted just the id without fetch the roles first

#

I went to see the docs

#

and accepts

#

I'm going to create a test role and see if it works

tardy patio
#

so it shows id ?

#

because i want to send message after create to mention author

neon wigeon
#

I haven't tested the create channel part yet.

tardy patio
#

ok

#

it works but i need that id

neon wigeon
#

they was created

#

i just

#

try to send a message after it

tardy patio
#

no no

#

it creates channel with perms fine

#

but i after channel is created, i need to get its id to send message

neon wigeon
#

ye

#

i will test it now

#

@tardy patio

#
const { MessageEmbed } = require('discord.js');
const colors = require('colors/safe');

module.exports = {
    name: 'test',
    description: 'test!',
    cooldown: 5,
    args: false,
    usage: '',
    guildOnly: true,
    aliases: ['test'],

    // eslint-disable-next-line no-unused-vars
    async execute(client, message, args) {
        try {
            const min = 0;
            const max = 9999;
            const count = Math.floor(Math.random() * (max - min + 1)) + min;
            const author = message.author.username;

            const createdChannel = await message.guild.channels.create(`${author}${count}`, {
                type: 'GUILD_TEXT',
                permissionOverwrites: [{
                    id: message.author.id,
                    allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
                },
                {
                    id: message.guild.id,
                    deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
                },
                {
                    id: '981650027879481434',
                    allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
                },
                ],
            });

            const channel = client.channels.cache.get(createdChannel.id);
            channel.send({ content: 'test' });
        }
        catch (error) {
            console.log(colors.brightRed(error));
        }
    },
};
#

just change the message to interaction

#

should work

tardy patio
#

ok ill try it

neon wigeon
#

and also adapts the roles id

tardy patio
#

adapts?

neon wigeon
#

I deleted the options you had

#

yes

tardy patio
#

oh

neon wigeon
#

the roles id que vem do config.json

#

fuck corrector

#

the roles.id settings that come from config.json

#
const { role_stuff_id, role_mods_id, role_supports_id } = require("../../settings.json")
#

something just @neon wigeon

tardy patio
#

bruh

#

now it shows error in event handler

#

omg thanks

#

it works

#

get channel id (fixed)

neon wigeon
#

¯_(ツ)_/¯

tardy patio
#

could you help me with mentioning?

#

instead test message?

#

@neon wigeon

neon wigeon
#

on

#

can u send u code

#

again

#

not to be adapting again

tardy patio
#

instead channel.send({ content: 'test' });

#

i want to mention author

neon wigeon
#

channel.send({ content: <@!${interaction.author.id}> });

#

try this

tardy patio
#

ok

#

oh yeah

#

thank you so much

neon wigeon
#

np

tardy patio
#

i was working on this shit for like 2 days xd

neon wigeon
#

normal for begginers

#

I've been like this for a while and I still am

tardy patio
#

ive created some bots but on latest node version im having problems with everything xd

neon wigeon
#

discord.js v13 be like

#

loved the 12

#

much more now

tardy patio
#

ya

#

you learn to make bots on v12 and then theres v13 xd

neon wigeon
#

ye

#

in my case

#

was on v11

tardy patio
#

im too old to relearn it xd

neon wigeon
#

you can no longer use it XD

#

now only v13

#

and with luck v12