Skip to content

Commit

Permalink
Merge pull request #1 from gretmn102/dev
Browse files Browse the repository at this point in the history
feat: add cooldown option to custom commands and make custom random probabilities
  • Loading branch information
gretmn102 authored Dec 24, 2023
2 parents 7bf9220 + e67e000 commit ab650cb
Show file tree
Hide file tree
Showing 54 changed files with 1,409 additions and 642 deletions.
39 changes: 16 additions & 23 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
strategy: min
storage: none
source https://api.nuget.org/v3/index.json

framework: netstandard2.0, netcoreapp3.1
nuget FSharp.Core
nuget DSharpPlus
nuget DSharpPlus.Rest
nuget FSharp.Core = 5.0.2
nuget DSharpPlus = 4.3
nuget DSharpPlus.Rest = 4.3
nuget Fuchu
nuget FParsec
nuget HtmlAgilityPack
nuget Newtonsoft.Json
nuget Newtonsoft.Json.Bson
nuget YamlDotNet
nuget TextCopy
nuget SixLabors.ImageSharp == 1.0.4
nuget SixLabors.Fonts == 1.0.0-beta15
nuget SixLabors.ImageSharp.Drawing == 1.0.0-beta13
nuget Svg
nuget MongoDB.Driver
nuget ably.io
nuget dotenv.net
nuget Saturn == 0.14.1
nuget Giraffe == 4.1
nuget Svg = 3.2.3
nuget MongoDB.Driver = 2.13.2
nuget ably.io = 1.2.8
nuget dotenv.net = 3.1.2

git https://github.com/gretmn102/rp-discord-bot.git

source https://gitlab.com/api/v4/projects/28574921/packages/nuget/index.json
storage: none
nuget FSharpMyExt
nuget DiscordBotExtensions
nuget FSharpMyExt prerelease
nuget DiscordBotExtensions = 0.10.0

group Build
strategy: min
source https://api.nuget.org/v3/index.json
framework: netstandard2.0
storage: none

nuget FSharp.Core
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Farmer
nuget FSharp.Core == 5.0.2
nuget Fake.Core.ReleaseNotes == 5.20.4
nuget Fake.Core.Target == 5.20.4
nuget Fake.DotNet.Cli == 5.20.4
nuget Fake.IO.FileSystem == 5.20.4
811 changes: 581 additions & 230 deletions paket.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Api.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Api
open Shared
open DiscordBotExtensions

module ApiProtocol =
open Newtonsoft.Json
Expand Down
18 changes: 9 additions & 9 deletions src/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open FsharpMyExtension.Either
open Microsoft.Extensions.Logging
open System.Threading.Tasks
open DSharpPlus

open Types
open Extensions
open DiscordBotExtensions
open DiscordBotExtensions.Types
open DiscordBotExtensions.Extensions

let botEventId = new EventId(42, "Bot-Event")

Expand All @@ -32,7 +32,7 @@ let initBotModules (db: MongoDB.Driver.IMongoDatabase) (logger: ILogger<_>) =
Calc.Main.create ()
Roll.Main.create ()
Age.Main.create "age" db
Characters.Main.create "characters" db
RpDiscordBot.Core.Characters.Main.create "characters" db
BallotBox.Main.create (fun setting client e -> AppsHub.start (AppsHub.Hub.InitBallotBox setting) client e)
NumberToWords.Main.create ()
EmojiManager.Main.create ()
Expand All @@ -42,15 +42,15 @@ let initBotModules (db: MongoDB.Driver.IMongoDatabase) (logger: ILogger<_>) =

open MongoDB.Driver
let initDb () =
let dbConnection = getEnvironmentVariable "DbConnection"
let dbConnection = EnvironmentExt.getEnvironmentVariable "DbConnection"

let settings =
MongoClientSettings.FromConnectionString (dbConnection)

let client = new MongoClient(settings)
let database =
let dataBaseName =
getEnvironmentVariable "DataBaseName"
EnvironmentExt.getEnvironmentVariable "DataBaseName"

client.GetDatabase(dataBaseName)

Expand All @@ -72,11 +72,11 @@ let main argv =
#else
"AblyToken"
#endif
getEnvironmentVariable serverConnectionVarName
EnvironmentExt.getEnvironmentVariable serverConnectionVarName

// Api.start ablyToken

match tryGetEnvironmentVariable tokenEnvVar with
match EnvironmentExt.tryGetEnvironmentVariable tokenEnvVar with
| None ->
printfn "Environment variable `%s` is not set!" tokenEnvVar
1
Expand Down Expand Up @@ -109,7 +109,7 @@ let main argv =
let prefix = "."

botModules
|> Shared.BotModule.bindToClientsEvents
|> BotModule.bindToClientsEvents
prefix
(fun client e ->
let b = DSharpPlus.Entities.DiscordEmbedBuilder()
Expand Down
9 changes: 5 additions & 4 deletions src/AppsHub.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module AppsHub

open Types
open DiscordBotExtensions
open DiscordBotExtensions.Types
open DiscordBotExtensions.DiscordMessage
open FsharpMyExtension
open FsharpMyExtension.Either

Expand All @@ -13,7 +14,7 @@ module Hub =

type AppAnswer =
| Answer of DSharpPlus.Entities.DiscordMessageBuilder
| BallotBoxAnswer of Types.ResultView
| BallotBoxAnswer of ResultView

type Err =
| HasNotStartedYet
Expand Down Expand Up @@ -355,7 +356,7 @@ module BotModule =
preturn (fun x -> f x msg)

let create () =
{ Shared.BotModule.empty with
{ BotModule.empty with
MessageCreateEventHandleExclude =
let exec: _ Parser.Parser =
Parser.start (fun (client: DiscordClient, e: EventArgs.MessageCreateEventArgs) msg ->
Expand Down
4 changes: 2 additions & 2 deletions src/MainProj.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\paket-files\github.com\gretmn102\rp-discord-bot\src\rp-discord-bot.fsproj">
<Name>rp-discord-bot.fsproj</Name>
<ProjectReference Include="..\paket-files\github.com\gretmn102\rp-discord-bot\src\Core\Core.fsproj">
<Name>Core.fsproj</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions src/Modules/Age/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ module Age.Main
open FsharpMyExtension
open FsharpMyExtension.Either
open DSharpPlus

open Shared
open Types
open Extensions
open DiscordBotExtensions
open DiscordBotExtensions.Extensions
open DiscordBotExtensions.Types

type Request =
| CreateForm
Expand Down
5 changes: 2 additions & 3 deletions src/Modules/Age/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ open FsharpMyExtension
open MongoDB.Driver
open MongoDB.Bson
open MongoDB.Bson.Serialization.Attributes

open Types
open Db
open DiscordBotExtensions.Types
open DiscordBotExtensions.Db

[<BsonIgnoreExtraElements>]
type DataPreVersion =
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/BallotBox/Core.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module BallotBox.Core
open FsharpMyExtension
open FsharpMyExtension.Either
open Types
open DiscordBotExtensions.Types

type ChoiceId = int
type Choice =
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/BallotBox/Main.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module BallotBox.Main
open DSharpPlus

open Shared
open Types
open DiscordBotExtensions
open DiscordBotExtensions.Types

type Request =
| BallotBox of description: string * choices: string list
Expand Down
8 changes: 4 additions & 4 deletions src/Modules/Boosters/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module Boosters.Main
open FsharpMyExtension
open FsharpMyExtension.Either
open DSharpPlus
open DiscordBotExtensions
open DiscordBotExtensions.Types
open DiscordBotExtensions.Extensions

open Shared
open Types
open Extensions
open Model

type Request =
Expand Down Expand Up @@ -43,7 +43,7 @@ let reduce (e: EventArgs.MessageCreateEventArgs) msg (state: Model.GuildSettings
match msg with
| SetSetting(channelId, messageTemplate) ->
let guild = e.Guild
let currentMember = getGuildMember guild e.Author
let currentMember = DiscordGuild.getMember e.Author guild
let replyMessage =
await (e.Channel.SendMessageAsync "Processing...")

Expand Down
5 changes: 2 additions & 3 deletions src/Modules/Boosters/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ open FsharpMyExtension
open MongoDB.Driver
open MongoDB.Bson
open MongoDB.Bson.Serialization.Attributes

open Types
open Db
open DiscordBotExtensions.Types
open DiscordBotExtensions.Db

[<BsonIgnoreExtraElements>]
type DataPreVersion =
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Calc/Main.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Calc.Main
open DSharpPlus

open Shared
open Types
open DiscordBotExtensions
open DiscordBotExtensions.Types

type Request = float

Expand Down
10 changes: 5 additions & 5 deletions src/Modules/ChatVoice/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module ChatVoice.Main
open FsharpMyExtension
open FsharpMyExtension.Either
open DSharpPlus
open DiscordBotExtensions
open DiscordBotExtensions.Types

open Shared
open Types
open Model

type Request =
Expand Down Expand Up @@ -57,7 +57,7 @@ let voiceHandle (e: DSharpPlus.EventArgs.VoiceStateUpdateEventArgs) =
printfn "voice channel <#%d> not found" beforeChatId
| channel ->
let guildMember =
getGuildMember e.Guild e.User
DiscordGuild.getMember e.User e.Guild

try
channel.AddOverwriteAsync(guildMember, deny=accessChannelsPermission)
Expand All @@ -82,7 +82,7 @@ let voiceHandle (e: DSharpPlus.EventArgs.VoiceStateUpdateEventArgs) =
printfn "voice channel <#%d> not found" beforeChatId
| channel ->
let guildMember =
getGuildMember e.Guild e.User
DiscordGuild.getMember e.User e.Guild

try
channel.AddOverwriteAsync(guildMember, allow=accessChannelsPermission)
Expand All @@ -95,7 +95,7 @@ let voiceHandle (e: DSharpPlus.EventArgs.VoiceStateUpdateEventArgs) =
let reduce (e: DSharpPlus.EventArgs.MessageCreateEventArgs) msg =
match msg with
| MentionInVoice ->
let guildMember = getGuildMember e.Guild e.Author
let guildMember = DiscordGuild.getMember e.Author e.Guild
let errorMessage =
"This command is available only if you are in the voice channel of this guild."
match guildMember.VoiceState with
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/ChatVoice/Model.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ChatVoice.Model
open Types
open DiscordBotExtensions.Types

type VoiceChannelId = ChannelId
type Settings = Map<GuildId, Map<VoiceChannelId, ChannelId>>
Loading

0 comments on commit ab650cb

Please sign in to comment.