42 lines
No EOL
1 KiB
Swift
42 lines
No EOL
1 KiB
Swift
import DDBKit
|
|
import DotEnv
|
|
import Foundation
|
|
|
|
@main
|
|
|
|
struct FjAdminBot: DiscordBotApp {
|
|
init() async {
|
|
do {
|
|
let env = try DotEnv.read(path: "./.env")
|
|
env.load()
|
|
print("Loaded .env file")
|
|
} catch {
|
|
print("Failed to load .env file, things won't work!")
|
|
}
|
|
|
|
let httpClient = HTTPClient()
|
|
bot = await BotGatewayManager(
|
|
eventLoopGroup: httpClient.eventLoopGroup,
|
|
httpClient: httpClient,
|
|
token: ProcessInfo.processInfo.environment["BOT_TOKEN"]!,
|
|
largeThreshold: 250,
|
|
presence: .init(activities: [], status: .online, afk: false),
|
|
intents: [.messageContent, .guildMessages]
|
|
)
|
|
cache = await .init(
|
|
gatewayManager: bot,
|
|
intents: .all,
|
|
requestAllMembers: .enabledWithPresences,
|
|
messageCachingPolicy: .saveEditHistoryAndDeleted
|
|
)
|
|
}
|
|
|
|
var body: [any BotScene] {
|
|
ReadyEvent { ready in
|
|
print(String(format: "Logged on as %@#%@!", ready.user.username, ready.user.discriminator))
|
|
}
|
|
}
|
|
|
|
var bot: Bot
|
|
var cache: Cache
|
|
} |