本文整理匯總了TypeScript中discord.js-commando.CommandMessage.reply方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript js-commando.CommandMessage.reply方法的具體用法?TypeScript js-commando.CommandMessage.reply怎麽用?TypeScript js-commando.CommandMessage.reply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類discord.js-commando.CommandMessage
的用法示例。
在下文中一共展示了js-commando.CommandMessage.reply方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: run
public async run(msg: CommandMessage, args: { cardName: string }): Promise<Message | Message[]> {
let filename: string
if (!msg.channel.typing) { msg.channel.startTyping() }
const card: Card = await CardData.findOne(args.cardName)
if (card) { filename = await card.getImageFile('art') }
if (msg.channel.typing) { msg.channel.stopTyping() }
if (!card) { return msg.reply(`sorry, I couldn't find a card with a name like '${args.cardName}'`) }
if (!filename) { return msg.reply(`sorry, there was a problem getting the art for ${card.name}`) }
const cleanFilename = path.basename(filename).replace('_', '')
return msg.embed(
new RichEmbed()
.setTitle(card.name)
.setURL(card.wikiUrl)
.setColor(card.classColor)
.addField('Artist', card.artist)
.attachFile({ attachment: filename, name: cleanFilename })
.setImage(`attachment://${cleanFilename}`)
)
}
示例2: run
public async run(msg: CommandMessage, args: { bnetServer: string }): Promise<Message | Message[]> {
const result = await CommunityDatabase.getQuestForUser(msg.author.id)
// Are they completing?
if (args.bnetServer === 'complete') {
if (result) {
return await CommunityDatabase.removeQuestsForUser(msg.author.id)
.then(() => msg.reply('congratulations! Removed your entry from those looking to trade quests.'))
}
return msg.reply('sorry, don\'t have you as looking to trade quests.')
}
const bnetServerDisplay = `Battle.net ${args.bnetServer} server`
// Check if they're on the list
if (result) {
if (result.server === args.bnetServer) {
return msg.reply(`already have you as looking to trade quests on the ${bnetServerDisplay}.`)
}
// Update entry to new server if different
return await CommunityDatabase.updateQuestsForUser(msg.author.id, args.bnetServer)
.then(() => msg.reply(
`updated your entry, now have you as looking to trade quests on the ${bnetServerDisplay}.`
))
}
// Check if another on the list shares a bnet and discord server
let results = await CommunityDatabase.getQuestsForServer(args.bnetServer)
if (results) {
// Get only quests where users share a guild
results = results.filter((q: any) => {
return this.client.guilds.some((g) => {
return g.members.has(msg.author.id) && g.members.has(q.userId)
})
})
if (results && results.length > 0) {
const requestor = this.client.users.get(msg.author.id)
const questHaver = this.client.users.get(results[0].user)
await questHaver.send(oneLine`
Hello! I have you on my list of people looking to trade Hearthstone quests.
${requestor} just told me they are also looking to trade on the ${bnetServerDisplay}.
Just contact them and enjoy your gold!\n\n
When you're all done, just tell me \`quest complete\`.
`).catch(winston.error)
return msg.reply(oneLine`
looks like someone you share a Discord server with is also looking to trade quests
on the ${bnetServerDisplay}! They should be contacting you soon.
`)
}
}
// Add them to the list
return await CommunityDatabase.addQuestForUserOnServer(msg.author.id, args.bnetServer)
.then(() => msg.reply(oneLine`
can't find a match for you right now, but will let you know as soon as
someone you share a Discord server with is also looking to trade quests on the ${bnetServerDisplay}.
`))
}
示例3: run
public async run(msg: CommandMessage, args: { cardName: string }): Promise<Message | Message[]> {
let filename: string
if (!msg.channel.typing) { msg.channel.startTyping() }
const card: Card = await CardData.findOne(args.cardName)
if (card) { filename = await card.getImageFile('gold') }
if (msg.channel.typing) { msg.channel.stopTyping() }
if (!card) { return msg.reply(`sorry, I couldn't find a card with a name like '${args.cardName}'`) }
if (!filename) { return msg.reply(`sorry, there was a problem getting the golden image for ${card.name}`) }
return msg.say('', { file: { attachment: filename } })
}
示例4: run
async run(message: CommandMessage, { soundKey }: Kwargs): Promise<any> {
const soundDir = path.join(__dirname, 'sounds')
const { voiceChannel } = message.member
// Commands are based on striped filenames minus mp3 extension
const availableCommands = fs
.readdirSync(soundDir)
.map(sound => sound.slice(0, -4))
/**
* @description If not in a voice channel
*/
if (!voiceChannel) {
return await message.reply('tu dois rejoindre un channel :triumph:')
}
/**
* @description If desired sound does not exist in folder
*/
if (availableCommands.indexOf(soundKey) === -1) {
return await message.reply(
`ce son n'existe pas, mais voici ceux disponibles :
${availableCommands.map(command => `\n**${command}**`)}
`
)
}
/**
* @description Join voice channel to play selected file
*/
voiceChannel
.join()
.then(connection => {
const dispatcher = connection.playFile(
path.join(__dirname, 'sounds', `${soundKey}.mp3`)
)
dispatcher.setVolume(0.5)
dispatcher.on('end', () => {
voiceChannel.leave()
})
})
.catch(console.error)
}
示例5: run
public async run(msg: CommandMessage, args: { cardName: string }): Promise<Message | Message[]> {
if (!msg.channel.typing) { msg.channel.startTyping() }
const card: Card = await CardData.findOne(args.cardName)
if (msg.channel.typing) { msg.channel.stopTyping() }
if (!card) { return msg.reply(`sorry, I couldn't find a card with a name like '${args.cardName}'`) }
return msg.code('json', JSON.stringify(card.json, undefined, ' '))
}
示例6: run
async run(message: CommandMessage): Promise<any> {
const { member, guild } = message
if (member.voiceChannel) {
// Send event to dispatcher in play.ts
if (member.voiceChannel.connection.dispatcher) {
const song = music.getNextMusic(guild.id)
if (song) {
message.channel.send(
`Prochaine musique : ${song.title} - ${song.channelTitle}`
)
} else {
message.reply(
'ArrĂŞt de la musique ... (plus de musique dans la playlist)'
)
}
member.voiceChannel.connection.dispatcher.end()
} else {
message.reply('Plus de musique dans la playlist')
}
}
}
示例7:
.then(() => msg.reply(
`updated your entry, now have you as looking to trade quests on the ${bnetServerDisplay}.`
))