move out src/test to test
This commit is contained in:
parent
f812e06d17
commit
46cbd66166
26 changed files with 51 additions and 45 deletions
26
test/cmds/addemoji.ts
Normal file
26
test/cmds/addemoji.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { Command, CommandContext } from '../../mod.ts'
|
||||
|
||||
export default class AddEmojiCommand extends Command {
|
||||
name = 'addemoji'
|
||||
aliases = ['ae', 'emojiadd']
|
||||
args = 2
|
||||
guildOnly = true
|
||||
|
||||
execute(ctx: CommandContext): any {
|
||||
const name = ctx.args[0]
|
||||
if (name === undefined) return ctx.message.reply('No name was given!')
|
||||
const url = ctx.argString.slice(name.length).trim()
|
||||
if (url === '') return ctx.message.reply('No URL was given!')
|
||||
ctx.message.guild?.emojis
|
||||
.create(name, url)
|
||||
.then((emoji) => {
|
||||
if (emoji === undefined) throw new Error('Unknown')
|
||||
ctx.message.reply(
|
||||
`Successfully added emoji ${emoji.toString()} ${emoji.name}!`
|
||||
)
|
||||
})
|
||||
.catch((e) => {
|
||||
ctx.message.reply(`Failed to add emoji. Reason: ${e.message}`)
|
||||
})
|
||||
}
|
||||
}
|
20
test/cmds/eval.ts
Normal file
20
test/cmds/eval.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { Command, CommandContext } from '../../mod.ts'
|
||||
|
||||
export default class EvalCommand extends Command {
|
||||
name = 'eval'
|
||||
ownerOnly = true
|
||||
|
||||
async execute(ctx: CommandContext): Promise<void> {
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
let evaled = eval(ctx.argString)
|
||||
if (evaled instanceof Promise) evaled = await evaled
|
||||
if (typeof evaled === 'object') evaled = Deno.inspect(evaled)
|
||||
await ctx.message.reply(
|
||||
`\`\`\`js\n${`${evaled}`.substring(0, 1990)}\n\`\`\``
|
||||
)
|
||||
} catch (e) {
|
||||
ctx.message.reply(`\`\`\`js\n${e.stack}\n\`\`\``)
|
||||
}
|
||||
}
|
||||
}
|
16
test/cmds/join.ts
Normal file
16
test/cmds/join.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { Command, CommandContext } from '../../mod.ts'
|
||||
|
||||
export default class JoinCommand extends Command {
|
||||
name = 'join'
|
||||
guildOnly = true
|
||||
|
||||
async execute(ctx: CommandContext): Promise<void> {
|
||||
const userVS = await ctx.guild?.voiceStates.get(ctx.author.id)
|
||||
if (userVS === undefined) {
|
||||
ctx.message.reply("You're not in VC.")
|
||||
return
|
||||
}
|
||||
await userVS.channel?.join()
|
||||
ctx.message.reply(`Joined VC channel - ${userVS.channel?.name}!`)
|
||||
}
|
||||
}
|
26
test/cmds/kickFromSpecificVoice.ts
Normal file
26
test/cmds/kickFromSpecificVoice.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import {
|
||||
Command,
|
||||
CommandContext,
|
||||
ChannelTypes,
|
||||
VoiceChannel
|
||||
} from '../../mod.ts'
|
||||
|
||||
export default class KickFromSpecificVoiceCommand extends Command {
|
||||
name = 'kickFromSpecificVoice'
|
||||
|
||||
async execute(ctx: CommandContext): Promise<void> {
|
||||
if (ctx.guild !== undefined) {
|
||||
const channel = await ctx.guild.channels.get('YOUR VOICE CHANNEL ID')
|
||||
if (channel === undefined || channel.type !== ChannelTypes.GUILD_VOICE) {
|
||||
ctx.channel.send('The channel is either not a voice or not available.')
|
||||
return
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const members = await (channel as VoiceChannel).disconnectAll()
|
||||
members.forEach((member) => {
|
||||
ctx.channel.send(`Kicked member ${member.id}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
19
test/cmds/kickFromVoice.ts
Normal file
19
test/cmds/kickFromVoice.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { Command, CommandContext } from '../../mod.ts'
|
||||
|
||||
export default class KickFromVoiceCommand extends Command {
|
||||
name = 'kickFromVoice'
|
||||
|
||||
async execute(ctx: CommandContext): Promise<void> {
|
||||
if (ctx.guild !== undefined) {
|
||||
const voiceStates = await ctx.guild.voiceStates.array()
|
||||
if (voiceStates !== undefined) {
|
||||
voiceStates.forEach(async (voiceState) => {
|
||||
const member = await voiceState.disconnect()
|
||||
if (member !== undefined) {
|
||||
ctx.channel.send(`Kicked member ${member.id}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
test/cmds/leave.ts
Normal file
18
test/cmds/leave.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { Command, CommandContext } from '../../mod.ts'
|
||||
|
||||
export default class LeaveCommand extends Command {
|
||||
name = 'leave'
|
||||
guildOnly = true
|
||||
|
||||
async execute(ctx: CommandContext): Promise<void> {
|
||||
const userVS = await ctx.guild?.voiceStates.get(
|
||||
(ctx.client.user?.id as unknown) as string
|
||||
)
|
||||
if (userVS === undefined) {
|
||||
ctx.message.reply("I'm not in VC.")
|
||||
return
|
||||
}
|
||||
userVS.channel?.leave()
|
||||
ctx.message.reply(`Left VC channel - ${userVS.channel?.name}!`)
|
||||
}
|
||||
}
|
35
test/cmds/mentions.ts
Normal file
35
test/cmds/mentions.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { Command, CommandContext, Embed } from '../../mod.ts'
|
||||
|
||||
export default class PingCommand extends Command {
|
||||
name = 'mentions'
|
||||
aliases = ['m']
|
||||
|
||||
execute(ctx: CommandContext): void {
|
||||
const embed = new Embed()
|
||||
.setTitle('Mentions')
|
||||
.addField(
|
||||
'Users',
|
||||
`${
|
||||
ctx.message.mentions.users.size === 0 ? `None` : ''
|
||||
}${ctx.message.mentions.users.map((u) => u.toString()).join(', ')}`
|
||||
)
|
||||
.addField(
|
||||
'Channels',
|
||||
`${
|
||||
ctx.message.mentions.channels.size === 0 ? `None` : ''
|
||||
}${ctx.message.mentions.channels.map((u) => u.toString()).join(', ')}`
|
||||
)
|
||||
.addField(
|
||||
'Roles',
|
||||
`${
|
||||
ctx.message.mentions.roles.size === 0 ? `None` : ''
|
||||
}${ctx.message.mentions.roles.map((u) => u.toString()).join(', ')}`
|
||||
)
|
||||
.addField(
|
||||
'Everyone?',
|
||||
ctx.message.mentions.everyone === true ? 'Yes' : 'No'
|
||||
)
|
||||
.setColor(0xff0000)
|
||||
ctx.message.channel.send(embed)
|
||||
}
|
||||
}
|
10
test/cmds/ping.ts
Normal file
10
test/cmds/ping.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { Command, CommandContext } from '../../mod.ts'
|
||||
|
||||
export default class PingCommand extends Command {
|
||||
name = 'ping'
|
||||
|
||||
execute(ctx: CommandContext): void {
|
||||
console.log(ctx.args, ctx.argString)
|
||||
ctx.message.reply(`Pong! Latency: ${ctx.client.ping}ms`)
|
||||
}
|
||||
}
|
23
test/cmds/userinfo.ts
Normal file
23
test/cmds/userinfo.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Command, Member, CommandContext, Embed } from '../../mod.ts'
|
||||
|
||||
export default class UserinfoCommand extends Command {
|
||||
name = 'userinfo'
|
||||
guildOnly = true
|
||||
aliases = ['u', 'user']
|
||||
|
||||
async execute(ctx: CommandContext): Promise<void> {
|
||||
const member: Member = ctx.message.member as any
|
||||
const roles = await member.roles.array()
|
||||
const embed = new Embed()
|
||||
.setTitle(`User Info`)
|
||||
.setAuthor({ name: member.user.tag })
|
||||
.addField('ID', member.id)
|
||||
.addField('Roles', roles.map((r) => r.name).join(', '))
|
||||
.addField(
|
||||
'Permissions',
|
||||
JSON.stringify(member.permissions.has('ADMINISTRATOR'))
|
||||
)
|
||||
.setColor(0xff00ff)
|
||||
ctx.channel.send(embed)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue