fj-admin-bot/Sources/Bot.swift

42 lines
1 KiB
Swift
Raw Normal View History

2024-11-29 21:31:42 -05:00
import DDBKit
import DotEnv
import Foundation
2024-11-29 21:31:42 -05:00
@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!")
}
2024-11-29 21:31:42 -05:00
let httpClient = HTTPClient()
bot = await BotGatewayManager(
eventLoopGroup: httpClient.eventLoopGroup,
httpClient: httpClient,
token: ProcessInfo.processInfo.environment["BOT_TOKEN"]!,
2024-11-29 21:31:42 -05:00
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))
2024-11-29 21:31:42 -05:00
}
}
var bot: Bot
var cache: Cache
}