GVKun编程网logo

类型错误:无法读取 discord.js 中未定义错误的属性“发送”(无法读取未定义的属性长度怎么解决)

15

本篇文章给大家谈谈类型错误:无法读取discord.js中未定义错误的属性“发送”,以及无法读取未定义的属性长度怎么解决的知识点,同时本文还将给你拓展Angular-错误类型错误:无法读取未定义的属性

本篇文章给大家谈谈类型错误:无法读取 discord.js 中未定义错误的属性“发送”,以及无法读取未定义的属性长度怎么解决的知识点,同时本文还将给你拓展Angular - 错误类型错误:无法读取未定义的属性“名称”、discord.js - TypeError:无法读取未定义错误的属性“缓存”、不断收到错误:未捕获的类型错误:无法读取未定义的属性“querySelector”、传单拆分图:类型错误:无法读取未定义的属性“样式”等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

类型错误:无法读取 discord.js 中未定义错误的属性“发送”(无法读取未定义的属性长度怎么解决)

类型错误:无法读取 discord.js 中未定义错误的属性“发送”(无法读取未定义的属性长度怎么解决)

好吧,Bot 又名 Client 在登录之前不存在,因此没有缓存任何频道。这就是频道是 undefined 的原因。
试试这个

const Discord = require('discord.js');
const botsettings = require('./botsettings.json');
const Bot = new Discord.Client({disableEveryone: true});

Bot.on("ready",async() => {
    //Now the bot is logged in and all channels are ready to be cached
    const Channel = Bot.channels.cache.get(botsettings.channelid);
    Channel.send("Hi,@everyone")
})

Bot.login(botsettings.token);
,

当机器人启动时,您没有任何缓存的频道。您需要获取它们。

const Discord = require('discord.js');
const botsettings = require('./botsettings.json');
const Bot = new Discord.Client({disableEveryone: true});
const Channel = Bot.channels.fetch(botsettings.channelid); // here

Bot.on("ready",async() => {
    Channel.send("Hi,@everyone")
})

Bot.login(botsettings.token);

Angular - 错误类型错误:无法读取未定义的属性“名称”

Angular - 错误类型错误:无法读取未定义的属性“名称”

如何解决Angular - 错误类型错误:无法读取未定义的属性“名称”?

在我的 Angular-12 项目中,我使用以下代码注册用户并使用 Laravel-8 api 将图像插入到目录和数据库中:

界面:

export interface ICompanySetup {
  companyName: string;
  registrationNumber: string;
  dateEstablished: Date;
  company_logo: any;
 }

服务:

createCompanySignup(data: any): Observable<ICompanySetup[]> {
  return this.http.post<ICompanySetup[]>(this.api.baseURL + ''signup'',data,this.httpOption);
}

组件:

import {
  ApiService
} from ''src/app/services/api.service'';

export class SignupComponent implements OnInit {
  isLinear = true;
  isLoading = false;
  companySetupForm!: FormGroup;
  companyForm!: FormGroup;
  idForm!: FormGroup;
  imageSrclogo!: string | ArrayBuffer;
  files: any;

  constructor(
    private fb: FormBuilder,private api: ApiService,private route: Router,) {}

  onFileChange(event: any) {
    const reader = new FileReader();

    if (event.target.files && event.target.files.length) {
      const [file] = event.target.files;
      reader.readAsDataURL(file);

      reader.onload = () => {
        this.imageSrclogo = reader.result as string;

        this.companyInfoForm.get(''company_logo'') ? .setValue(file);
      };

    }
  }

  ngOnInit() {
    this.companyForm = this.fb.group({
      companyName: ['''',[Validators.required,Validators.minLength(3),Validators.maxLength(100)]],dateEstablished: ['''',[Validators.required]],company_logo: ['''',[
        RxwebValidators.extension({
          extensions: ["jpg","jpeg","bmp","png","gif","svg"]
        })
      ]],},{
      updateOn: "blur"
    });
    this.idForm = this.fb.group({
      registrationNumber: ['''',});
  }

  get fc() {
    return this.companyForm.controls;
  };
  get fi() {
    return this.idForm.controls;
  };

  onSubmit() {
    this.isSubmitted = true;

    const formCompanyData = this.companyForm.getRawValue();
    const formIdData = this.idForm.getRawValue();

    const formData = new FormData();
    var datestr = (new Date(formCompanyData.dateEstablished)).toUTCString();
    formData.append(''companyName'',formCompanyData.companyName);
    formData.append("company_logo",this.files,this.files.name);
    formData.append(''registrationNumber'',formCompanyData.registrationNumber);
    formData.append("dateEstablished",datestr);

    this.spinnerService.show();
    const header = {
      ''Content-Type'': ''application/json''
    };

    this.isLoading = true;
    this.companyService.createCompanySignup(formData).subscribe((res: any) => {
        this.router.navigate([''admin/category'']).then(() => this.showToasterSuccess(res.message));
      },error => this.router.navigate([''admin/category'']).then(() => this.showToasterError(error[0].message))
    );;
  }
}

HTML:

<mat-horizontal-stepper [linear]="isLinear" #stepper labelPosition="bottom">
  <mat-step [stepControl]="companyForm">
    <form [formGroup]="companyForm">
      <ng-template matStepLabel matStepperIcon="phone">Company Info</ng-template>

      <div>
        <div>
          <divhttps://www.jb51.cc/tag/Box/" target="_blank">Box-profile">
            <div>
              <img[src]="imageSrclogo || ''assets/img/no-image.png''" alt="No Company logo">
            </div>

            <h3>Company logo</h3>

            <div>
              <label for="file"></label>
              <input formControlName="company_logo" id="file" type="file"(change)="onFileChange($event)">
            </div>
          </div>
        </div>
      </div>
      <div>
        <div>
          <label for="dateEstablished">Date Registered:<span>*</span></label>
          <mat-form-field fxFlex="100%" fxFlex.gt-sm>
            <input matInput [matDatepicker]="dateEstablished" placeholder="Choose a date" [max]="tomorrow" formControlName="dateEstablished" readonly required>
            <mat-datepicker-toggle matSuffix [for]="dateEstablished"></mat-datepicker-toggle>
            <mat-datepicker #dateEstablished></mat-datepicker>
          </mat-form-field>
        </div>
        <div *ngIf="fc.dateEstablished.touched && fc.dateEstablished.invalid">
          <div *ngIf="fc.dateEstablished.hasError(''required'')">
            <div>
              Date Registered is required!
            </div>
          </div>
        </div>
      </div>
      <div>
        <div>
          <label for="name">Company Name:<span>*</span></label>}
          <input type="text" formControlName="companyName" placeholder="Company Name"required/>
        </div>
        <div *ngIf="fc.companyName.touched && fc.companyName.invalid">
          <div *ngIf="fc.companyName.hasError(''required'')">
            <div>
              Company Name is required!
            </div>
          </div>
          <div *ngIf="fc.companyName.hasError(''minlength'')">
            <div>
              Company Name cannot be less than 3 characters!
            </div>
          </div>
          <div *ngIf="fc.companyName.hasError(''maxlength'')">
            <div>
              Company Name cannot be more than 100 characters!
            </div>
          </div>
        </div>
      </div>
      <div>
        <button mat-raised-button color="primary" matStepperNext [disabled]="companyForm.status != ''VALID''">Next</button>
      </div>
    </form>
  </mat-step>
  <mat-step [stepControl]="idForm">
    <form [formGroup]="idForm">
      <ng-template matStepLabel>Company ID</ng-template>
      <div>
        <div>
          <label for="registration_number">Registration Number:<span>*</span></label>
          <input type="text" formControlName="registrationNumber" placeholder="Registration Number"required/>
        </div>
        <div *ngIf="fi.registrationNumber.touched && fi.registrationNumber.invalid">
          <div *ngIf="fi.registrationNumber.hasError(''required'')">
            <div>
              Company Reg. No. is required!
            </div>
          </div>
          <div *ngIf="fi.registrationNumber.hasError(''maxlength'')">
            <div>
              Company Reg. No. cannot be more than 100 characters!
            </div>
          </div>
        </div>
      </div>
      <div>
        <button mat-raised-button color="black" matStepperPrevIoUs>Back</button> &nbsp;
        <button mat-raised-button color="success" [disabled]="isLoading" type="submit" (click)="onSubmit()">
                            <span *ngIf="isLoading"></span>
                              Submit
                          </button> &nbsp;
        <button mat-raised-button color="warn" (click)="stepper.reset()">Reset</button>
      </div>
  </mat-step>
</mat-horizontal-stepper>

this.files.name 是更改时 company_logo 的名称。

当我提交表单时,我收到了这两 (2) 个错误:

  1. core.js:6456 错误类型错误:无法在“FormData”上执行“append”:参数 2 不是“Blob”类型。
  1. 错误类型错误:无法读取未定义的属性“名称”

它指向:

formData.append("company_logo",this.files.name);

我正在尝试使用徽标上传来注册用户。我已经解决了很长时间没有任何解决方案。

我该如何解决这个问题?

或者有什么更好的方法吗?

尤其是第一个错误。

谢谢

解决方法

在您发布的代码中,您没有在任何地方为 this.files 设置值。由于错误指出字段 this.files 仍然是 undefined,因此当它尝试访问 this.files.name 时,它报告错误,在 undefined 上找不到任何字段名称。

解决方案:为 this.files 设置一个值并确保它也包含一个字段 name

discord.js - TypeError:无法读取未定义错误的属性“缓存”

discord.js - TypeError:无法读取未定义错误的属性“缓存”

Message 对象没有 channels 属性,您可能打算使用:

message.client.channels.cache.get() //...

不断收到错误:未捕获的类型错误:无法读取未定义的属性“querySelector”

不断收到错误:未捕获的类型错误:无法读取未定义的属性“querySelector”

如何解决不断收到错误:未捕获的类型错误:无法读取未定义的属性“querySelector”?

我收到一个错误,上面写着未捕获的类型错误:在日期验证时无法读取未定义的属性“querySelector”。 任何帮助将不胜感激。

这是我的 JSP 页面表单

  <form id="reg-form" action="RegisterServlet" methods="POST">
                                      
                                            <div>
                                              <label for="user_name">UserName</label>
                                              
                                              <input name="user_name" type="text"id="username" placeholder="Enter name">
                                              <small></small>

                                            </div>
                                            <div>
                                              <label for="user_email">Email address</label>
                                              <input name="user_email" type="email"id="email" aria-describedby="emailHelp" placeholder="Enter Email">
                                             
                                                 <small></small>

                                            </div>
                                            <div>
                                              <label for="user_password">Password</label>
                                              <input name="user_password" type="password"id="password" placeholder="Enter password">
                                                   <small></small>

                                            </div>
                                      
                                            <div> 
                                              <label for="confirm_password">Confirm Password</label>
                                              <input type="password" placeholder="confirm Password" name="confirm_password"id="confirm-password" >
                                                <small></small>
                                             </div>
                                      
                                            <div> 
                                            <label for="user_dob">Date of Birth</label>
                                            <input type="text" placeholder="Enter dob"name="user_dob" id="dob" >
                                              <small></small>
                                            </div>
                                      
                                           
                                            <div>
                                              <label for="user_regid">Registration ID</label>
                                              <input type="text" name="user_regid"id="regid" aria-describedby="regid" placeholder="Enter Reg. ID">
                                                 <small></small>

                                            </div>
                                      
                                             <div>
                                              <label for="user_rollno">Roll No.</label>
                                              <input type="text" name="user_rollno"id="roll" aria-describedby="year" placeholder="(e.g) 31384">
                                                 <small></small>

                                            </div>
                                      
                                           
                                      
                                            <div>
                                              <label for="user_no">Contact No.</label>
                                              <input type="text"name="user_no"  id="" aria-describedby="year" placeholder="Enter 10-digit phone number">
                                                  <small></small>

                                            </div>
                                      
                                           
                                      
                                          
                                      
                                      
                                            <div>
                                              <input type="checkBox" name="user_check"id="exampleCheck1">
                                              <labelfor="exampleCheck1">I Agree terms and conditions</label>
                                            </div>
                                      
                                      
                                      <br>
                                      <divhttps://www.jb51.cc/tag/dis/" target="_blank">display: none" id="loader">
                                      <span></span>
                                      <h4> Please wait...</h4>
                                      </div>
                                      <br>
                                            <button id="submit"  type="submit">Submit</button>
                                          </form>

这是发生错误的部分(日期验证)

 <div> 
 <label for="user_dob">Date of Birth</label>
  <input type="text" placeholder="Enter dob"name="user_dob" id="dob" >
  <small></small>
  </div>

这是我的 JS 代码,只发布了发生错误的部分。


const dateE1=document.getElementById(''dob'');

const debounce = (fn,delay = 500) => {
    let timeoutId;
    return (...args) => {
        // cancel the prevIoUs timer
        if (timeoutId) {
            clearTimeout(timeoutId);
        }
        // setup a new timer
        timeoutId = setTimeout(() => {
            fn.apply(null,args)
        },delay);
    };
};


form.addEventListener(''input'',debounce(function (e) {
    switch (e.target.id) {
        case ''username'':
            checkUsername();
            break;
        case ''email'':
            checkEmail();
            break;
        case ''password'':
            checkPassword();
            break;
        case ''confirm-password'':
            checkConfirmPassword();
            break;
        case ''dob'':
            checkDate();
            break;
    }
}));

const checkDate = () => {

    let valid = false;

   

    const mydate = dateE1.value.trim();

    if (!isrequired(mydate)) {
        showError(mydate,''date cannot be blank'');
    } 
    else {
        showSuccess(mydate);
        valid = true;
    }
    return valid;
};

const isrequired = value => value === '''' ? false : true;

const showError = (input,message) => {
    // get the form-field element
    const formField = input.parentElement;
    // add the error class


    // show the error message    const error = formField.querySelector(''small'');

    const error = formField.querySelector(''small'');
    error.textContent = message;
};

const showSuccess = (input) => {
    // get the form-field element
    const formField = input.parentElement;



    // hide the error message
    const error = formField.querySelector(''small'');
    error.textContent = '''';
}



任何帮助将不胜感激

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

传单拆分图:类型错误:无法读取未定义的属性“样式”

传单拆分图:类型错误:无法读取未定义的属性“样式”

如何解决传单拆分图:类型错误:无法读取未定义的属性“样式”?

我正在尝试使用动态 Url 处理实现一个 react-leaflet 地图,代码如下:

    // some code here ///
    const sideBySideMap = L.control.splitMap(
        L.tileLayer(tiles[leftTileIndex]._url,{
            tms: true,opacity: 1,attribution: "",minZoom: 1,maxZoom: 16,}),L.tileLayer(tiles[rightTileIndex]._url,''padding: 50;'',})
    );

    useEffect(() => {
        if (map) {
            sideBySideMap.addTo(map);
        }
    },[map]);

这种和平正在生成分割地图的实例,我正在尝试在使用效果中将分割地图图层添加到地图中,但出现错误 ->“类型错误:无法读取未定义的属性''样式''” . Screen Shot Of Error。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

关于类型错误:无法读取 discord.js 中未定义错误的属性“发送”无法读取未定义的属性长度怎么解决的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Angular - 错误类型错误:无法读取未定义的属性“名称”、discord.js - TypeError:无法读取未定义错误的属性“缓存”、不断收到错误:未捕获的类型错误:无法读取未定义的属性“querySelector”、传单拆分图:类型错误:无法读取未定义的属性“样式”等相关内容,可以在本站寻找。

本文标签:

上一篇函数 window.jitaJS.rtk.refreshAdUnits 中的第二个参数(useeffect第二个参数为函数)

下一篇使用 JS 后端和 Python 进行机器学习(js前端 python后端)