本文整理汇总了TypeScript中discord.js.Message类的典型用法代码示例。如果您正苦于以下问题:TypeScript js.Message类的具体用法?TypeScript js.Message怎么用?TypeScript js.Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了js.Message类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getVoiceChannelFromMessageAuthor
public getVoiceChannelFromMessageAuthor(message: Message) {
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel) {
message.reply('Join a voice channel first!');
}
return voiceChannel;
}
开发者ID:DominusX,项目名称:discord-soundbot,代码行数:8,代码来源:VoiceChannelFinder.ts
示例3: isValidMessage
private isValidMessage(message: Message) {
return !message.isDirectMessage() &&
message.hasPrefix(this.prefix) &&
!this.db.isIgnoredUser(message.author.id);
}
开发者ID:DominusX,项目名称:discord-soundbot,代码行数:5,代码来源:MessageHandler.ts
示例4:
.then((reply: Message) => {
reply.delete(3000)
}
开发者ID:Zunon,项目名称:Sagiri,代码行数:3,代码来源:handlers.ts
注:本文中的discord.js.Message类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论