Решено! Cannot read property ‘CreateObjectAsync’ of undefined

Решено! Cannot read property 'CreateObjectAsync' of undefined ЭЦП

Discord.js: typeerror: cannot read properties of undefined (reading ‘add’)

I searched all of Stack Overflow and the internet and found nothing helpful. I tried everything and it tells me the same thing. I’m making a Discord bot and trying to add a role to a user, but it keeps telling me I have an error. I have tried copying exactly what tutorials on YouTube and blogs did, but it tells me the same error. I’m being driven insane; I’ve tried to debug this error for over a week now. Here’s my code:

const targetUser = message.mentions.users.first()
    if(!targetUser) {
        message.reply('ya gotta specify someone to give the role to ya idiot')
        return
    }
//gets the user's username. For example: someone#0001



    args.shift()
//takes user out of the arguments array


    const roleName = args[0]

//finds the name of the role. For example: Mod.


    const { guild } = message
//not sure what this does. I copied it from a tutorial on YouTube. I think it just makes saying guild the same thing as saying message
    const rool = guild.roles.cache.find((role)=>{
        return role.name === roleName
    })
    const role = rool.toString().replace("<", "").replace(">", "").replace("@", "").replace("&", "")
//this gets the role id: for example: 912345678901234567



    if(!role) {
    message.reply(`There is no role with the name ${roleName}. btw, you might want to put the person you're adding the role to first, *and then* the role name.`)
//checks if role exists
    }



    const member = targetUser.id
//gets user id. For example: 812345678901234567 
    try{
        member.role.add(role)//THIS IS THE ONE I HAVE TROUBLE WITH. THE ONE LINE! ALL THE OTHERS WORK PERFECTLY FINE. I HAVE NO IDEA WHAT'S WRONG.
    } catch(bad){
    message.channel.send("i have bad bad error: "   bad   ". Please try again later. Much, much later.")
    message.channel.send(`btw, member = ${member} and the role is ${role}`)
    message.channel.send(typeof role)
    message.channel.send(typeof member)

//the role is a string. the member is a string. I checked, and they are right. I've seen other people do the exact same thing as me and it DOESN'T WORK.
    }

Feel free to ask for more code if you need it.
Whenever I run the code, because I have a catch, it tells me:

i have bad bad error: TypeError: Cannot read properties of undefined (reading 'add'). Please try again later. Much, much later.
btw, member = 768522095071985746 and the role is 925077346170585138
string
string

Maybe something is wrong with my compiler or runtime environment or all those other weird words programmers use?

Uncaught typeerror: cannot read property ‘add’ of undefined

You want to call add on the tile, but try to access the add function of the tiles array itself. This does not exist.

What you need to do is to access the add function of each individual tile. To do so, first get it:

var tile = tiles[i];

Then, change your call to

tile.classList.add(…);

(You could also omit the temporary variable tile, and use tiles[i].classList.add directly. But IMHO using a dedicated variable makes the code more clear to read.)

Another option, which may be even better, is to use forEach. Since you use the i only for accessing the current element and nothing else, you basically want to perform an action on each element. You can do it like this as well (and, for bonus points, this even protects you against off-by-one errors):

tiles.forEach(function (tile) {
  // ...
});

Then, within the function body, you automatically have a variable tile that you can access in the way you want to.

That’s it 🙂

Как победить ошибку "cannot read property of undefined"?

RAX7,

user_ids
https://vk.com/dev/users.get

как бы да, но всеравно ХЗ что за модуль он использует для доступа к vk api. Возможно, что используемый модуль вполне умеет и user_id обрабатывать. Проблема в том, что модуль не указан, посмотреть его доку не представляется возможным. Я например не пишу ботов под вк, и не в курсе, сколько там различных либ, для доступа к API понаписали, а лезть и целенаправленно разбираться с этим вопросом мне лень)

Решено! cannot read property ‘createobjectasync’ of undefined

При попытке использовать Крипто-Про ЭЦП на сайте ГосЗакупки может появиться ошибка со ссылкой на CreateObjectAsync. В этом случае подписать перевод в ЕИС либо невозможно совсем, либо удается не с первого раза. К сожалению, техническая поддержка работает довольно слабо и не дает нормального описания ошибки. Нам пришлось собирать информацию по крупицам, но кое-что удалось найти и это должно сработать.

Текст ошибки:

Cannot read property ‘CreateObjectAsync’ of undefined

Cannot read properties of undefined reading (“CreateObjectAsync”)

У нас есть несколько решений подобных ошибок. Мы точно не знаем, какое именно из них сработает, но что-то должно сработать. Попробуйте следующие действия.

Что нужно сделать:

  • Используйте браузер Спутник с поддержкой криптографии или IE. С казначейским программным обеспечением они работают лучше всего.
  • Переустановить Крипто-Про ЭЦП. Удалите его и установите заново. Для начала можно просто отключить и запустить заново.
  • Обновить или настроить сертификаты. Нужно запустить КриптоПро CSP, а дальше все выполняется на вкладке «Сервис».

Cannot read property 'CreateObjectAsync' of undefined

  • Отключить другие расширения. Если порядок подключения скриптов будет нарушен, будет появляться ошибка. Следует временно отключить все дополнения, особенно те, которые сейчас не используются.

Также следует на время использования отключить антивирус и брандмауэр, если таковые есть. Они могут мешать получению доступа к файлам и некоторым сетевым узлам. Надеемся, это сработает. На данный момент здесь описана вся информация по поводу данной проблемы, которую удалось найти в сети. Не стесняйтесь задавать вопросы, так как могут появляться новые сведения, полезные для вас.

Оцените статью
ЭЦП64
Добавить комментарий