當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript js.Message.delete方法代碼示例

本文整理匯總了TypeScript中discord.js.Message.delete方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript js.Message.delete方法的具體用法?TypeScript js.Message.delete怎麽用?TypeScript js.Message.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在discord.js.Message的用法示例。


在下文中一共展示了js.Message.delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: switch

client.on(`message`, (message: Message) => {
  // Check if message is a command
  if(message.content.startsWith(config.prefix)) {
    // Splits message into command and arguments
    var text: string[] = message.content.toLowerCase().split(` `)
    var command: string = text[0].substr(1)
    text.shift()
    // Matches command with known commands
    switch(command) {
      /*
        If it's a public command, it fires the handler straight away
        and passes the message object and the arguments passed into
        the command
      */
      /**
       * joinchannel and leavechannel commands
       * @deprecated
       * @todo Remove at the start of summer 2018
       */
      case `joinchannel`:
        joinChannel(message.member, message.guild, text)
        break
      case `leavechannel`:
        leaveChannel(message.member, message.guild, text)
        break
      /*
        If it's a command that requires elevation, it first checks
        that the user who sent the command passes the authentication
        function, and then it fires the handler with the appropriate
        arguments
      */
      case `doroles`:
        if (authenticate(message.member)) {
          doRoles(message.guild)
        } else {
            message.member.send('you must be an authorized user to use this command!')
        }
        break
      case `prune`:
        if (authenticate(message.member)) {
          prune(message.channel as TextChannel, parseInt(text[0]) + 1)
        } else {
          message.member.send('you must be an authorized user to use this command!')
        }
        break
      // If the command wasn't recognized, it replies saying that the command wasn't recognized
      default:
        message.member.send("sorry I didn't recognize that command.")
    }

    message.delete().then(
      () => {
        console.log("Deleted command message.")
      },
      () => {
        console.log("Couldn't delete message.")
      }
    )
  }
})
開發者ID:Zunon,項目名稱:Sagiri,代碼行數:60,代碼來源:main.ts

示例2:

 .then((reply: Message) => {
   reply.delete(3000)
 }
開發者ID:Zunon,項目名稱:Sagiri,代碼行數:3,代碼來源:handlers.ts


注:本文中的discord.js.Message.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。