# This is the main code for initializing the bot client and
# This is the code necessary for connecting to Discord.
# The binary's entry point is in Init.cr.
require"db"
require"discordcr"
require"dotenv"
require"logger"
require"sqlite3"
# Fix for modify_guild_role_positions until it's merged into their master
require"./DiscordCr"
# This makes the client and its cache globally available. It's ugly
# but shorter than writing Bampersand.client.not_nil!.whatever
macrobot!
Bampersand.client.not_nil!
end
macrocache!
Bampersand.cache.not_nil!
end
require"./DiscordCrAddenda"
require"./Util"
require"./State"
require"./Arguments"
require"./Perms"
require"./modules/Config"
require"./modules/Mirroring"
require"./modules/Board"
require"./modules/JoinLeaveLog"
@ -32,78 +17,58 @@ require "./modules/Killfile"
require"./modules/RoleKiosk"
require"./modules/Commands"
moduleBampersand
VERSION=`shards version`.chomp
PRESENCES=["your concerns","endless complaints","socialist teachings","the silence of the lambs","anarchist teachings","emo poetry","FREUDE SCHรNER GรTTERFUNKEN","the heat death of the universe","[ASMR] Richard Stallman tells you to use free software","the decline of western civilisation","4'33'' (Nightcore Remix)","General Protection Fault","breadtube","the book of origin"]
STARTUP=Time.monotonic
DATABASE=DB.open"sqlite3://./bampersand.sqlite3"
# Needs to be nilable as we don't want to connect to discord when running
# tests, so the client init is in a method which isn't guaranteed to run
@@bot:Discord::Client?
@@cache:Discord::Cache?
# Don't use these, but the bot! and cache! macros instead
presences=["your concerns","endless complaints","socialist teachings","the silence of the lambs","anarchist teachings","emo poetry","FREUDE SCHรNER GรTTERFUNKEN","the heat death of the universe","[ASMR] Richard Stallman tells you to use free software","the decline of western civilisation","4'33'' (Nightcore Remix)","General Protection Fault","breadtube","the book of origin"]
@ -26,9 +24,9 @@ Commands.register_command("help", "Lists commands. Pass a single argument to sea
end
Commands.register_command("about","Displays stats about Bampersand and links to further resources.",Perms::Level::User)do
uptime=Time.monotonic-Bampersand::STARTUP
uptime=Time.monotonic-STARTUP
{
title:"**BAMPERSAND VERSION #{Bampersand::VERSION}**",
text:"This is a simple utility bot for Discord powered by [Crystal](https://crystal-lang.org).\nYou can take a peek <:blobpeek:559732380697362482> at the [documentation](https://git.15318.de/Dingens/Bampersand/wiki/Home) and the [source code](https://git.15318.de/Dingens/Bampersand)!\nCurrently running on #{cache!.guilds.size} guilds, serving #{cache!.users.size} users.\nUptime is #{uptime.days}d #{uptime.hours}h #{uptime.minutes}m #{uptime.seconds}s. Bot operator is <@#{ENV["admin"]}>.",
title:"**BAMPERSAND VERSION #{VERSION}**",
text:"This is a simple utility bot for Discord powered by [Crystal](https://crystal-lang.org).\nYou can take a peek <:blobpeek:559732380697362482> at the [documentation](https://git.15318.de/Dingens/Bampersand/wiki/Home) and the [source code](https://git.15318.de/Dingens/Bampersand)!\nCurrently running on #{CACHE.guilds.size} guilds, serving #{CACHE.users.size} users.\nUptime is #{uptime.days}d #{uptime.hours}h #{uptime.minutes}m #{uptime.seconds}s. Bot operator is <@#{ENV["admin"]}>.",
next"Ffs\nDon't do that again <@#{ctx.issuer.id}>. Look at my flair\nI only need 0.001% of my power to wipe you out"unlessPerms.check(ctx.guild_id,ctx.issuer.id,Perms::Level::Operator)
"Your message in <##{msg.channel_id}> has been removed due to slowmode enforcement. Here's the text in case you want to post in at least #{timeout.total_milliseconds/1000} seconds:",
# Posting it as embed circumvents the 2000 char limit.