2020-10-22 15:50:47 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
2020-11-01 12:05:22 +00:00
|
|
|
import { GatewayIntents } from '../types/gateway.ts'
|
2020-10-22 15:55:42 +00:00
|
|
|
import { TOKEN } from './config.ts'
|
2020-11-01 06:38:45 +00:00
|
|
|
import { Message } from "../structures/message.ts"
|
2020-11-01 11:22:09 +00:00
|
|
|
import { RedisCacheAdapter } from "../models/CacheAdapter.ts"
|
2020-11-02 07:27:14 +00:00
|
|
|
import { ClientPresence } from "../structures/presence.ts"
|
2020-10-22 15:50:47 +00:00
|
|
|
|
2020-11-02 07:27:14 +00:00
|
|
|
const bot = new Client({
|
|
|
|
presence: new ClientPresence({
|
|
|
|
activity: {
|
|
|
|
name: "Testing",
|
|
|
|
type: 'COMPETING'
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
forceNewSession: true
|
|
|
|
})
|
2020-10-22 15:50:47 +00:00
|
|
|
|
2020-11-03 05:19:57 +00:00
|
|
|
bot.setAdapter(new RedisCacheAdapter(bot, {
|
|
|
|
hostname: "127.0.0.1",
|
|
|
|
port: 6379
|
|
|
|
}))
|
2020-11-01 11:22:09 +00:00
|
|
|
|
2020-10-25 17:03:53 +00:00
|
|
|
bot.on('ready', () => {
|
2020-10-31 11:45:33 +00:00
|
|
|
console.log(`[Login] Logged in as ${bot.user?.tag}!`)
|
2020-11-02 07:27:14 +00:00
|
|
|
bot.setPresence({
|
|
|
|
name: "Test After Ready",
|
|
|
|
type: 'COMPETING'
|
|
|
|
})
|
2020-10-25 17:03:53 +00:00
|
|
|
})
|
2020-10-23 16:11:00 +00:00
|
|
|
|
2020-10-31 11:45:33 +00:00
|
|
|
bot.on('debug', console.log)
|
|
|
|
|
2020-11-02 12:08:38 +00:00
|
|
|
bot.on('messageCreate', async (msg: Message) => {
|
|
|
|
if (msg.author.bot) return
|
|
|
|
console.log(`${msg.author.tag} (${msg.channel + ""}): ${msg.content}`)
|
|
|
|
if (msg.content == "!ping") {
|
|
|
|
msg.reply("Pong! API Ping: " + bot.ping + "ms")
|
|
|
|
} else if (msg.content == "!members") {
|
|
|
|
let col = await msg.guild?.members.collection()
|
|
|
|
let data = col?.array().map((c, i) => {
|
|
|
|
return `${i + 1}. ${c.user.tag}`
|
|
|
|
}).join("\n")
|
|
|
|
msg.channel.send("Member List:\n" + data)
|
|
|
|
} else if (msg.content == "!guilds") {
|
|
|
|
let guilds = await msg.client.guilds.collection()
|
|
|
|
msg.channel.send("Guild List:\n" + guilds.array().map((c, i) => {
|
|
|
|
return `${i + 1}. ${c.name} - ${c.memberCount} members`
|
|
|
|
}).join("\n"))
|
|
|
|
} else if (msg.content == "!roles") {
|
|
|
|
let col = await msg.guild?.roles.collection()
|
|
|
|
let data = col?.array().map((c, i) => {
|
|
|
|
return `${i + 1}. ${c.name}`
|
|
|
|
}).join("\n")
|
|
|
|
msg.channel.send("Roles List:\n" + data)
|
|
|
|
} else if (msg.content == "!channels") {
|
|
|
|
let col = await msg.guild?.channels.array()
|
|
|
|
let data = col?.map((c, i) => {
|
|
|
|
return `${i + 1}. ${c.name}`
|
|
|
|
}).join("\n")
|
|
|
|
msg.channel.send("Channels List:\n" + data)
|
2020-10-25 17:03:53 +00:00
|
|
|
}
|
2020-10-25 06:50:32 +00:00
|
|
|
})
|
|
|
|
|
2020-10-25 17:03:53 +00:00
|
|
|
bot.connect(TOKEN, [
|
|
|
|
GatewayIntents.GUILD_MEMBERS,
|
|
|
|
GatewayIntents.GUILD_PRESENCES,
|
2020-10-30 14:51:40 +00:00
|
|
|
GatewayIntents.GUILD_MESSAGES,
|
|
|
|
GatewayIntents.DIRECT_MESSAGES,
|
|
|
|
GatewayIntents.DIRECT_MESSAGE_REACTIONS,
|
|
|
|
GatewayIntents.DIRECT_MESSAGE_TYPING,
|
|
|
|
GatewayIntents.GUILDS,
|
|
|
|
GatewayIntents.GUILD_BANS,
|
|
|
|
GatewayIntents.GUILD_EMOJIS,
|
|
|
|
GatewayIntents.GUILD_INTEGRATIONS,
|
|
|
|
GatewayIntents.GUILD_INVITES,
|
|
|
|
GatewayIntents.GUILD_MESSAGE_REACTIONS,
|
|
|
|
GatewayIntents.GUILD_MESSAGE_TYPING,
|
|
|
|
GatewayIntents.GUILD_VOICE_STATES,
|
|
|
|
GatewayIntents.GUILD_WEBHOOKS
|
2020-10-25 17:03:53 +00:00
|
|
|
])
|