Compare commits
130 commits
Author | SHA1 | Date | |
---|---|---|---|
ff46c4eab6 | |||
df6012bb86 | |||
3f6468f374 | |||
e0ff50b5cd | |||
276d311ff7 | |||
0aff208cf0 | |||
11141df435 | |||
525273bad6 | |||
3032aaa5b0 | |||
cbb9f8d1ac | |||
0e41cb7cc2 | |||
ffe4e64387 | |||
427a011590 | |||
682ecb6f08 | |||
ced58d17c3 | |||
d171b92989 | |||
172b1ed5e6 | |||
8f6ecff5af | |||
94aee4ad10 | |||
d910683d78 | |||
8ed26e11d3 | |||
d682909bab | |||
015724a150 | |||
7f36481987 | |||
16c64762b7 | |||
d8aa040f75 | |||
37522cf65c | |||
ea06e9f217 | |||
68e736ceb8 | |||
d3c90ab59f | |||
9aa567b276 | |||
026e5a151e | |||
4a19d91a4f | |||
53af8f940d | |||
6891869046 | |||
aba5c4fbfd | |||
7d8f61ecea | |||
524c97d9bf | |||
c058d180ae | |||
57a5993064 | |||
aa06f62258 | |||
07df2ed450 | |||
aaf8522987 | |||
d414ecda2d | |||
99a8030898 | |||
28f21bae12 | |||
177257da12 | |||
051daebada | |||
d96039d20c | |||
0a1797700c | |||
e4afa1e385 | |||
69f45cd592 | |||
ea1c8c56e3 | |||
4c2b42ab7f | |||
97fe14cf5a | |||
b1d28296f0 | |||
9fe75d930f | |||
69a02e0e15 | |||
8d08595a9f | |||
1cbaaed944 | |||
a583c7d763 | |||
7246c982df | |||
d26efb3c8c | |||
16025b74e3 | |||
55e3a80405 | |||
4d3bdc2481 | |||
a1bf03ad40 | |||
2d3c7de8e7 | |||
9044a04c87 | |||
b3d2785cec | |||
2f740e96b8 | |||
ae8a63eeac | |||
4549b1f4e4 | |||
9b8d00d184 | |||
4a5bcd46e6 | |||
2eb973ccd3 | |||
c522abe856 | |||
3a8c811798 | |||
339237b351 | |||
91d464b041 | |||
4ec6396c87 | |||
605073d6ec | |||
d7ec044340 | |||
5b9cd88848 | |||
eb808d00e5 | |||
b033b062a5 | |||
d9d35420c9 | |||
134e5a8c92 | |||
c179ea6c07 | |||
98fddbd9b1 | |||
df1f1ed3a9 | |||
1d667db598 | |||
8025b9f9fe | |||
ca46786c5e | |||
83701a9e0b | |||
6d08ddee7d | |||
62a01d3d06 | |||
77628be826 | |||
7b4d4b1f8c | |||
c8ea928de7 | |||
d77fa7a115 | |||
d5eb3b57a0 | |||
fbb9064434 | |||
e77f85edc6 | |||
0a57edfcb3 | |||
73db4e59c2 | |||
b9b53ef3e8 | |||
988d8c0250 | |||
082cf79736 | |||
612c230b7b | |||
775d77e94e | |||
f2820c980e | |||
947b3794e9 | |||
ba1f5afa01 | |||
8fa6b0c999 | |||
1cd02222b9 | |||
9af44d2220 | |||
cce4795f9b | |||
35d5b068be | |||
c0d2fb297e | |||
32d27a7ddb | |||
265aac01f1 | |||
168b9c0224 | |||
2b581473c8 | |||
fb658b8189 | |||
d5d3801e1a | |||
54f7a36c5b | |||
2efa3c5347 | |||
ad472fd52e | |||
37986ed0b2 |
264 changed files with 24733 additions and 15852 deletions
.editorconfigmkdocs-requirements.txtmkdocs.yml
.github/workflows
.gitignoreCHANGELOG.mdREADME.mddocs
md
assets
elliehub-1.pngelliehub-2.pngelliehub-3.pngelliehub-4.pngelliehub-5.pngelliehub-6.pngfavicon.pngpatreon.pngpaypal.png
creds-guide.mddonate.mdguides
index.mdmarmalade
snippets
src
Ellie.Marmalade
EllieBot.GrpcApiBase
EllieBot.VotesApi
Common
Controllers
DockerfileEllieBot.VotesApi.csprojProgram.csProtos
Services
Startup.csappsettings.jsonEllieBot
Db
EllieBot.csprojEllieBot.csproj.DotSettingsMigrations
PostgreSql
20250228044209_init.Designer.cs20250310101121_userroles.sql20250310143026_club-banners.sql20250315193825_fs-prettyname.sql20250315225518_prot-delete-gcid.sql20250317063129_scheduled-commands.sql20250318221943_xpexclusion.sql20250319010757_livechannels.sql20250323021916_linkfixer.sql20250324230804_quests.sql20250327001838_fishitems.sql20250327001912_init.Designer.cs20250327001912_init.csPostgreSqlContextModelSnapshot.cs
Sqlite
20250126062816_cleanup.sql20250228044206_init.Designer.cs20250310101118_userroles.sql20250310143023_club-banners.sql20250315193822_fs-prettyname.sql20250315225515_prot-delete-gcid.sql20250317063119_scheduled-commands.sql20250318221922_xpexclusion.sql20250319010745_livechannels.sql20250323021857_linkfixer.sql20250324230801_quests.sql20250327001835_fishitems.sql20250327001909_init.Designer.cs20250327001909_init.csSqliteContextModelSnapshot.cs
Modules/Administration
208
.editorconfig
Normal file
208
.editorconfig
Normal file
|
@ -0,0 +1,208 @@
|
|||
|
||||
[*]
|
||||
charset = utf-8-bom
|
||||
end_of_line = crlf
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Microsoft .NET properties
|
||||
csharp_new_line_before_members_in_object_initializers = false
|
||||
csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
|
||||
csharp_style_prefer_utf8_string_literals = true:suggestion
|
||||
csharp_style_var_elsewhere = true:suggestion
|
||||
csharp_style_var_for_built_in_types = true:suggestion
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
dotnet_naming_rule.constants_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.constants_rule.resharper_description = Constant fields (not private)
|
||||
dotnet_naming_rule.constants_rule.resharper_guid = 669e5282-fb4b-4e90-91e7-07d269d04b60
|
||||
dotnet_naming_rule.constants_rule.severity = suggestion
|
||||
dotnet_naming_rule.constants_rule.style = all_upper_style
|
||||
dotnet_naming_rule.constants_rule.symbols = constants_symbols
|
||||
dotnet_naming_rule.interfaces_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.interfaces_rule.resharper_description = Interfaces
|
||||
dotnet_naming_rule.interfaces_rule.resharper_guid = a7a3339e-4e89-4319-9735-a9dc4cb74cc7
|
||||
dotnet_naming_rule.interfaces_rule.severity = suggestion
|
||||
dotnet_naming_rule.interfaces_rule.style = i_upper_camel_case_style
|
||||
dotnet_naming_rule.interfaces_rule.symbols = interfaces_symbols
|
||||
dotnet_naming_rule.local_constants_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.local_constants_rule.resharper_description = Local constants
|
||||
dotnet_naming_rule.local_constants_rule.resharper_guid = a4f433b8-abcd-4e55-a08f-82e78cef0f0c
|
||||
dotnet_naming_rule.local_constants_rule.severity = suggestion
|
||||
dotnet_naming_rule.local_constants_rule.style = all_upper_style
|
||||
dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols
|
||||
dotnet_naming_rule.private_constants_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.private_constants_rule.resharper_description = Constant fields (private)
|
||||
dotnet_naming_rule.private_constants_rule.resharper_guid = 236f7aa5-7b06-43ca-bf2a-9b31bfcff09a
|
||||
dotnet_naming_rule.private_constants_rule.severity = suggestion
|
||||
dotnet_naming_rule.private_constants_rule.style = all_upper_style
|
||||
dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols
|
||||
dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.private_instance_fields_rule.resharper_description = Instance fields (private)
|
||||
dotnet_naming_rule.private_instance_fields_rule.resharper_guid = 4a98fdf6-7d98-4f5a-afeb-ea44ad98c70c
|
||||
dotnet_naming_rule.private_instance_fields_rule.severity = suggestion
|
||||
dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style
|
||||
dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols
|
||||
dotnet_naming_rule.private_static_fields_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.private_static_fields_rule.resharper_description = Static fields (private)
|
||||
dotnet_naming_rule.private_static_fields_rule.resharper_exclusive_prefixes_suffixes = true
|
||||
dotnet_naming_rule.private_static_fields_rule.resharper_guid = f9fce829-e6f4-4cb2-80f1-5497c44f51df
|
||||
dotnet_naming_rule.private_static_fields_rule.severity = suggestion
|
||||
dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style
|
||||
dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols
|
||||
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.private_static_readonly_rule.resharper_description = Static readonly fields (private)
|
||||
dotnet_naming_rule.private_static_readonly_rule.resharper_guid = 15b5b1f1-457c-4ca6-b278-5615aedc07d3
|
||||
dotnet_naming_rule.private_static_readonly_rule.severity = suggestion
|
||||
dotnet_naming_rule.private_static_readonly_rule.style = lower_camel_case_style
|
||||
dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols
|
||||
dotnet_naming_rule.type_parameters_rule.import_to_resharper = True
|
||||
dotnet_naming_rule.type_parameters_rule.resharper_description = Type parameters
|
||||
dotnet_naming_rule.type_parameters_rule.resharper_guid = 2c62818f-621b-4425-adc9-78611099bfcb
|
||||
dotnet_naming_rule.type_parameters_rule.severity = suggestion
|
||||
dotnet_naming_rule.type_parameters_rule.style = t_upper_camel_case_style
|
||||
dotnet_naming_rule.type_parameters_rule.symbols = type_parameters_symbols
|
||||
dotnet_naming_style.all_upper_style.capitalization = all_upper
|
||||
dotnet_naming_style.all_upper_style.word_separator = _
|
||||
dotnet_naming_style.i_upper_camel_case_style.capitalization = pascal_case
|
||||
dotnet_naming_style.i_upper_camel_case_style.required_prefix = I
|
||||
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
|
||||
dotnet_naming_style.lower_camel_case_style.required_prefix = _
|
||||
dotnet_naming_style.t_upper_camel_case_style.capitalization = pascal_case
|
||||
dotnet_naming_style.t_upper_camel_case_style.required_prefix = T
|
||||
dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
|
||||
dotnet_naming_symbols.constants_symbols.applicable_kinds = field
|
||||
dotnet_naming_symbols.constants_symbols.required_modifiers = const
|
||||
dotnet_naming_symbols.constants_symbols.resharper_applicable_kinds = constant_field
|
||||
dotnet_naming_symbols.constants_symbols.resharper_required_modifiers = any
|
||||
dotnet_naming_symbols.interfaces_symbols.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.interfaces_symbols.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interfaces_symbols.resharper_applicable_kinds = interface
|
||||
dotnet_naming_symbols.interfaces_symbols.resharper_required_modifiers = any
|
||||
dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local
|
||||
dotnet_naming_symbols.local_constants_symbols.required_modifiers = const
|
||||
dotnet_naming_symbols.local_constants_symbols.resharper_applicable_kinds = local_constant
|
||||
dotnet_naming_symbols.local_constants_symbols.resharper_required_modifiers = any
|
||||
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_constants_symbols.required_modifiers = const
|
||||
dotnet_naming_symbols.private_constants_symbols.resharper_applicable_kinds = constant_field
|
||||
dotnet_naming_symbols.private_constants_symbols.resharper_required_modifiers = any
|
||||
dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_instance_fields_symbols.resharper_applicable_kinds = field,readonly_field
|
||||
dotnet_naming_symbols.private_instance_fields_symbols.resharper_required_modifiers = instance
|
||||
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
|
||||
dotnet_naming_symbols.private_static_fields_symbols.resharper_applicable_kinds = field
|
||||
dotnet_naming_symbols.private_static_fields_symbols.resharper_required_modifiers = static
|
||||
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = readonly,static
|
||||
dotnet_naming_symbols.private_static_readonly_symbols.resharper_applicable_kinds = readonly_field
|
||||
dotnet_naming_symbols.private_static_readonly_symbols.resharper_required_modifiers = static
|
||||
dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
|
||||
dotnet_naming_symbols.type_parameters_symbols.resharper_applicable_kinds = type_parameter
|
||||
dotnet_naming_symbols.type_parameters_symbols.resharper_required_modifiers = any
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
|
||||
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
dotnet_style_qualification_for_event = false:suggestion
|
||||
dotnet_style_qualification_for_field = false:suggestion
|
||||
dotnet_style_qualification_for_method = false:suggestion
|
||||
dotnet_style_qualification_for_property = false:suggestion
|
||||
|
||||
# ReSharper properties
|
||||
resharper_autodetect_indent_settings = true
|
||||
resharper_csharp_wrap_arguments_style = chop_if_long
|
||||
resharper_force_attribute_style = join
|
||||
resharper_formatter_off_tag = @formatter:off
|
||||
resharper_formatter_on_tag = @formatter:on
|
||||
resharper_formatter_tags_enabled = true
|
||||
resharper_keep_existing_embedded_arrangement = false
|
||||
resharper_keep_existing_expr_member_arrangement = false
|
||||
resharper_method_or_operator_body = expression_body
|
||||
resharper_object_creation_when_type_not_evident = target_typed
|
||||
resharper_place_accessorholder_attribute_on_same_line = false
|
||||
resharper_place_accessor_attribute_on_same_line = false
|
||||
resharper_place_expr_method_on_single_line = false
|
||||
resharper_place_expr_property_on_single_line = false
|
||||
resharper_place_field_attribute_on_same_line = false
|
||||
resharper_place_simple_embedded_statement_on_same_line = false
|
||||
resharper_show_autodetect_configure_formatting_tip = false
|
||||
resharper_use_indent_from_vs = false
|
||||
resharper_wrap_before_arrow_with_expressions = true
|
||||
|
||||
# ReSharper inspection severities
|
||||
resharper_arrange_constructor_or_destructor_body_highlighting = hint
|
||||
resharper_arrange_method_or_operator_body_highlighting = suggestion
|
||||
resharper_arrange_object_creation_when_type_evident_highlighting = none
|
||||
resharper_arrange_redundant_parentheses_highlighting = suggestion
|
||||
resharper_arrange_this_qualifier_highlighting = hint
|
||||
resharper_arrange_type_member_modifiers_highlighting = none
|
||||
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
|
||||
resharper_built_in_type_reference_style_highlighting = hint
|
||||
resharper_check_namespace_highlighting = none
|
||||
resharper_class_never_instantiated_global_highlighting = hint
|
||||
resharper_convert_to_primary_constructor_highlighting = none
|
||||
resharper_convert_to_using_declaration_highlighting = warning
|
||||
resharper_convert_type_check_pattern_to_null_check_highlighting = hint
|
||||
resharper_empty_general_catch_clause_highlighting = none
|
||||
resharper_function_never_returns_highlighting = suggestion
|
||||
resharper_inconsistent_naming_highlighting = suggestion
|
||||
resharper_invert_if_highlighting = none
|
||||
resharper_lambda_expression_can_be_made_static_highlighting = hint
|
||||
resharper_mvc_action_not_resolved_highlighting = warning
|
||||
resharper_mvc_area_not_resolved_highlighting = warning
|
||||
resharper_mvc_controller_not_resolved_highlighting = warning
|
||||
resharper_mvc_masterpage_not_resolved_highlighting = warning
|
||||
resharper_mvc_partial_view_not_resolved_highlighting = warning
|
||||
resharper_mvc_template_not_resolved_highlighting = warning
|
||||
resharper_mvc_view_component_not_resolved_highlighting = warning
|
||||
resharper_mvc_view_component_view_not_resolved_highlighting = warning
|
||||
resharper_mvc_view_not_resolved_highlighting = warning
|
||||
resharper_non_readonly_member_in_get_hash_code_highlighting = suggestion
|
||||
resharper_not_accessed_field_local_highlighting = suggestion
|
||||
resharper_out_parameter_value_is_always_discarded_local_highlighting = suggestion
|
||||
resharper_private_field_can_be_converted_to_local_variable_highlighting = suggestion
|
||||
resharper_razor_assembly_not_resolved_highlighting = warning
|
||||
resharper_redundant_anonymous_type_property_name_highlighting = suggestion
|
||||
resharper_redundant_base_qualifier_highlighting = warning
|
||||
resharper_redundant_pattern_parentheses_highlighting = none
|
||||
resharper_redundant_record_class_keyword_highlighting = suggestion
|
||||
resharper_replace_with_single_call_to_first_or_default_highlighting = hint
|
||||
resharper_suggest_var_or_type_built_in_types_highlighting = hint
|
||||
resharper_suggest_var_or_type_elsewhere_highlighting = hint
|
||||
resharper_suggest_var_or_type_simple_types_highlighting = hint
|
||||
resharper_unused_method_return_value_local_highlighting = suggestion
|
||||
resharper_use_await_using_highlighting = warning
|
||||
resharper_web_config_module_not_resolved_highlighting = warning
|
||||
resharper_web_config_type_not_resolved_highlighting = warning
|
||||
resharper_web_config_wrong_module_highlighting = warning
|
||||
|
||||
[{*.har,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[{*.bash,*.sh,*.zsh}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.proto]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.{appxmanifest,asax,ascx,aspx,axaml,blockshader,build,cg,cginc,compute,cs,cshtml,dtd,fx,fxh,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,shaderFoundry,skin,urtshader,usf,ush,vb,xaml,xamlx,xoml,xsd}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
tab_width = 4
|
36
.github/workflows/mkdocs-deploy.yml
vendored
Normal file
36
.github/workflows/mkdocs-deploy.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
name: Deploy EllieBot Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["v6"]
|
||||
paths:
|
||||
- 'docs/**'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
cache: 'pip'
|
||||
cache-dependency-path: 'docs/mkdocs-requirements.txt'
|
||||
|
||||
- name: Install project dependencies
|
||||
run: pip install -r docs/mkdocs-requirements.txt
|
||||
|
||||
- name: Build the site with MkDocs
|
||||
working-directory: ./docs
|
||||
run: mkdocs build --strict
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
working-directory: ./docs
|
||||
run: mkdocs gh-deploy --force
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -371,4 +371,9 @@ site/
|
|||
|
||||
.aider.*
|
||||
PROMPT.md
|
||||
.aider*
|
||||
.*rules
|
||||
|
||||
## Python pip/env files
|
||||
Pipfile
|
||||
Pipfile.lock
|
||||
.venv
|
243
CHANGELOG.md
243
CHANGELOG.md
|
@ -1,6 +1,247 @@
|
|||
# Changelog
|
||||
|
||||
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o
|
||||
*a,c,f,r,o*
|
||||
|
||||
## [6.1.5] - 07.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.xpadd` will finally apply rewards and trigger notifications
|
||||
- Fixed `.hangman` dislocation
|
||||
|
||||
## [6.1.4] - 05.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed .timely awarding multiple times
|
||||
- Fixed .plant password - moved it down and right to avoid cutoff on phones
|
||||
|
||||
## [6.1.3] - 05.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bot will no longer fail to startup if ownerids are wrong
|
||||
|
||||
## [6.1.2] - 03.04.2025
|
||||
|
||||
### Fixed
|
||||
- Fixed `.feed` not adding new feeds to the database
|
||||
|
||||
## [6.1.1] - 03.04.2025
|
||||
|
||||
### Added
|
||||
- Added some config options for .conf fish
|
||||
|
||||
### Fixed
|
||||
- Fixed a typo in fish shop
|
||||
- .fishlb will now compare unique fish caught, instead of total catches
|
||||
- hangman category now appears in .hangman output
|
||||
|
||||
## [6.1.0] - 30.03.2025
|
||||
|
||||
### Added
|
||||
- Added Quest System!
|
||||
- Each user gets a couple of daily quests to complete
|
||||
- There are 10-15 different quests, each day you'll get 3
|
||||
- Upon completion of all dailies, the user will get a boost to timely and vote
|
||||
- `.quests` to see your quests
|
||||
- Added Fishing Items!
|
||||
- `.fishop` to see a list of all available items for sale
|
||||
- `.fibuy` to buy an item
|
||||
- `.finv` to see your inventory
|
||||
- `.fiuse` to use an item. You can equip one of each item, except potions
|
||||
- You can equip one of each item
|
||||
- You can equip any number of potions, but they have limited duration and cant be unequiped
|
||||
- `.fili` will show your equipped item names, nad `.fish` will show bonuses
|
||||
- Added `.fishlb` to see the top anglers
|
||||
- Added `.notify <channel> nicecatch <message>` event
|
||||
- It will show all rare fish/trash and all max star fish caught on any server
|
||||
- You can use `.notifyphs nicecatch` to see the list of placeholders you can use while setting a message
|
||||
- Example: `.notify #fishfeed nicecatch %user% just caught a %event.fish.stars% %event.fish.name% %event.fish.emoji%`
|
||||
- Added prices to `.nczoom`
|
||||
- Voting re-added, `.votefeed` to see all votes. Non-trivial setup required, check commits
|
||||
- owner only `.massping` command for special situations
|
||||
|
||||
### Changed
|
||||
- .notify commands now require Manage Messages permission
|
||||
- .notify will now let you know if you can't set a notify message due to a missing channel
|
||||
- `.say` will no longer reply
|
||||
- `.vote` and `.timely` will now show active bonuses
|
||||
- `.lcha` (live channel) limit increased to 5
|
||||
- `.nc` will now show instructions
|
||||
|
||||
### Fixed
|
||||
- Fixed `.antispamignore` restart persistence
|
||||
- Fixed `.notify` events. Only levelup used to work
|
||||
- Fixed `.hangman` misalignment
|
||||
- Fixed bank quest
|
||||
|
||||
## [6.0.13] - 23.03.2025
|
||||
|
||||
### Added
|
||||
- Added `.linkfix <old> <new>` command
|
||||
- If bot sees a message with the old link, it will reply to the message with a fixed (new) link
|
||||
- ex: `.linkfix twitter.com vxtwitter.com`
|
||||
- Added `.roleicon role <icon_url / server_emoji>` command to set the icon of a role
|
||||
- Added a captcha option for `.fish`
|
||||
|
||||
### Fixed
|
||||
- Fixed youtube stream notifications in case invalid channel was provided
|
||||
- `.lcha` (live channel) will now let you override an existing channel template even if you're at the limit
|
||||
- Fixed `.shop` commands
|
||||
|
||||
### Removed
|
||||
- removed `.xpglb` as it is no longer used
|
||||
|
||||
## [6.0.12] - 20.03.2025
|
||||
|
||||
### Fixed
|
||||
- `.antispamignore` fixed for the last time hopefully
|
||||
- protection commands are some of the oldest commands, and they might get overhauled in future updates
|
||||
- please report if you find any other weird issue with them
|
||||
|
||||
## [6.0.11] - 20.03.2025
|
||||
|
||||
### Changed
|
||||
- wordfilter, invitefilter and linkfilter will now properly detect forwarded messages, as forwards were used to circumvent filtering.
|
||||
|
||||
### Fixed
|
||||
- `.dmc` fixed
|
||||
- Fixed .streamremove - now showing proper youtube name when removing instead of channel id
|
||||
|
||||
## [6.0.10] - 20.03.2025
|
||||
|
||||
### Changed
|
||||
|
||||
- Live channels `.lcha` is limited to 1 for now. It will be reverted back to 5 in a couple of days at most as some things need to be implemented.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.antispam` won't break if you have thread channels in the server anymore
|
||||
- `.ve` now works properly
|
||||
- selfhosters: `.yml` parsing errors will now tell you which .yml file is causing the issue and why.
|
||||
|
||||
## [6.0.9] - 19.03.2025
|
||||
|
||||
### Changed
|
||||
|
||||
- `.cinfo` now also has a member list
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.antispamignore` will now properly persist through restarts
|
||||
- livechannels and scheduled commands will now be inside utility module as they should
|
||||
|
||||
## [6.0.8] - 19.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Live channel commands
|
||||
- `.lcha` adds a channel with a template message (supports placeholders, and works on category channels too!)
|
||||
- Every 10 minutes, channel name will be updated
|
||||
- example: `.lcha #my-channel --> Members: %server.members% <--` will display the number of members in the server as a channel name, updating once every 10 minutes
|
||||
- `.lchl` lists all live channels (Up to 5)
|
||||
- `.lchd <channel or channelId>` removed a live channel
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.antispamignore` fixed
|
||||
|
||||
## [6.0.7] - 19.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Schedule commands!
|
||||
- `.scha <time> <text>` adds the command to be excuted after the specified amount of time
|
||||
- `.schd <id>` deletes the command with the specified id
|
||||
- `.schl` lists your scheduled commands
|
||||
- `.masskick` added as massban and masskill already exist
|
||||
- `.xpex` and `.xpexl` are back, as there was no way to exclude specific users or roles with .xprate
|
||||
|
||||
### Fix
|
||||
|
||||
- `.xprate` will now (as exclusion did) respect parent channel xp rates in threads
|
||||
- the xprate system will first check if a thread channel has a rate set
|
||||
- if it doesn't it will try to use the parent channel's rate
|
||||
|
||||
## [6.0.6] - 16.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Added youtube live stream notification support for `.streamadd`
|
||||
- it only works by using an invidious instance (with a working api) from data/searches.yml
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.hangman` not receiving input sometimes
|
||||
- Fixed `.sfl` and similar toggles not working
|
||||
- Fixed `.antialt` and other protection commands not properly turning on
|
||||
- Fixed `%bot.time%` and `%bot.date%` placeholders showing wrong date.
|
||||
- No longer a timestamp
|
||||
|
||||
## [6.0.5] - 15.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Aded a title in `.whosplaying`
|
||||
- Added a crown emoji next to commands if -v 1 or -v2 option is specified
|
||||
|
||||
### Changed
|
||||
|
||||
- `.remind` looks better
|
||||
- `.savechat` no longer owner only, up to 1000 messages - unlimited if ran by the bot owner
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.ropl` fixed
|
||||
|
||||
## [6.0.4] - 14.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- `.xp` system reworked
|
||||
- Global XP has been removed in favor of server XP
|
||||
- You can now set `.xprate` for each channel in your server!
|
||||
- You can set voice, image, and text rates
|
||||
- Use `.xpratereset` to reset it back to default
|
||||
- This feature makes `.xpexclude` obsolete
|
||||
- Requirement to create a club removed
|
||||
- `.xp` card should generate faster
|
||||
- Fixed countless possible issues with xp where some users didn't gain xp, or froze, etc
|
||||
- user-role commands added!
|
||||
- `.ura <user> <role>` - assign a role to a user
|
||||
- `.url <user?>` - list assigned roles for all users or a specific user
|
||||
- `.urm` - show 'my' (your) assigned roles
|
||||
- `.urn <role> <new_name>` - set a name for your role
|
||||
- `.urc <role> <hex_color>` - set a color for your role
|
||||
- `.uri <role> <url/server_emoji>` - set an icon for your role (accepts either a server emoji or a link to an image)
|
||||
- `.notify` improved
|
||||
- Lets you specify source channel (for some events) as the message output
|
||||
- `.pload <id> --shuffle` lets you load a saved playlist in random order
|
||||
- `.lyrics <song_name>` added - find lyrics for a song (it's not always accurate)
|
||||
|
||||
- For Selfhosters
|
||||
- you have to update to latest v5 before updating to v6, otherwise migrations will fail
|
||||
- migration system was reworked
|
||||
- Xp card is now 500x245
|
||||
- xp_template.json backed up to old_xp_template.json
|
||||
- check pinned message in #dev channel to see full selfhoster announcement
|
||||
- Get bot version via --version
|
||||
|
||||
### Changed
|
||||
|
||||
- `.lopl` will queue subdirectories too now
|
||||
- Some music playlist commands have been renamed to fit with other commands
|
||||
- Removed gold/silver frames from xp card
|
||||
- `.inrole` is now showing users in alphabetical order
|
||||
- `.curtrs` are now paginated
|
||||
- pagination now lasts for 10+ minutes
|
||||
- selfhosters: Restart command default now assumes binary installation
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed several fonts
|
||||
- Xp Exclusion commands (superseded by `.xprate`)
|
||||
|
||||
## [5.3.9] - 31.01.2025
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# EllieBot
|
||||
|
||||
[](https://nogithub.codeberg.page)
|
||||
[](https://nogithub.codeberg.page) 
|
||||
|
||||
## Guides
|
||||
|
||||
For hosting guides go https://docs.elliebot.net/ellie/
|
||||
For hosting guides go https://docs.elliebot.net/
|
||||
|
||||
## Support
|
||||
|
||||
|
|
BIN
docs/md/assets/elliehub-1.png
Normal file
BIN
docs/md/assets/elliehub-1.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 52 KiB |
BIN
docs/md/assets/elliehub-2.png
Normal file
BIN
docs/md/assets/elliehub-2.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 58 KiB |
BIN
docs/md/assets/elliehub-3.png
Normal file
BIN
docs/md/assets/elliehub-3.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 56 KiB |
BIN
docs/md/assets/elliehub-4.png
Normal file
BIN
docs/md/assets/elliehub-4.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 15 KiB |
BIN
docs/md/assets/elliehub-5.png
Normal file
BIN
docs/md/assets/elliehub-5.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.2 KiB |
BIN
docs/md/assets/elliehub-6.png
Normal file
BIN
docs/md/assets/elliehub-6.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1,014 B |
BIN
docs/md/assets/favicon.png
Normal file
BIN
docs/md/assets/favicon.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 273 KiB |
BIN
docs/md/assets/patreon.png
Normal file
BIN
docs/md/assets/patreon.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 28 KiB |
BIN
docs/md/assets/paypal.png
Normal file
BIN
docs/md/assets/paypal.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 27 KiB |
32
docs/md/creds-guide.md
Normal file
32
docs/md/creds-guide.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
## Creating your own Discord bot
|
||||
|
||||
This guide will show you how to create your own discord bot, invite it to your server, and obtain the credentials needed to run it.
|
||||
|
||||
1. Go to [the Discord developer application page][Discord].
|
||||
2. Log in with your Discord account.
|
||||
3. Click **New Application**.
|
||||
4. Fill out the `Name` field however you like, accept the terms, and confirm.
|
||||
5. Go to the **Bot** tab on the left sidebar.
|
||||
6. Click on the `Add a Bot` button and confirm that you do want to add a bot to this app.
|
||||
7. **Optional:** Add bot's avatar and description.
|
||||
8. Copy your Token to `creds.yml` as shown above.
|
||||
9. Scroll down to the **`Privileged Gateway Intents`** section
|
||||
- You MUST enable the following:
|
||||
- **PRESENCE INTENT**
|
||||
- **SERVER MEMBERS INTENT**
|
||||
- **MESSAGE CONTENT INTENT**
|
||||
|
||||
### Inviting your bot to your server
|
||||
|
||||

|
||||
|
||||
- On the **General Information** tab, copy your `Application ID` from your [applications page][Discord].
|
||||
- Replace the `YOUR_CLIENT_ID_HERE` in this link:
|
||||
`https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=66186303` with your `Client ID`
|
||||
- The link should now look something like this:
|
||||
`https://discord.com/oauth2/authorize?client_id=123123123123&scope=bot&permissions=66186303`
|
||||
- Access that newly created link, pick your Discord server, click `Authorize` and confirm with the captcha at the end
|
||||
- The bot should now be in your server
|
||||
|
||||
|
||||
[Discord]: https://discord.com/developers/applications/me
|
37
docs/md/donate.md
Normal file
37
docs/md/donate.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Donate
|
||||
|
||||
Ellie is an [open-source project][toastielab], and we rely on your help to develop the bot, pay hosting fees, maintain our website and more.
|
||||
Donations go a long way in helping us keep the project alive, and we appreciate every single one of them.
|
||||
|
||||
## Perks
|
||||
|
||||
Donating to us also gives you the following benefits:
|
||||
|
||||
- A hoisted **Patron** role in [Ellie Discord server][discord-server]
|
||||
- Access to exclusive **#donator-general** text and voice channels
|
||||
- **3000 candy** on the public bot per dollar donated (after fees)
|
||||
|
||||
## Patreon
|
||||
|
||||
You can set up a monthly pledge on [Patreon][patreon] and support the project's growth, and also get candy rewards for every month you donate!
|
||||
|
||||
!!! Note
|
||||
Connect your Discord account on Patreon to receive your candy automatically
|
||||
|
||||
[![img][patreon-button]][patreon]
|
||||
|
||||
## PayPal
|
||||
|
||||
You can also donate to us through [PayPal][paypal] for one-time donations using the button below, or by donating to `toastie@dragonschildstudios.com`.
|
||||
|
||||
!!! Note
|
||||
Mention your Discord username or user id in the payment note to receive candy rewards.
|
||||
|
||||
[![img][paypal-button]][paypal]
|
||||
|
||||
[toastielab]: https://toastielab.dev/EllieBotDevs/elliebot
|
||||
[discord-server]: https://discord.nadeko.bot/
|
||||
[patreon]: https://www.patreon.com/elliebot
|
||||
[patreon-button]: ./assets/patreon.png
|
||||
[paypal]: https://paypal.me/toastie_t0ast
|
||||
[paypal-button]: ./assets/paypal.png
|
235
docs/md/guides/cli-guide.md
Normal file
235
docs/md/guides/cli-guide.md
Normal file
|
@ -0,0 +1,235 @@
|
|||
# EllieBot CLI Guide (via Bash Installer)
|
||||
|
||||
### Supported Operating Systems
|
||||
|
||||
--8<-- "md/snippets/supported-platforms.md:linux"
|
||||
--8<-- "md/snippets/supported-platforms.md:macos"
|
||||
|
||||
### Prerequisites
|
||||
|
||||
macOS:
|
||||
|
||||
- [Homebrew](https://brew.sh/)
|
||||
- [Curl](#__tabbed_1_5)
|
||||
|
||||
Linux:
|
||||
|
||||
- [Curl](#__tabbed_1_1)
|
||||
|
||||
---
|
||||
|
||||
??? note "24/7 Up-time via VPS (Digital Ocean Guide)"
|
||||
--8<-- "md/guides/vps-linux-guide.md"
|
||||
|
||||
??? note "Creating a Discord Bot & Getting Credentials"
|
||||
--8<-- "md/creds-guide.md"
|
||||
|
||||
---
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
!!! failure
|
||||
This script is broken and should no be used. please use [Desktop Guide](../guides/desktop-guide.md)
|
||||
|
||||
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
||||
|
||||
1. First make sure that curl is installed
|
||||
|
||||
/// tab | Ubuntu | Debian | Mint
|
||||
|
||||
```bash
|
||||
sudo apt install curl
|
||||
```
|
||||
|
||||
///
|
||||
/// tab | Rocky | Alma | Fedora
|
||||
|
||||
```bash
|
||||
sudo dnf install curl
|
||||
```
|
||||
|
||||
///
|
||||
/// tab | openSUSE
|
||||
|
||||
```bash
|
||||
sudo zypper install curl
|
||||
```
|
||||
|
||||
///
|
||||
/// tab | Arch | Artix
|
||||
|
||||
```bash
|
||||
sudo pacman -S curl
|
||||
```
|
||||
|
||||
///
|
||||
/// tab | macOS
|
||||
|
||||
```bash
|
||||
brew install curl
|
||||
```
|
||||
|
||||
///
|
||||
|
||||
2. Download and run the **new** installer script
|
||||
``` sh
|
||||
cd ~
|
||||
curl -L -o e-install.sh https://toastielab.dev/EllieBotDevs/ellie-bash-installer/raw/branch/v6/e-install.sh
|
||||
bash e-install.sh
|
||||
```
|
||||
3. Install the bot (type `1` and press enter)
|
||||
4. Edit creds (type `3` and press enter)
|
||||
- *ALTERNATIVELY*, you can exit the installer (option `6`) and edit `ellie/creds.yml` file yourself
|
||||
5. Follow the instruction [below](#creating-your-own-discord-bot) to create your own Discord bot and obtain the credentials needed to run it.
|
||||
- After you're done, you can close nano (and save the file) by inputting, in order:
|
||||
- `CTRL` + `X`
|
||||
- `Y`
|
||||
- `Enter`
|
||||
6. Run the installer script again
|
||||
- `bash e-install.sh`
|
||||
7. Run the bot (type `3` and press enter)
|
||||
8. Done!
|
||||
|
||||
## Update Instructions
|
||||
|
||||
1. ⚠ Stop the bot ⚠
|
||||
2. Navigate to your bot's folder, we'll use home directory as an example
|
||||
- `cd ~`
|
||||
3. Simply re-install the bot with a newer version by running the installer script
|
||||
- `curl -L -o e-install.sh https://toastielab.dev/EllieBotDevs/ellie-bash-installer/raw/branch/v6/e-install.sh && bash e-install.sh`
|
||||
4. Select option 1, and select a NEWER version
|
||||
|
||||
## Running Ellie
|
||||
|
||||
There are two main methods to run EllieBot: using `tmux` (macOS and Linux) or using `systemd` with a script (Linux only).
|
||||
|
||||
/// tab | Tmux (Preferred Method)
|
||||
|
||||
Using `tmux` is the simplest method, and is therefore recommended for most users.
|
||||
|
||||
!!! warning
|
||||
Before proceeding, make sure your bot is not currently running by either running `.die` in your Discord server or exiting the process with `Ctrl+C`.
|
||||
|
||||
1. Access the directory where `e-install.sh` and `ellie` is located.
|
||||
2. Create a new tmux session: `tmux new -s ellie`
|
||||
- The above command will create a new session named **ellie**. You may replace **ellie** with any name you prefer.
|
||||
3. Run the installer: `bash e-install.sh`
|
||||
4. Start the bot by typing `3` and pressing `Enter`.
|
||||
5. Detach from the tmux session, allowing the bot to run in the background:
|
||||
- Press `Ctrl` + `B`
|
||||
- Then press `D`
|
||||
|
||||
Now check your Discord server, the bot should be online. Ellie should now be running in the background of your system.
|
||||
|
||||
To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t ellie`. *(Make sure to replace "ellie" with your session name. If you didn't change it, leave it as it is.)*
|
||||
|
||||
///
|
||||
/// tab | Systemd
|
||||
|
||||
!!! note
|
||||
Systemd is only available on Linux. macOS utilizes Launchd, which is not covered in this guide. If you're on macOS, please use the `tmux` method, or use [EllieHub](desktop-guide.md) to run EllieBot.
|
||||
|
||||
This method is a bit more complex and involved, but comes with the added benefit of better error logging and control over what happens before and after the startup of Ellie.
|
||||
|
||||
1. Access the directory where `e-install.sh` and `ellie` is located.
|
||||
2. Use the following command to create a service that will be used to execute `EllieRun.bash`:
|
||||
```bash
|
||||
echo "[Unit]
|
||||
Description=EllieBot service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=2
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
WorkingDirectory=$PWD
|
||||
ExecStart=/bin/bash EllieRun.bash
|
||||
#ExecStart=./ellie/EllieBot
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=EllieBot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/ellie.service
|
||||
```
|
||||
3. Make the new service available: `sudo systemctl daemon-reload`
|
||||
4. Use the following command to create a script that will be used to start Ellie:
|
||||
```bash
|
||||
cat <<EOF > EllieRun.bash
|
||||
#!/bin/bash
|
||||
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
is_python3_installed=\$(command -v python3 &>/dev/null && echo true || echo false)
|
||||
is_yt_dlp_installed=\$(command -v yt-dlp &>/dev/null && echo true || echo false)
|
||||
|
||||
[[ \$is_python3_installed == true ]] \\
|
||||
&& echo "[INFO] python3 path: \$(which python3)" \\
|
||||
&& echo "[INFO] python3 version: \$(python3 --version)"
|
||||
[[ \$is_yt_dlp_installed == true ]] \\
|
||||
&& echo "[INFO] yt-dlp path: \$(which yt-dlp)"
|
||||
|
||||
echo "[INFO] Running EllieBot in the background with auto restart"
|
||||
if [[ \$is_yt_dlp_installed == true ]]; then
|
||||
yt-dlp -U || echo "[ERROR] Failed to update 'yt-dlp'" >&2
|
||||
fi
|
||||
|
||||
echo "[INFO] Starting EllieBot..."
|
||||
|
||||
while true; do
|
||||
if [[ -d $PWD/ellie ]]; then
|
||||
cd "$PWD/ellie" || {
|
||||
echo "[ERROR] Failed to change working directory to '$PWD/ellie'" >&2
|
||||
echo "[INFO] Exiting..."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo "[WARN] '$PWD/ellie' doesn't exist" >&2
|
||||
echo "[INFO] Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./EllieBot || {
|
||||
echo "[ERROR] An error occurred when trying to start EllieBot" >&2
|
||||
echo "[INFO] Exiting..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "[INFO] Waiting 5 seconds..."
|
||||
sleep 5
|
||||
if [[ \$is_yt_dlp_installed == true ]]; then
|
||||
yt-dlp -U || echo "[ERROR] Failed to update 'yt-dlp'" >&2
|
||||
fi
|
||||
echo "[INFO] Restarting EllieBot..."
|
||||
done
|
||||
|
||||
echo "[INFO] Stopping EllieBot..."
|
||||
EOF
|
||||
```
|
||||
|
||||
With everything set up, you can run EllieBot in one of three modes:
|
||||
|
||||
1. **Auto-Restart Mode**: EllieBot will restart automatically if you restart it via the `.die` command.
|
||||
- To enable this mode, start the service: `sudo systemctl start ellie`
|
||||
2. **Auto-Restart on Reboot Mode**: In addition to auto-restarting after `.die`, EllieBot will also start automatically on system reboot.
|
||||
- To enable this mode, run:
|
||||
```bash
|
||||
sudo systemctl enable ellie
|
||||
sudo systemctl start ellie
|
||||
```
|
||||
3. **Standard Mode**: EllieBot will stop completely when you use `.die`, without restarting automatically.
|
||||
- To switch to this mode:
|
||||
1. Stop the service: `sudo systemctl stop ellie`
|
||||
2. Edit the service file: `sudo <editor> /etc/systemd/system/ellie.service`
|
||||
3. Modify the `ExecStart` line:
|
||||
- **Comment out**: `ExecStart=/bin/bash EllieRun.bash`
|
||||
- **Uncomment**: `#ExecStart=./ellie/EllieBot`
|
||||
4. Save and exit the editor.
|
||||
5. Reload systemd: `sudo systemctl daemon-reload`
|
||||
6. Disable automatic startup: `sudo systemctl disable ellie`
|
||||
7. Start EllieBot manually: `sudo systemctl start ellie`
|
||||
|
||||
///
|
53
docs/md/guides/desktop-guide.md
Normal file
53
docs/md/guides/desktop-guide.md
Normal file
|
@ -0,0 +1,53 @@
|
|||
# EllieBot Desktop Guide (via EllieHub)
|
||||
|
||||
### Supported Operating Systems
|
||||
|
||||
--8<-- "md/snippets/supported-platforms.md"
|
||||
|
||||
---
|
||||
|
||||
??? note "Creating a Discord Bot & Getting Credentials"
|
||||
--8<-- "md/creds-guide.md"
|
||||
|
||||
---
|
||||
|
||||
## Setup
|
||||
|
||||
1. Download and run [elliehub](https://toastielab.dev/EllieBotDevs/EllieHub/releases/latest).
|
||||
|
||||

|
||||
|
||||
2. Click the plus button to add a new bot
|
||||
|
||||

|
||||
|
||||
3. If you want to use the music module, click on the settings icon then click **`Install`** next to `ffmpeg` and `yt-dlp` near the top of the setting tab.
|
||||
4. Click on the newly created bot
|
||||
|
||||
5. Click on **Install** located above the live console (This may take a bit)
|
||||
|
||||

|
||||

|
||||
|
||||
6. When installation is finished, click on **`CREDS`** (`1`) above the **`RUN`** (`3`) button on the lower left
|
||||
- **`2`** simply opens your bot's data folder.
|
||||
7. Paste in your **BOT TOKEN** previously obtained
|
||||
|
||||
## Starting EllieBot
|
||||
|
||||
- Either click on **`RUN`** button in the updater or run the bot via its desktop shortcut.
|
||||
|
||||
## Updating EllieBot
|
||||
|
||||
!!! warning "IMPORTANT"
|
||||
|
||||
- Make sure Ellie is closed and not running
|
||||
- Run `.die` in a connected server to make sure.
|
||||
- Make sure you don't have `data` folder, bot folder, or any other bot file open in any program, as the updater will fail to replace your version
|
||||
|
||||
1. Run `elliehub` if not already running
|
||||
2. Click on your bot
|
||||
3. Click on **`Check for updates`**
|
||||
4. If updates are available, you will be able to click on the Update button
|
||||
5. Click `Update`
|
||||
6. Click `RUN` after it's done
|
72
docs/md/guides/docker-guide.md
Normal file
72
docs/md/guides/docker-guide.md
Normal file
|
@ -0,0 +1,72 @@
|
|||
# Docker Guide
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [Docker Core Engine](https://docs.docker.com/engine/install/)
|
||||
- [Docker Compose](https://docs.docker.com/compose/install/) (optional, but recommended)
|
||||
|
||||
---
|
||||
|
||||
??? note "Creating a Discord Bot & Getting Credentials"
|
||||
--8<-- "md/creds-guide.md"
|
||||
|
||||
---
|
||||
|
||||
## Installing EllieBot with Docker
|
||||
|
||||
When deploying EllieBot with Docker, you have two options: using [Docker](#__tabbed_1_1) or [Docker Compose](#__tabbed_1_2). The following sections provide step-by-step instructions for both methods.
|
||||
|
||||
/// tab | Docker
|
||||
|
||||
### Deploying EllieBot with Docker
|
||||
|
||||
1. Move to a directory where you want your Elliebot's data folder to be (data folder will keep the database and config files) and create a data folder there.
|
||||
``` sh
|
||||
cd ~ && mkdir ellie && cd ellie && mkdir data
|
||||
```
|
||||
2. Mount the newly created empty data folder as a volume while starting your docker container. Replace YOUR_TOKEN_HERE with the bot token obtained from the creds guide above.
|
||||
``` sh
|
||||
docker run -d --name ellie toastielab.dev/elliebotdevs/elliebot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 ellie
|
||||
```
|
||||
3. Enjoy! 🎉
|
||||
|
||||
### Updating your bot
|
||||
|
||||
If you want to update elliebot to the latest version, all you have to do is pull the latest image and re-run.
|
||||
|
||||
1. Pull the latest image
|
||||
``` sh
|
||||
docker pull toastielab.dev/elliebotdevs/elliebot:v6
|
||||
```
|
||||
2. Re-run your bot the same way you did before
|
||||
``` sh
|
||||
docker run -d --name ellie toastielab.dev/elliebotdevs/elliebot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 ellie
|
||||
```
|
||||
3. Done! 🎉
|
||||
|
||||
///
|
||||
/// tab | Docker Compose
|
||||
|
||||
1. **Choose Your Workspace:** Select a directory where you'll set up your EllieBot stack. Use your terminal to navigate to this directory. For the purpose of this guide, we'll use `/opt/stacks/ellie/` as an example, but you can choose any directory that suits your needs.
|
||||
2. **Create a Docker Compose File:** In this directory, create a Docker Compose file named `docker-compose.yml`. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano docker-compose.yml`.
|
||||
3. **Configure Your Docker Compose File:** Populate your Docker Compose file with the following configuration:
|
||||
``` yml
|
||||
services:
|
||||
ellie:
|
||||
image: toastielab.dev/elliebotdevs/elliebot:v6
|
||||
container_name: ellie
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Europe/Rome # Modify this to your timezone
|
||||
bot_token: YOUR_TOKEN_HERE
|
||||
volumes:
|
||||
- /opt/stacks/ellie/data:/app/data
|
||||
networks: {}
|
||||
```
|
||||
|
||||
1. **Launch Your Bot:** Now, you're ready to run Docker Compose. Use the following command: `docker compose up -d`.
|
||||
2. **Navigate to Your Directory:** Use `cd /opt/stacks/ellie/` to go to the directory containing your Docker Compose file.
|
||||
3. **Pull the Latest Images:** Use `docker compose pull` to fetch the latest images.
|
||||
4. **Restart Your Containers:** Use `docker compose up -d` to restart the containers.
|
||||
|
||||
///
|
66
docs/md/guides/source-guide.md
Normal file
66
docs/md/guides/source-guide.md
Normal file
|
@ -0,0 +1,66 @@
|
|||
# Setting Up EllieBot on Windows from source
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Windows 10 or later (64-bit)
|
||||
- [.net 8 sdk](https://dotnet.microsoft.com/download/dotnet/8.0)
|
||||
- If you want ellie to play music: [Visual C++ 2010 (x86)] and [Visual C++ 2017 (x64)] (both are required, you may install them later)
|
||||
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
||||
- **Optional** Any code editor, for example [Visual Studio Code](https://code.visualstudio.com/Download)
|
||||
- You'll need to at least modify creds.yml, notepad is inadequate
|
||||
|
||||
---
|
||||
|
||||
??? note "Creating a Discord Bot & Getting Credentials"
|
||||
--8<-- "md/creds-guide.md"
|
||||
|
||||
---
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and
|
||||
|
||||
1. Navigate to the location where you want to install the bot
|
||||
- for example, type `cd ~/Desktop/` and press enter
|
||||
2. `git clone https://toastielab.dev/EllieBotDevs/elliebot -b v6 --depth 1`
|
||||
3. `cd elliebot/src/EllieBot`
|
||||
4. `dotnet build -c Release`
|
||||
5. `cp data/creds_example.yml data/creds.yml`
|
||||
6. "You're done installing, you may now proceed to set up your bot's credentials by following the creds guide
|
||||
- Once done, come back here and run the last command
|
||||
6. Run the bot `dotnet EllieBot.dll`
|
||||
7. 🎉 Enjoy
|
||||
|
||||
## Update Instructions
|
||||
|
||||
Open PowerShell as described above and run the following commands:
|
||||
|
||||
1. Stop the bot
|
||||
- ⚠️ Make sure you don't have your database, credentials or any other elliebot folder open in some application, this might prevent some of the steps from executing successfully
|
||||
2. Navigate to your bot's folder, example:
|
||||
- `cd ~/Desktop/elliebot`
|
||||
3. Pull the new version, and make sure you're on the v6 branch
|
||||
- `git pull`
|
||||
- ⚠️ IF this fails, you may want to `git stash` or remove your code changes if you don't know how to resolve merge conflicts
|
||||
4. **Backup** old output in case your data is overwritten
|
||||
- `cp -r -fo output/ output-old`
|
||||
5. Build the bot again
|
||||
- `dotnet run -c Release src/EllieBot/`
|
||||
6. Copy old data, and new strings
|
||||
- `cp -r -fo .\output-old\data\ .\output\`
|
||||
7. Run the bot
|
||||
- `cd output`
|
||||
- `dotnet EllieBot.dll`
|
||||
8. 🎉 Enjoy
|
||||
|
||||
## Music Prerequisites
|
||||
|
||||
In order to use music commands, you need ffmpeg and yt-dlp installed.
|
||||
|
||||
- [ffmpeg]
|
||||
- [yt-dlp]
|
||||
- Click to download the `yt-dlp.exe` file, then move `yt-dlp.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `yt-dlp.exe` file to your elliebot's output folder.
|
||||
|
||||
[.net]: https://dotnet.microsoft.com/download/dotnet/8.0
|
||||
[ffmpeg]: https://github.com/GyanD/codexffmpeg/releases/latest
|
||||
[yt-dlp]: https://github.com/yt-dlp/yt-dlp/releases/latest
|
54
docs/md/guides/vps-linux-guide.md
Normal file
54
docs/md/guides/vps-linux-guide.md
Normal file
|
@ -0,0 +1,54 @@
|
|||
## Setting up Ellie on a Linux VPS (Digital Ocean Droplet)
|
||||
|
||||
If you want Ellie to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Ellie on Linux Digital Ocean Droplet using the link [DigitalOcean](https://m.do.co/c/1bb1db830f41/) (by using this link, you will get **$10 credit** and also support Ellie)
|
||||
|
||||
To set up the VPS, please select the options below
|
||||
```
|
||||
These are the min requirements you must follow:
|
||||
|
||||
OS: Any between Ubuntu, Fedora, and Debian
|
||||
|
||||
Droplet Type: SHARED CPU | Basic
|
||||
|
||||
CPU options: Regular | Disk type: SSD
|
||||
6$/mo
|
||||
1 GB / 1 CPU
|
||||
25 GB SSD Disk
|
||||
1000 GB transfer
|
||||
|
||||
Note: You can select the cheapest option with 512 MB / 1 CPU but this has been a hit or miss.
|
||||
|
||||
Datacenter region: Choose one depending on where you are located.
|
||||
|
||||
Authentication: Password or SSH
|
||||
(Select SSH if you know what you are doing, otherwise choose password)
|
||||
Click create droplet
|
||||
```
|
||||
**Setting up EllieBot**
|
||||
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.
|
||||
|
||||
**This section is only relevant to those who want to host Ellie on DigitalOcean. Go through this whole section before setting the bot up.**
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
|
||||
- Download [WinSCP](https://winscp.net/eng/download.php) *(optional)*
|
||||
- [Create and invite the bot](../creds-guide.md).
|
||||
|
||||
### Starting up
|
||||
|
||||
- **Open PuTTY** and paste or enter your `IP address` and then click **Open**.
|
||||
If you entered your Droplets IP address correctly, it should show **login as:** in a newly opened window.
|
||||
- Now for **login as:**, type `root` and press enter.
|
||||
- It should then ask for a password. Type the `root password` you have received in your e-mail address, then press Enter.
|
||||
|
||||
If you are running your droplet for the first time, it will most likely ask you to change your root password. To do that, copy the **password you've received by e-mail** and paste it on PuTTY.
|
||||
|
||||
- To paste, just right-click the window (it won't show any changes on the screen), then press Enter.
|
||||
- Type a **new password** somewhere, copy and paste it on PuTTY. Press Enter then paste it again.
|
||||
|
||||
**Save the new password somewhere safe.**
|
||||
|
||||
After that, your droplet should be ready for use.
|
||||
|
||||
[Setting up Ellie on a VPS (Digital Ocean)]: #setting-up-ellie-on-a-linux-vps-digital-ocean-droplet
|
40
docs/md/index.md
Normal file
40
docs/md/index.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
# EllieBot Documentation
|
||||
|
||||
<!-- ![img][header] -->
|
||||
|
||||
## Inviting Ellie
|
||||
|
||||
There are two versions of Ellie, a public bot and a self-hostable bot.
|
||||
|
||||
To invite public Ellie to your server or to view its commands, click on the buttons below:
|
||||
|
||||
[:material-plus: Add Ellie to your server][invite]{ .md-button .md-button--primary }
|
||||
[:material-format-list-text: View commands][commands]{ .md-button }
|
||||
|
||||
To self-host your own Ellie, use the guides below:
|
||||
|
||||
- [:material-television-guide: Desktop guide (Windows/Linux/macOS)][desktop-guide]
|
||||
- [:material-console: CLI guide (Linux/macOS)][cli-guide]
|
||||
- [:material-docker: Docker guide][docker-guide]
|
||||
- [:material-source-branch: From source guide][from-source-guide]
|
||||
|
||||
In case you need any help, join our [Discord server][discord-server] where we may provide support.
|
||||
|
||||
## About Ellie
|
||||
|
||||
EllieBot is an [open source project][toastielab]. Any issues with the bot may be filed [here][issues].
|
||||
|
||||
If you're unsure whether something is an issue, ask in our support server first.
|
||||
|
||||
[Donations are welcome][donate], and we rely on your contributions to help keep the project alive.
|
||||
|
||||
[invite]: https://discordapp.com/oauth2/authorize?client_id=608119997713350679&scope=bot&permissions=66186303/
|
||||
[commands]: https://commands.elliebot.net/
|
||||
[desktop-guide]: ./guides/desktop-guide.md
|
||||
[cli-guide]: ./guides/cli-guide.md
|
||||
[docker-guide]: ./guides/docker-guide.md
|
||||
[from-source-guide]: ./guides/source-guide.md
|
||||
[discord-server]: https://discord.gg/etQdZxSyEH
|
||||
[toastielab]: https://toastielab.dev/EllieBotDevs/elliebot
|
||||
[issues]: https://toastielab.dev/EllieBotDevs/elliebot/issues
|
||||
[donate]: ./donate.md
|
18
docs/md/marmalade/canary-lifecycle.md
Normal file
18
docs/md/marmalade/canary-lifecycle.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Canary Lifecycle
|
||||
|
||||
*You can override several methods to hook into command handler's lifecycle.
|
||||
These methods start with `Exec*`*
|
||||
|
||||
|
||||
- `ExecOnMessageAsync` runs first right after any message was received
|
||||
- `ExecInputTransformAsync` runs after ExecOnMessageAsync and allows you to transform the message content before the bot looks for the matching command
|
||||
- `ExecPreCommandAsync` runs after a command was found but not executed, allowing you to potentially prevent command execution
|
||||
- `ExecPostCommandAsync` runs if the command was successfully executed
|
||||
- `ExecOnNoCommandAsync` runs instead of ExecPostCommandAsync if no command was found for a message
|
||||
|
||||
|
||||
*Besides that, canaries have 2 methods with which you can initialize and cleanup your canary*
|
||||
|
||||
|
||||
- `InitializeAsync` Runs when the marmalade which contains this canary is being loaded
|
||||
- `DisposeAsync` Runs when the marmalade which contains this canary is being unloaded
|
279
docs/md/marmalade/creating-a-marmalade.md
Normal file
279
docs/md/marmalade/creating-a-marmalade.md
Normal file
|
@ -0,0 +1,279 @@
|
|||
## Practice
|
||||
|
||||
This section will guide you through how to create a simple custom marmalade. You can find the entirety of this code hosted [here](https://toastielab.dev/ellie/example_marmalade)
|
||||
|
||||
#### Prerequisite
|
||||
- [.net8 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
||||
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
||||
|
||||
#### There are currently two ways of creating a marmalade and you can view both of them using the tabs below.
|
||||
|
||||
/// tab | Using our template
|
||||
|
||||
### Prerequisite
|
||||
- [git](https://git-scm.com/downloads) installed
|
||||
|
||||
### Guide
|
||||
|
||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||
|
||||
- Install the ellie-marmalade template
|
||||
- `git clone https://toastielab.dev/EllieBotDevs/ellie-marmalade`
|
||||
- `cd ellie-marmalade`
|
||||
- `dotnet new install .\`
|
||||
|
||||
- Create a new folder and move into it
|
||||
- `mkdir example_marmalade `
|
||||
- `cd example_marmalade`
|
||||
|
||||
- Make a new Ellie Marmalade project
|
||||
- `dotnet new ellie-marmalade`
|
||||
- This can be any name you want you just have to specify `-n <any name you want here>` after the first part of the command
|
||||
- Here is an example `dotnet new ellie-marmalade -n my-cool-marmalade`
|
||||
- This will create a marmalade project with the name my-cool-marmalade
|
||||
|
||||
Now follow the instructions below and you should be good to go.
|
||||
///
|
||||
|
||||
/// tab | Building from scratch
|
||||
|
||||
### Guide
|
||||
|
||||
!!! info
|
||||
This requires writing a little bit of code but we will help you through it as much as we can.
|
||||
|
||||
|
||||
### Without any further issues we shall now begin
|
||||
|
||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||
|
||||
- Create a new folder
|
||||
- `mkdir example_marmalade`
|
||||
- Create a new .net class library
|
||||
- `dotnet new classlib`
|
||||
- Open the current folder with your favorite editor/IDE. In this case we'll use VsCode
|
||||
- `code .`
|
||||
- Remove the `Class1.cs` file
|
||||
- Replace the contents of the `.csproj` file with the following contents
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<!-- Reduces some boilerplate in your .cs files -->
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
<!-- Use latest .net features -->
|
||||
<LangVersion>preview</LangVersion>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
|
||||
|
||||
<!-- tell .net that this library will be used as a plugin -->
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Base marmalade package. You MUST reference this in order to have a working marmalade -->
|
||||
<!-- Also, this package comes from Toastielab, which requires you to have a NuGet.Config file next to your .csproj -->
|
||||
<PackageReference Include="Ellie.Marmalade" Version="6.*">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
<!-- Note: If you want to use EllieBot services etc... You will have to manually clone
|
||||
the https://toastielab.dev/EllieBotDevs/elliebot repo locally and reference the EllieBot.csproj because there is no EllieBot package atm.
|
||||
It is strongly recommended that you checkout a specific tag which matches your version of ellie,
|
||||
as there could be breaking changes even between minor versions of EllieBot.
|
||||
For example if you're running EllieBot 4.1.0 locally for which you want to create a marmalade for,
|
||||
you should do "git checkout 4.1.0" in your EllieBot solution and then reference the EllieBot.csproj
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Copy shortcut and full strings to output (if they exist) -->
|
||||
<ItemGroup>
|
||||
<None Update="res.yml;cmds.yml;strings/**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
```
|
||||
- Create a `MyCanary.cs` file and add the following contents
|
||||
```cs
|
||||
using EllieBot.Marmalade;
|
||||
using Discord;
|
||||
|
||||
public sealed class MyCanary : Canary
|
||||
{
|
||||
[cmd]
|
||||
public async Task Hello(AnyContext ctx)
|
||||
{
|
||||
await ctx.Channel.SendMessageAsync($"Hello everyone!");
|
||||
}
|
||||
|
||||
[cmd]
|
||||
public async Task Hello(AnyContext ctx, IUser target)
|
||||
{
|
||||
await ctx.ConfirmLocalizedAsync("hello", target);
|
||||
}
|
||||
}
|
||||
```
|
||||
- Create `res.yml` and `cmds.yml` files with the following contents
|
||||
|
||||
`res.yml`
|
||||
```yml
|
||||
marmalade.description: "This is my marmalade's description"
|
||||
hello: "Hello {0}, from res.yml!"
|
||||
```
|
||||
|
||||
`cmds.yml`
|
||||
```yml
|
||||
hello:
|
||||
desc: "This is a basic hello command"
|
||||
args:
|
||||
- ""
|
||||
- "@Someone"
|
||||
```
|
||||
|
||||
- Add `NuGet.Config` file which will let you use the base Ellie.Marmalade package. This file should always look like this and you shouldn't change it
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="toastielab.dev" value="https://toastielab.dev/api/packages/ellie/nuget/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
///
|
||||
|
||||
### Build it
|
||||
|
||||
- Build your Marmalade into a dll that Ellie can load. In your terminal, type:
|
||||
- `dotnet publish -o bin/marmalades/example_marmalade /p:DebugType=embedded`
|
||||
|
||||
- Done. You can now try it out in action.
|
||||
|
||||
### Try it out
|
||||
|
||||
- Copy the `bin/marmalades/example_marmalade` folder into your EllieBot's `data/marmalades/` folder. (EllieBot version 4.1.0+)
|
||||
|
||||
- Load it with `.maload example_marmalade`
|
||||
|
||||
- In the channel your bot can see, run the following commands to try it out
|
||||
- `.hello` and
|
||||
- `.hello @<someone>`
|
||||
|
||||
- Check its information with
|
||||
- `.mainfo example_marmalade`
|
||||
|
||||
- Unload it
|
||||
- `.maunload example_marmalade`
|
||||
|
||||
- 🎉 Congrats! You've just made your first marmalade! 🎉
|
||||
|
||||
## Theory
|
||||
|
||||
Marmalade system allows you to write independent marmalades (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
||||
|
||||
The marmalade base classes used for development are open source [here](https://toastielab.dev/EllieBotDevs/elliebot/src/branch/v5/src/Ellie.Marmalade) in case you need reference, as there is no generated documentation at the moment.
|
||||
|
||||
### Term list
|
||||
|
||||
#### Marmalade
|
||||
|
||||
- The project itself which compiles to a single `.dll` (and some optional auxiliary files), it can contain multiple [Canaries](#canary), [Services](#service), and [ParamParsers](#param-parser)
|
||||
|
||||
#### Canary
|
||||
|
||||
- A class which will be added as a single Module to EllieBot on load. It also acts as a [lifecycle handler](canary-lifecycle.md) and as a singleton service with the support for initialize and cleanup.
|
||||
- It can contain a Canary (called SubCanary) but only 1 level of nesting is supported (you can only have a canary contain a subcanary, but a subcanary can't contain any other canaries)
|
||||
- Canaries can have their own prefix
|
||||
- For example if you set this to 'test' then a command called 'cmd' will have to be invoked by using `.test cmd` instead of `.cmd`
|
||||
|
||||
#### Canary Command
|
||||
|
||||
- Acts as a normal command
|
||||
- Has context injected as a first argument which controls where the command can be executed
|
||||
- `AnyContext` the command can be executed in both DMs and Servers
|
||||
- `GuildContext` the command can only be executed in Servers
|
||||
- `DmContext` the command can only be executed in DMs
|
||||
- Support the usual features such as default values, leftover, params, etc.
|
||||
- It also supports dependency injection via `[inject]` attribute. These dependencies must come after the context and before any input parameters
|
||||
- Supports `ValueTask`, `Task`, `Task<T>` and `void` return types
|
||||
|
||||
#### Param Parser
|
||||
|
||||
- Allows custom parsing of command arguments into your own types.
|
||||
- Overriding existing parsers (for example for IGuildUser, etc...) can cause issues.
|
||||
|
||||
#### Service
|
||||
|
||||
- Usually not needed.
|
||||
- They are marked with a `[svc]` attribute, and offer a way to inject dependencies to different parts of your marmalade.
|
||||
- Transient and Singleton lifetimes are supported.
|
||||
|
||||
### Localization
|
||||
|
||||
Response and command strings can be kept in one of three different places based on whether you plan to allow support for localization
|
||||
|
||||
option 1) `res.yml` and `cmds.yml`
|
||||
|
||||
If you don't plan on having your app localized, but you just *may* in the future, you should keep your strings in the `res.yml` and `cmds.yml` file the root folder of your project, and they will be automatically copied to the output whenever you build your marmalade.
|
||||
|
||||
##### Example project folder structure:
|
||||
- uwu/
|
||||
- uwu.csproj
|
||||
- uwu.cs
|
||||
- res.yml
|
||||
- cmds.yml
|
||||
|
||||
##### Example output folder structure:
|
||||
- marmalades/uwu/
|
||||
- uwu.dll
|
||||
- res.yml
|
||||
- cmds.yml
|
||||
|
||||
option 2) `strings` folder
|
||||
|
||||
If you plan on having your app localized (or want to allow your consumers to easily add languages themselves), you should keep your response strings in the `strings/res/en-us.yml` and your command strings in `strings/cmds/en-us.yml` file. This will be your base file, and from there you can make support for additional languages, for example `strings/res/ru-ru.yml` and `strings/cmds/ru-ru.yml`
|
||||
|
||||
##### Example project folder structure:
|
||||
- uwu/
|
||||
- uwu.csproj
|
||||
- uwu.cs
|
||||
- strings/
|
||||
- res/
|
||||
- en-us.yml
|
||||
- cmds/
|
||||
- en-us.yml
|
||||
|
||||
##### Example output folder structure:
|
||||
- marmalades/uwu/
|
||||
- uwu.dll
|
||||
- strings/
|
||||
- res/
|
||||
- en-us.yml
|
||||
- cmds/
|
||||
- en-us.yml
|
||||
|
||||
option 3) In the code
|
||||
|
||||
If you don't want any auxiliary files, and you don't want to bother making new .yml files to keep your strings in, you can specify the command strings directly in the `[cmd]` attribute itself, and use non-localized methods for message sending in your commands.
|
||||
|
||||
If you update your response strings .yml file(s) while the marmalade is loaded and running, running `.stringsreload` will reload the responses without the need to reload the marmalade or restart the bot.
|
||||
|
||||
#### Bot marmalade config file
|
||||
|
||||
- Marmalade config is kept in `marmalades/marmalade.yml` file
|
||||
- At the moment this config only keeps track of which marmalades are currently loaded (they will also be always loaded at startup)
|
||||
- If a marmalade is causing issues and you're unable to unload it, you can remove it from the `loaded:` list in this config file and restart the bot. It won't be loaded next time the bot is started up
|
||||
|
||||
#### Unloadability issues
|
||||
|
||||
To make sure your marmalade can be properly unloaded/reloaded you must:
|
||||
|
||||
- Make sure that none of your types and objects are referenced by the Bot or Bot's services after the DisposeAsync is called on your Canary instances.
|
||||
|
||||
- Make sure that all of your commands execute quickly and don't have any long running tasks, as they will hold a reference to a type from your assembly
|
||||
|
||||
- If you are still having issues, you can always run `.maunload` followed by a bot restart, or if you want to find what is causing the marmalade unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
31
docs/md/marmalade/getting-started.md
Normal file
31
docs/md/marmalade/getting-started.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
## Getting Started
|
||||
|
||||
### What is the Marmalade system?
|
||||
|
||||
- It is a dynamic module/plugin/cog system for EllieBot introduced in **EllieBot 4.1.0**
|
||||
|
||||
- Allows developers to add custom functionality to Ellie without modifying the original code
|
||||
|
||||
- Allows for those custom features to be updated during bot runtime (if properly written), without the need for bot restart.
|
||||
|
||||
- They are added to `data/marmalades` folder and are loaded, unloaded and handled through discord commands.
|
||||
- `.maload` Loads the specified marmalade (see `.h .maload`)
|
||||
- `.maunload` Unloads the specified marmalade (see `.h .maunload`)
|
||||
- `.mainfo` Checks marmalades information (see `.h .mainfo`)
|
||||
- `.malist` Lists the available marmalades (see `.h .malist`)
|
||||
|
||||
### How to make one?
|
||||
|
||||
Marmalades are written in [C#](https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/) programming language, so you will need at least low-intermediate knowledge of it in order to make a useful Marmalade.
|
||||
|
||||
Follow the [creating a marmalade guide](creating-a-marmalade.md)
|
||||
|
||||
### Where to get marmalades other people made?
|
||||
|
||||
⚠ *It is EXTREMELY, and I repeat **EXTREMELY** dangerous to run marmalades of strangers or people you don't FULLY trust.* ⚠
|
||||
|
||||
⚠ *It can not only lead to your bot being stolen, but it also puts your entire computer and personal files in jeopardy.* ⚠
|
||||
|
||||
**It is strongly recommended to run only the marmalades you yourself wrote, and only on a hosted VPS or dedicated server which ONLY hosts your bot, to minimize the potential damage caused by bad actors.**
|
||||
|
||||
No easy way at the moment, except asking in the `#dev-and-modding` chat in [Ellie's Home server](https://discord.gg/etQdZxSyEH)
|
18
docs/md/snippets/supported-platforms.md
Normal file
18
docs/md/snippets/supported-platforms.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!-- TODO: These should potentially be reformated to be more readable... -->
|
||||
--8<-- [start:windows]
|
||||
- **Windows 10** or later (64-bit)
|
||||
--8<-- [end:windows]
|
||||
--8<-- [start:linux]
|
||||
- **Ubuntu**: 20.04, 22.04, 24.04
|
||||
- **Mint**: 19, 20, 21
|
||||
- **Debian**: 10, 11, 12
|
||||
- **RockyLinux**: 8, 9
|
||||
- **AlmaLinux**: 8, 9
|
||||
- **openSUSE Leap**: 15.5, 15.6
|
||||
- **openSUSE Tumbleweed**
|
||||
- **Fedora**: 38, 39, 40, 41, 42
|
||||
- **Arch** & **Artix**
|
||||
--8<-- [end:linux]
|
||||
--8<-- [start:macos]
|
||||
- **macOS 13 (Ventura)** or later
|
||||
--8<-- [end:macos]
|
3
docs/mkdocs-requirements.txt
Normal file
3
docs/mkdocs-requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
mkdocs-material~=9.6
|
||||
mkdocs~=1.6
|
||||
mkdocs-exclude~=1.0
|
80
docs/mkdocs.yml
Normal file
80
docs/mkdocs.yml
Normal file
|
@ -0,0 +1,80 @@
|
|||
site_name: EllieBot docs
|
||||
site_url: https://docs.elliebot.net
|
||||
repo_url: 'https://toastielab.dev/EllieBotDevs/elliebot'
|
||||
site_author: Toastie_t0ast
|
||||
docs_dir: 'md'
|
||||
copyright: Copyright © 2018 - 2025 Toastie_t0ast & EllieBotDevs
|
||||
theme:
|
||||
name: material
|
||||
palette:
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
primary: indigo
|
||||
accent: blue
|
||||
toggle:
|
||||
icon: material/weather-sunny
|
||||
name: Switch to dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: black
|
||||
accent: blue
|
||||
toggle:
|
||||
icon: material/weather-night
|
||||
name: Switch to light mode
|
||||
features:
|
||||
- navigation.instant
|
||||
- navigation.expand
|
||||
- navigation.top
|
||||
font:
|
||||
text: Source Sans 3
|
||||
code: Source Code Pro
|
||||
logo: assets/favicon.png
|
||||
favicon: assets/favicon.png
|
||||
icon:
|
||||
repo: material/git
|
||||
extra:
|
||||
homepage: https://elliebot.net
|
||||
plugins:
|
||||
- search
|
||||
- exclude:
|
||||
glob:
|
||||
- 'guides/vps-linux-guide.md'
|
||||
- 'snippets/supported-platforms.md'
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
- codehilite:
|
||||
guess_lang: false
|
||||
- toc:
|
||||
permalink: true
|
||||
- pymdownx.betterem:
|
||||
smart_enable: all
|
||||
- admonition
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences
|
||||
- pymdownx.blocks.tab:
|
||||
alternate_style: true
|
||||
- pymdownx.snippets
|
||||
- pymdownx.details
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
options:
|
||||
custom_icons:
|
||||
- overrides/.icons
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Guides:
|
||||
- Desktop Guide: guides/desktop-guide.md
|
||||
- CLI Guide: guides/cli-guide.md
|
||||
- Docker Guide: guides/docker-guide.md
|
||||
- Source Guide: guides/source-guide.md
|
||||
- Commands:
|
||||
- Commands List: https://commands.elliebot.net
|
||||
- Features Explained:
|
||||
- Basic Creds: creds-guide.md
|
||||
- Marmalade System:
|
||||
- marmalade/getting-started.md
|
||||
- marmalade/creating-a-marmalade.md
|
||||
- marmalade/canary-lifecycle.md
|
||||
- Donate: donate.md
|
|
@ -9,7 +9,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.17.1" />
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.17.2" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.6" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.29.3" />
|
||||
<PackageReference Include="Grpc" Version="2.46.6" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.69.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.68.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -12,7 +12,6 @@ service GrpcOther {
|
|||
rpc GetRoles(GetRolesRequest) returns (GetRolesReply);
|
||||
|
||||
rpc GetCurrencyLb(GetLbRequest) returns (CurrencyLbReply);
|
||||
rpc GetXpLb(GetLbRequest) returns (XpLbReply);
|
||||
rpc GetWaifuLb(GetLbRequest) returns (WaifuLbReply);
|
||||
|
||||
rpc GetShardStats(google.protobuf.Empty) returns (stream ShardStatsReply);
|
||||
|
@ -78,17 +77,6 @@ message GetLbRequest {
|
|||
int32 perPage = 2;
|
||||
}
|
||||
|
||||
message XpLbReply {
|
||||
repeated XpLbEntryReply entries = 1;
|
||||
}
|
||||
|
||||
message XpLbEntryReply {
|
||||
string user = 1;
|
||||
uint64 userId = 2;
|
||||
int64 totalXp = 3;
|
||||
int64 level = 4;
|
||||
}
|
||||
|
||||
message WaifuLbReply {
|
||||
repeated WaifuLbEntry entries = 1;
|
||||
}
|
||||
|
|
|
@ -10,22 +10,10 @@ service GrpcXp {
|
|||
|
||||
rpc GetXpSettings(GetXpSettingsRequest) returns (GetXpSettingsReply);
|
||||
|
||||
rpc AddExclusion(AddExclusionRequest) returns (AddExclusionReply);
|
||||
rpc DeleteExclusion(DeleteExclusionRequest) returns (DeleteExclusionReply);
|
||||
|
||||
rpc AddReward(AddRewardRequest) returns (AddRewardReply);
|
||||
rpc DeleteReward(DeleteRewardRequest) returns (DeleteRewardReply);
|
||||
|
||||
rpc SetServerExclusion(SetServerExclusionRequest) returns (SetServerExclusionReply);
|
||||
}
|
||||
|
||||
message SetServerExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
bool serverExcluded = 2;
|
||||
}
|
||||
|
||||
message SetServerExclusionReply {
|
||||
bool success = 1;
|
||||
|
||||
rpc GetUserXp(GetUserXpRequest) returns (GetUserXpReply);
|
||||
}
|
||||
|
||||
message GetXpLbRequest {
|
||||
|
@ -57,47 +45,19 @@ message ResetUserXpReply {
|
|||
}
|
||||
|
||||
message GetXpSettingsReply {
|
||||
repeated ExclItemReply exclusions = 1;
|
||||
repeated RewItemReply rewards = 2;
|
||||
bool serverExcluded = 3;
|
||||
}
|
||||
|
||||
message GetXpSettingsRequest {
|
||||
uint64 guildId = 1;
|
||||
}
|
||||
|
||||
message ExclItemReply {
|
||||
string type = 1;
|
||||
uint64 id = 2;
|
||||
string name = 3;
|
||||
}
|
||||
|
||||
message RewItemReply {
|
||||
int32 level = 1;
|
||||
string type = 2;
|
||||
string value = 3;
|
||||
}
|
||||
|
||||
message AddExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
string type = 2;
|
||||
uint64 id = 3;
|
||||
}
|
||||
|
||||
message AddExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message DeleteExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
string type = 2;
|
||||
uint64 id = 3;
|
||||
}
|
||||
|
||||
message DeleteExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message AddRewardRequest {
|
||||
uint64 guildId = 1;
|
||||
int32 level = 2;
|
||||
|
@ -117,4 +77,18 @@ message DeleteRewardRequest {
|
|||
|
||||
message DeleteRewardReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetUserXpRequest {
|
||||
uint64 guildId = 1;
|
||||
uint64 userId = 2;
|
||||
}
|
||||
|
||||
message GetUserXpReply {
|
||||
int64 xp = 1;
|
||||
int64 requiredXp = 2;
|
||||
int64 level = 3;
|
||||
string club = 4;
|
||||
string clubIcon = 5;
|
||||
int32 rank = 6;
|
||||
}
|
71
src/EllieBot.GrpcApiBase/protos/xpshop.proto
Normal file
71
src/EllieBot.GrpcApiBase/protos/xpshop.proto
Normal file
|
@ -0,0 +1,71 @@
|
|||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace = "EllieBot.GrpcApi";
|
||||
|
||||
package greet;
|
||||
|
||||
service GrpcXpShop {
|
||||
rpc AddXpShopItem (AddXpShopItemRequest) returns (AddXpShopItemReply);
|
||||
rpc GetShopItems (GetShopItemsRequest) returns (GetShopItemsReply);
|
||||
rpc UseShopItem (UseShopItemRequest) returns (UseShopItemReply);
|
||||
rpc BuyShopItem (BuyShopItemRequest) returns (BuyShopItemReply);
|
||||
}
|
||||
|
||||
message UseShopItemRequest {
|
||||
uint64 userId = 1;
|
||||
string uniqueName = 2;
|
||||
GrpcXpShopItemType itemType = 3;
|
||||
}
|
||||
|
||||
message UseShopItemReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message BuyShopItemRequest {
|
||||
uint64 userId = 1;
|
||||
string uniqueName = 2;
|
||||
GrpcXpShopItemType itemType = 3;
|
||||
}
|
||||
|
||||
message BuyShopItemReply {
|
||||
bool success = 1;
|
||||
optional BuyShopItemError Error = 2;
|
||||
}
|
||||
|
||||
enum BuyShopItemError {
|
||||
NotEnough = 0;
|
||||
AlreadyOwned = 1;
|
||||
Unknown = 2;
|
||||
}
|
||||
|
||||
message AddXpShopItemRequest {
|
||||
XpShopItem item = 1;
|
||||
string uniqueName = 2;
|
||||
GrpcXpShopItemType itemType = 3;
|
||||
}
|
||||
|
||||
message AddXpShopItemReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetShopItemsRequest {
|
||||
|
||||
}
|
||||
|
||||
message GetShopItemsReply {
|
||||
repeated XpShopItem bgs = 1;
|
||||
repeated XpShopItem frames = 2;
|
||||
}
|
||||
|
||||
message XpShopItem {
|
||||
string Name = 1;
|
||||
string Description = 2;
|
||||
int64 Price = 3;
|
||||
string FullUrl = 4;
|
||||
string PreviewUrl = 5;
|
||||
}
|
||||
|
||||
enum GrpcXpShopItemType {
|
||||
Bg = 0;
|
||||
Frame = 1;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
|
@ -14,6 +15,7 @@ namespace EllieBot.VotesApi
|
|||
public const string SchemeName = "AUTHORIZATION_SCHEME";
|
||||
public const string DiscordsClaim = "DISCORDS_CLAIM";
|
||||
public const string TopggClaim = "TOPGG_CLAIM";
|
||||
public const string DiscordbotlistClaim = "DISCORDBOTLIST_CLAIM";
|
||||
|
||||
private readonly IConfiguration _conf;
|
||||
|
||||
|
@ -24,17 +26,58 @@ namespace EllieBot.VotesApi
|
|||
: base(options, logger, encoder)
|
||||
=> _conf = conf;
|
||||
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
if (!Request.Headers.TryGetValue("Authorization", out var authHeader))
|
||||
{
|
||||
return AuthenticateResult.Fail("Authorization header missing");
|
||||
}
|
||||
|
||||
var authToken = authHeader.ToString().Trim();
|
||||
if (string.IsNullOrWhiteSpace(authToken))
|
||||
{
|
||||
return AuthenticateResult.Fail("Authorization token empty");
|
||||
}
|
||||
|
||||
var claims = new List<Claim>();
|
||||
|
||||
if (_conf[ConfKeys.DISCORDS_KEY].Trim() == Request.Headers["Authorization"].ToString().Trim())
|
||||
claims.Add(new(DiscordsClaim, "true"));
|
||||
var discsKey = _conf[ConfKeys.DISCORDS_KEY]?.Trim();
|
||||
var topggKey = _conf[ConfKeys.TOPGG_KEY]?.Trim();
|
||||
var dblKey = _conf[ConfKeys.DISCORDBOTLIST_KEY]?.Trim();
|
||||
|
||||
if (_conf[ConfKeys.TOPGG_KEY] == Request.Headers["Authorization"].ToString().Trim())
|
||||
if (!string.IsNullOrWhiteSpace(discsKey)
|
||||
&& System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(discsKey),
|
||||
Encoding.UTF8.GetBytes(authToken)))
|
||||
{
|
||||
claims.Add(new Claim(DiscordsClaim, "true"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(topggKey)
|
||||
&& System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(topggKey),
|
||||
Encoding.UTF8.GetBytes(authToken)))
|
||||
{
|
||||
claims.Add(new Claim(TopggClaim, "true"));
|
||||
}
|
||||
|
||||
return Task.FromResult(AuthenticateResult.Success(new(new(new ClaimsIdentity(claims)), SchemeName)));
|
||||
if (!string.IsNullOrWhiteSpace(dblKey)
|
||||
&& System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(dblKey),
|
||||
Encoding.UTF8.GetBytes(authToken)))
|
||||
{
|
||||
claims.Add(new Claim(DiscordbotlistClaim, "true"));
|
||||
}
|
||||
|
||||
if (claims.Count == 0)
|
||||
{
|
||||
return AuthenticateResult.Fail("Invalid authorization token");
|
||||
}
|
||||
|
||||
return AuthenticateResult.Success(
|
||||
new AuthenticationTicket(
|
||||
new ClaimsPrincipal(new ClaimsIdentity(claims)),
|
||||
SchemeName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,5 +4,6 @@
|
|||
{
|
||||
public const string DISCORDS_KEY = "DiscordsKey";
|
||||
public const string TOPGG_KEY = "TopGGKey";
|
||||
public const string DISCORDBOTLIST_KEY = "DiscordbotListKey";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
namespace EllieBot.VotesApi
|
||||
{
|
||||
public class DiscordbotlistVoteWebhookModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The avatar hash of the user
|
||||
/// </summary>
|
||||
public string Avatar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The username of the user who voted
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the user who voted
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
}
|
||||
}
|
|
@ -12,12 +12,6 @@
|
|||
/// </summary>
|
||||
public string Bot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains totalVotes, votesMonth, votes24, hasVoted - a list of IDs of users who have voted this month, and
|
||||
/// Voted24 - a list of IDs of users who have voted today
|
||||
/// </summary>
|
||||
public string Votes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of event, whether it is a vote event or test event
|
||||
/// </summary>
|
|
@ -4,5 +4,6 @@
|
|||
{
|
||||
public const string DiscordsAuth = "DiscordsAuth";
|
||||
public const string TopggAuth = "TopggAuth";
|
||||
public const string DiscordbotlistAuth = "DiscordbotlistAuth";
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.VotesApi.Services;
|
||||
|
||||
namespace EllieBot.VotesApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class DiscordsController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<DiscordsController> _logger;
|
||||
private readonly IVotesCache _cache;
|
||||
|
||||
public DiscordsController(ILogger<DiscordsController> logger, IVotesCache cache)
|
||||
{
|
||||
_logger = logger;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
[HttpGet("new")]
|
||||
[Authorize(Policy = Policies.DiscordsAuth)]
|
||||
public async Task<IEnumerable<Vote>> New()
|
||||
{
|
||||
var votes = await _cache.GetNewDiscordsVotesAsync();
|
||||
if (votes.Count > 0)
|
||||
_logger.LogInformation("Sending {NewDiscordsVotes} new discords votes", votes.Count);
|
||||
return votes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.VotesApi.Services;
|
||||
|
||||
namespace EllieBot.VotesApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class TopGgController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<TopGgController> _logger;
|
||||
private readonly IVotesCache _cache;
|
||||
|
||||
public TopGgController(ILogger<TopGgController> logger, IVotesCache cache)
|
||||
{
|
||||
_logger = logger;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
[HttpGet("new")]
|
||||
[Authorize(Policy = Policies.TopggAuth)]
|
||||
public async Task<IEnumerable<Vote>> New()
|
||||
{
|
||||
var votes = await _cache.GetNewTopGgVotesAsync();
|
||||
if (votes.Count > 0)
|
||||
_logger.LogInformation("Sending {NewTopggVotes} new topgg votes", votes.Count);
|
||||
|
||||
return votes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,33 +2,32 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.VotesApi.Services;
|
||||
using EllieBot.GrpcVotesApi;
|
||||
|
||||
namespace EllieBot.VotesApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
public class WebhookController : ControllerBase
|
||||
public class WebhookController(ILogger<WebhookController> logger, VoteService.VoteServiceClient client)
|
||||
: ControllerBase
|
||||
{
|
||||
private readonly ILogger<WebhookController> _logger;
|
||||
private readonly IVotesCache _votesCache;
|
||||
|
||||
public WebhookController(ILogger<WebhookController> logger, IVotesCache votesCache)
|
||||
{
|
||||
_logger = logger;
|
||||
_votesCache = votesCache;
|
||||
}
|
||||
|
||||
[HttpPost("/discordswebhook")]
|
||||
[Authorize(Policy = Policies.DiscordsAuth)]
|
||||
public async Task<IActionResult> DiscordsWebhook([FromBody] DiscordsVoteWebhookModel data)
|
||||
{
|
||||
|
||||
_logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
if ((data.Type?.Contains("vote") ?? false) == false)
|
||||
return Ok();
|
||||
|
||||
logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
data.User,
|
||||
data.Bot,
|
||||
"discords.com");
|
||||
|
||||
await _votesCache.AddNewDiscordsVote(data.User);
|
||||
await client.VoteReceivedAsync(new GrpcVoteData()
|
||||
{
|
||||
Type = VoteType.Discords,
|
||||
UserId = data.User,
|
||||
});
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
@ -36,12 +35,34 @@ namespace EllieBot.VotesApi.Controllers
|
|||
[Authorize(Policy = Policies.TopggAuth)]
|
||||
public async Task<IActionResult> TopggWebhook([FromBody] TopggVoteWebhookModel data)
|
||||
{
|
||||
_logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
data.User,
|
||||
data.Bot,
|
||||
"top.gg");
|
||||
|
||||
await _votesCache.AddNewTopggVote(data.User);
|
||||
await client.VoteReceivedAsync(new GrpcVoteData()
|
||||
{
|
||||
Type = VoteType.Topgg,
|
||||
UserId = data.User,
|
||||
});
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("/discordbotlistwebhook")]
|
||||
[Authorize(Policy = Policies.DiscordbotlistAuth)]
|
||||
public async Task<IActionResult> DiscordbotlistWebhook([FromBody] DiscordbotlistVoteWebhookModel data)
|
||||
{
|
||||
logger.LogInformation("User {UserId} has voted for Bot on {Platform}",
|
||||
data.Id,
|
||||
"discordbotlist.com");
|
||||
|
||||
await client.VoteReceivedAsync(new GrpcVoteData()
|
||||
{
|
||||
Type = VoteType.Discordbotlist,
|
||||
UserId = data.Id,
|
||||
});
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["src/EllieBot.VotesApi/EllieBot.VotesApi.csproj", "EllieBot.VotesApi/"]
|
||||
RUN dotnet restore "src/EllieBot.VotesApi/EllieBot.VotesApi.csproj"
|
||||
COPY . .
|
||||
COPY ["EllieBot.VotesApi.csproj", "EllieBot.VotesApi/"]
|
||||
RUN dotnet restore "EllieBot.VotesApi/EllieBot.VotesApi.csproj"
|
||||
COPY . "EllieBot.VotesApi/"
|
||||
WORKDIR "/src/EllieBot.VotesApi"
|
||||
RUN dotnet build "EllieBot.VotesApi.csproj" -c Release -o /app/build
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="MorseCode.ITask" Version="2.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.70.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="Protos/vote.proto" GrpcServices="Client" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using EllieBot.VotesApi;
|
||||
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
|
||||
static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
|
||||
static IHostBuilder CreateHostBuilder(string[] args)
|
||||
=> Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration(c => c.AddEnvironmentVariables())
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder
|
||||
.UseStartup<Startup>();
|
||||
});
|
24
src/EllieBot.VotesApi/Protos/vote.proto
Normal file
24
src/EllieBot.VotesApi/Protos/vote.proto
Normal file
|
@ -0,0 +1,24 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package vote;
|
||||
|
||||
option csharp_namespace = "EllieBot.GrpcVotesApi";
|
||||
|
||||
enum VoteType {
|
||||
TOPGG = 0;
|
||||
DISCORDBOTLIST = 1;
|
||||
DISCORDS = 2;
|
||||
}
|
||||
|
||||
message GrpcVoteData {
|
||||
string userId = 1;
|
||||
VoteType type = 2;
|
||||
}
|
||||
|
||||
message GrpcVoteResult {
|
||||
|
||||
}
|
||||
|
||||
service VoteService {
|
||||
rpc VoteReceived (GrpcVoteData) returns (GrpcVoteResult);
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using MorseCode.ITask;
|
||||
|
||||
namespace EllieBot.VotesApi.Services
|
||||
{
|
||||
public class FileVotesCache : IVotesCache
|
||||
{
|
||||
// private const string STATS_FILE = "store/stats.json";
|
||||
private const string TOPGG_FILE = "store/topgg.json";
|
||||
private const string DISCORDS_FILE = "store/discords.json";
|
||||
|
||||
private readonly SemaphoreSlim _locker = new SemaphoreSlim(1, 1);
|
||||
|
||||
public FileVotesCache()
|
||||
{
|
||||
if (!Directory.Exists("store"))
|
||||
Directory.CreateDirectory("store");
|
||||
|
||||
if (!File.Exists(TOPGG_FILE))
|
||||
File.WriteAllText(TOPGG_FILE, "[]");
|
||||
|
||||
if (!File.Exists(DISCORDS_FILE))
|
||||
File.WriteAllText(DISCORDS_FILE, "[]");
|
||||
}
|
||||
|
||||
public ITask AddNewTopggVote(string userId)
|
||||
=> AddNewVote(TOPGG_FILE, userId);
|
||||
|
||||
public ITask AddNewDiscordsVote(string userId)
|
||||
=> AddNewVote(DISCORDS_FILE, userId);
|
||||
|
||||
private async ITask AddNewVote(string file, string userId)
|
||||
{
|
||||
await _locker.WaitAsync();
|
||||
try
|
||||
{
|
||||
var votes = await GetVotesAsync(file);
|
||||
votes.Add(userId);
|
||||
await File.WriteAllTextAsync(file, JsonSerializer.Serialize(votes));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_locker.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public async ITask<IList<Vote>> GetNewTopGgVotesAsync()
|
||||
{
|
||||
var votes = await EvictTopggVotes();
|
||||
return votes;
|
||||
}
|
||||
|
||||
public async ITask<IList<Vote>> GetNewDiscordsVotesAsync()
|
||||
{
|
||||
var votes = await EvictDiscordsVotes();
|
||||
return votes;
|
||||
}
|
||||
|
||||
private ITask<List<Vote>> EvictTopggVotes()
|
||||
=> EvictVotes(TOPGG_FILE);
|
||||
|
||||
private ITask<List<Vote>> EvictDiscordsVotes()
|
||||
=> EvictVotes(DISCORDS_FILE);
|
||||
|
||||
private async ITask<List<Vote>> EvictVotes(string file)
|
||||
{
|
||||
await _locker.WaitAsync();
|
||||
try
|
||||
{
|
||||
|
||||
var ids = await GetVotesAsync(file);
|
||||
await File.WriteAllTextAsync(file, "[]");
|
||||
|
||||
return ids?
|
||||
.Select(x => (Ok: ulong.TryParse(x, out var r), Id: r))
|
||||
.Where(x => x.Ok)
|
||||
.Select(x => new Vote
|
||||
{
|
||||
UserId = x.Id
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_locker.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private async ITask<IList<string>> GetVotesAsync(string file)
|
||||
{
|
||||
await using var fs = File.Open(file, FileMode.Open);
|
||||
var votes = await JsonSerializer.DeserializeAsync<List<string>>(fs);
|
||||
return votes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using MorseCode.ITask;
|
||||
|
||||
namespace EllieBot.VotesApi.Services
|
||||
{
|
||||
public interface IVotesCache
|
||||
{
|
||||
ITask<IList<Vote>> GetNewTopGgVotesAsync();
|
||||
ITask<IList<Vote>> GetNewDiscordsVotesAsync();
|
||||
ITask AddNewTopggVote(string userId);
|
||||
ITask AddNewDiscordsVote(string userId);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using System;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using EllieBot.VotesApi.Services;
|
||||
using EllieBot.GrpcVotesApi;
|
||||
|
||||
namespace EllieBot.VotesApi
|
||||
{
|
||||
|
@ -21,11 +22,16 @@ namespace EllieBot.VotesApi
|
|||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
services.AddSingleton<IVotesCache, FileVotesCache>();
|
||||
services.AddSwaggerGen(static c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "EllieBot.VotesApi", Version = "v1" });
|
||||
});
|
||||
|
||||
services.AddGrpcClient<VoteService.VoteServiceClient>(options =>
|
||||
{
|
||||
options.Address = new Uri(Configuration["BotGrpcHost"]!);
|
||||
})
|
||||
.ConfigureChannel((sp, c) =>
|
||||
{
|
||||
c.Credentials = ChannelCredentials.Insecure;
|
||||
c.ServiceProvider = sp;
|
||||
});
|
||||
|
||||
services
|
||||
.AddAuthentication(opts =>
|
||||
|
@ -40,9 +46,18 @@ namespace EllieBot.VotesApi
|
|||
opts.DefaultPolicy = new AuthorizationPolicyBuilder(AuthHandler.SchemeName)
|
||||
.RequireAssertion(static _ => false)
|
||||
.Build();
|
||||
opts.AddPolicy(Policies.DiscordsAuth, static policy => policy.RequireClaim(AuthHandler.DiscordsClaim));
|
||||
opts.AddPolicy(Policies.TopggAuth, static policy => policy.RequireClaim(AuthHandler.TopggClaim));
|
||||
opts.AddPolicy(Policies.DiscordsAuth,
|
||||
static policy => policy.RequireClaim(AuthHandler.DiscordsClaim));
|
||||
opts.AddPolicy(Policies.TopggAuth,
|
||||
static policy => policy.RequireClaim(AuthHandler.TopggClaim));
|
||||
opts.AddPolicy(Policies.DiscordbotlistAuth,
|
||||
static policy => policy.RequireClaim(AuthHandler.DiscordbotlistClaim));
|
||||
});
|
||||
|
||||
services.AddCors(x => x.AddDefaultPolicy(cpb =>
|
||||
cpb.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyOrigin()));
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
@ -51,8 +66,6 @@ namespace EllieBot.VotesApi
|
|||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(static c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "EllieBot.VotesApi v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
|
|
@ -8,5 +8,7 @@
|
|||
},
|
||||
"DiscordsKey": "my_discords_key",
|
||||
"TopGGKey": "my_topgg_key",
|
||||
"DiscordBotListKey": "my_discordbotlist_key",
|
||||
"BotGrpcHost": "http://127.0.0.1:59384",
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public abstract class EllieContext : DbContext
|
|||
{
|
||||
// load all entities from current assembly
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(EllieContext).Assembly);
|
||||
|
||||
|
||||
#region Notify
|
||||
|
||||
modelBuilder.Entity<Notify>(e =>
|
||||
|
@ -113,8 +113,8 @@ public abstract class EllieContext : DbContext
|
|||
#region GuildColors
|
||||
|
||||
modelBuilder.Entity<GuildColors>()
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique(true);
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique(true);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -123,7 +123,7 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<ButtonRole>(br =>
|
||||
{
|
||||
br.HasIndex(x => x.GuildId)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
|
||||
br.HasAlternateKey(x => new
|
||||
{
|
||||
|
@ -145,27 +145,27 @@ public abstract class EllieContext : DbContext
|
|||
});
|
||||
|
||||
sg.HasMany(x => x.Roles)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Sar>()
|
||||
.HasAlternateKey(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.RoleId
|
||||
});
|
||||
.HasAlternateKey(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.RoleId
|
||||
});
|
||||
|
||||
modelBuilder.Entity<SarAutoDelete>()
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rakeback
|
||||
|
||||
modelBuilder.Entity<Rakeback>()
|
||||
.HasKey(x => x.UserId);
|
||||
.HasKey(x => x.UserId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -174,14 +174,14 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<UserBetStats>(ubs =>
|
||||
{
|
||||
ubs.HasIndex(x => new
|
||||
{
|
||||
x.UserId,
|
||||
x.Game
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.UserId,
|
||||
x.Game
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
ubs.HasIndex(x => x.MaxWin)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -189,22 +189,22 @@ public abstract class EllieContext : DbContext
|
|||
#region Flag Translate
|
||||
|
||||
modelBuilder.Entity<FlagTranslateChannel>()
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ChannelId
|
||||
})
|
||||
.IsUnique();
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ChannelId
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
#region NCanvas
|
||||
|
||||
modelBuilder.Entity<NCPixel>()
|
||||
.HasAlternateKey(x => x.Position);
|
||||
.HasAlternateKey(x => x.Position);
|
||||
|
||||
modelBuilder.Entity<NCPixel>()
|
||||
.HasIndex(x => x.OwnerId);
|
||||
.HasIndex(x => x.OwnerId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -221,10 +221,11 @@ public abstract class EllieContext : DbContext
|
|||
var configEntity = modelBuilder.Entity<GuildConfig>();
|
||||
|
||||
configEntity.HasIndex(c => c.GuildId)
|
||||
.IsUnique();
|
||||
.IsUnique();
|
||||
|
||||
configEntity.Property(x => x.VerboseErrors)
|
||||
.HasDefaultValue(true);
|
||||
.HasDefaultValue(true);
|
||||
|
||||
// end shop
|
||||
|
||||
modelBuilder.Entity<PlantedCurrency>().HasIndex(x => x.MessageId).IsUnique();
|
||||
|
@ -270,22 +271,19 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<DiscordUser>(du =>
|
||||
{
|
||||
du.Property(x => x.IsClubAdmin)
|
||||
.HasDefaultValue(false);
|
||||
|
||||
du.Property(x => x.NotifyOnLevelUp)
|
||||
.HasDefaultValue(XpNotificationLocation.None);
|
||||
.HasDefaultValue(false);
|
||||
|
||||
du.Property(x => x.TotalXp)
|
||||
.HasDefaultValue(0);
|
||||
.HasDefaultValue(0);
|
||||
|
||||
du.Property(x => x.CurrencyAmount)
|
||||
.HasDefaultValue(0);
|
||||
.HasDefaultValue(0);
|
||||
|
||||
du.HasAlternateKey(w => w.UserId);
|
||||
du.HasOne(x => x.Club)
|
||||
.WithMany(x => x.Members)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.WithMany(x => x.Members)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
du.HasIndex(x => x.TotalXp);
|
||||
du.HasIndex(x => x.CurrencyAmount);
|
||||
|
@ -311,11 +309,11 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
var xps = modelBuilder.Entity<UserXpStats>();
|
||||
xps.HasIndex(x => new
|
||||
{
|
||||
x.UserId,
|
||||
x.GuildId
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.UserId,
|
||||
x.GuildId
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
xps.HasIndex(x => x.UserId);
|
||||
xps.HasIndex(x => x.GuildId);
|
||||
|
@ -327,49 +325,49 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
var ci = modelBuilder.Entity<ClubInfo>();
|
||||
ci.HasOne(x => x.Owner)
|
||||
.WithOne()
|
||||
.HasForeignKey<ClubInfo>(x => x.OwnerId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
.WithOne()
|
||||
.HasForeignKey<ClubInfo>(x => x.OwnerId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
ci.HasIndex(x => new
|
||||
{
|
||||
x.Name
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.Name
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClubManytoMany
|
||||
|
||||
modelBuilder.Entity<ClubApplicants>()
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ClubApplicants>()
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
|
||||
modelBuilder.Entity<ClubApplicants>()
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Applicants);
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Applicants);
|
||||
|
||||
modelBuilder.Entity<ClubBans>()
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ClubBans>()
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
|
||||
modelBuilder.Entity<ClubBans>()
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Bans);
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Bans);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -378,16 +376,16 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<CurrencyTransaction>(e =>
|
||||
{
|
||||
e.HasIndex(x => x.UserId)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
|
||||
e.Property(x => x.OtherId)
|
||||
.HasDefaultValueSql(CurrencyTransactionOtherIdDefaultValue);
|
||||
.HasDefaultValueSql(CurrencyTransactionOtherIdDefaultValue);
|
||||
|
||||
e.Property(x => x.Type)
|
||||
.IsRequired();
|
||||
.IsRequired();
|
||||
|
||||
e.Property(x => x.Extra)
|
||||
.IsRequired();
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -402,21 +400,21 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
|
||||
modelBuilder.Entity<BanTemplate>()
|
||||
.Property(x => x.PruneDays)
|
||||
.HasDefaultValue(null)
|
||||
.IsRequired(false);
|
||||
.Property(x => x.PruneDays)
|
||||
.HasDefaultValue(null)
|
||||
.IsRequired(false);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Perm Override
|
||||
|
||||
modelBuilder.Entity<DiscordPermOverride>()
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Command
|
||||
})
|
||||
.IsUnique();
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Command
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -433,14 +431,14 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<ReactionRoleV2>(rr2 =>
|
||||
{
|
||||
rr2.HasIndex(x => x.GuildId)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
|
||||
rr2.HasIndex(x => new
|
||||
{
|
||||
x.MessageId,
|
||||
x.Emote
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.MessageId,
|
||||
x.Emote
|
||||
})
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -450,18 +448,18 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<LogSetting>(ls => ls.HasIndex(x => x.GuildId).IsUnique());
|
||||
|
||||
modelBuilder.Entity<LogSetting>(ls => ls
|
||||
.HasMany(x => x.LogIgnores)
|
||||
.WithOne(x => x.LogSetting)
|
||||
.OnDelete(DeleteBehavior.Cascade));
|
||||
.HasMany(x => x.LogIgnores)
|
||||
.WithOne(x => x.LogSetting)
|
||||
.OnDelete(DeleteBehavior.Cascade));
|
||||
|
||||
modelBuilder.Entity<IgnoredLogItem>(ili => ili
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.LogSettingId,
|
||||
x.LogItemId,
|
||||
x.ItemType
|
||||
})
|
||||
.IsUnique());
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.LogSettingId,
|
||||
x.LogItemId,
|
||||
x.ItemType
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -514,12 +512,12 @@ public abstract class EllieContext : DbContext
|
|||
{
|
||||
// user can own only one of each item
|
||||
x.HasIndex(model => new
|
||||
{
|
||||
model.UserId,
|
||||
model.ItemType,
|
||||
model.ItemKey
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
model.UserId,
|
||||
model.ItemType,
|
||||
model.ItemKey
|
||||
})
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -527,27 +525,27 @@ public abstract class EllieContext : DbContext
|
|||
#region AutoPublish
|
||||
|
||||
modelBuilder.Entity<AutoPublishChannel>(apc => apc
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique());
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
#region GamblingStats
|
||||
|
||||
modelBuilder.Entity<GamblingStats>(gs => gs
|
||||
.HasIndex(x => x.Feature)
|
||||
.IsUnique());
|
||||
.HasIndex(x => x.Feature)
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sticky Roles
|
||||
|
||||
modelBuilder.Entity<StickyRole>(sr => sr.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
{
|
||||
x.GuildId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -555,35 +553,35 @@ public abstract class EllieContext : DbContext
|
|||
#region Giveaway
|
||||
|
||||
modelBuilder.Entity<GiveawayModel>()
|
||||
.HasMany(x => x.Participants)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.GiveawayId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.HasMany(x => x.Participants)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.GiveawayId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GiveawayUser>(gu => gu
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GiveawayId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GiveawayId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Todo
|
||||
|
||||
modelBuilder.Entity<TodoModel>()
|
||||
.HasKey(x => x.Id);
|
||||
.HasKey(x => x.Id);
|
||||
|
||||
modelBuilder.Entity<TodoModel>()
|
||||
.HasIndex(x => x.UserId)
|
||||
.IsUnique(false);
|
||||
.HasIndex(x => x.UserId)
|
||||
.IsUnique(false);
|
||||
|
||||
modelBuilder.Entity<ArchivedTodoListModel>()
|
||||
.HasMany(x => x.Items)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.ArchiveId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.HasMany(x => x.Items)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.ArchiveId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -591,11 +589,11 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
modelBuilder
|
||||
.Entity<GreetSettings>(gs => gs.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.GreetType
|
||||
})
|
||||
.IsUnique());
|
||||
{
|
||||
x.GuildId,
|
||||
x.GreetType
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
modelBuilder.Entity<GreetSettings>(gs =>
|
||||
{
|
||||
|
@ -622,6 +620,6 @@ public abstract class EllieContext : DbContext
|
|||
#endif
|
||||
|
||||
optionsBuilder.ConfigureWarnings(x => x.Log(RelationalEventId.PendingModelChangesWarning)
|
||||
.Ignore());
|
||||
.Ignore());
|
||||
}
|
||||
}
|
|
@ -7,14 +7,23 @@ namespace EllieBot.Db;
|
|||
|
||||
public static class CurrencyTransactionExtensions
|
||||
{
|
||||
public static Task<List<CurrencyTransaction>> GetPageFor(
|
||||
public static async Task<IReadOnlyCollection<CurrencyTransaction>> GetPageFor(
|
||||
this DbSet<CurrencyTransaction> set,
|
||||
ulong userId,
|
||||
int page)
|
||||
=> set.ToLinqToDBTable()
|
||||
{
|
||||
var items = await set.ToLinqToDBTable()
|
||||
.Where(x => x.UserId == userId)
|
||||
.OrderByDescending(x => x.DateAdded)
|
||||
.Skip(15 * page)
|
||||
.Take(15)
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async Task<int> GetCountFor(this DbSet<CurrencyTransaction> set, ulong userId)
|
||||
=> await set.ToLinqToDBTable()
|
||||
.Where(x => x.UserId == userId)
|
||||
.CountAsyncLinqToDB();
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
||||
// FUTURE remove LastLevelUp from here and UserXpStats
|
||||
public class DiscordUser : DbEntity
|
||||
{
|
||||
public const string DEFAULT_USERNAME = "??Unknown";
|
||||
|
@ -15,7 +13,6 @@ public class DiscordUser : DbEntity
|
|||
public bool IsClubAdmin { get; set; }
|
||||
|
||||
public long TotalXp { get; set; }
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
|
||||
public long CurrencyAmount { get; set; }
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@ public class FollowedStream
|
|||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string PrettyName { get; set; } = null;
|
||||
public FType Type { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string Message { get; set; } = null;
|
||||
|
||||
protected bool Equals(FollowedStream other)
|
||||
=> ChannelId == other.ChannelId
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
@ -31,39 +30,38 @@ public sealed class GuildFilterConfigEntityConfiguration : IEntityTypeConfigurat
|
|||
public class GuildConfig : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public string? Prefix { get; set; } = null;
|
||||
|
||||
public bool DeleteMessageOnCommand { get; set; }
|
||||
|
||||
public string AutoAssignRoleIds { get; set; }
|
||||
public bool DeleteMessageOnCommand { get; set; } = false;
|
||||
|
||||
public string? AutoAssignRoleIds { get; set; } = null;
|
||||
public bool VerbosePermissions { get; set; } = true;
|
||||
public string PermissionRole { get; set; }
|
||||
public string? PermissionRole { get; set; } = null;
|
||||
|
||||
//filtering
|
||||
public string MuteRoleName { get; set; }
|
||||
public string? MuteRoleName { get; set; } = null;
|
||||
|
||||
// chatterbot
|
||||
public bool CleverbotEnabled { get; set; }
|
||||
public bool CleverbotEnabled { get; set; } = false;
|
||||
|
||||
// aliases
|
||||
public bool WarningsInitialized { get; set; }
|
||||
public bool WarningsInitialized { get; set; } = false;
|
||||
|
||||
public ulong? GameVoiceChannel { get; set; }
|
||||
public ulong? GameVoiceChannel { get; set; } = null;
|
||||
public bool VerboseErrors { get; set; } = true;
|
||||
|
||||
|
||||
public bool NotifyStreamOffline { get; set; }
|
||||
public bool DeleteStreamOnlineMessage { get; set; }
|
||||
public int WarnExpireHours { get; set; }
|
||||
public bool NotifyStreamOffline { get; set; } = true;
|
||||
public bool DeleteStreamOnlineMessage { get; set; } = false;
|
||||
public int WarnExpireHours { get; set; } = 0;
|
||||
public WarnExpireAction WarnExpireAction { get; set; } = WarnExpireAction.Clear;
|
||||
|
||||
public bool DisableGlobalExpressions { get; set; } = false;
|
||||
|
||||
public bool StickyRoles { get; set; }
|
||||
|
||||
public string TimeZoneId { get; set; }
|
||||
public string Locale { get; set; }
|
||||
public bool StickyRoles { get; set; } = false;
|
||||
|
||||
public string? TimeZoneId { get; set; } = null;
|
||||
public string? Locale { get; set; } = null;
|
||||
|
||||
public List<Permissionv2> Permissions { get; set; } = [];
|
||||
}
|
|
@ -21,4 +21,6 @@ public enum NotifyType
|
|||
Protection = 1, Prot = 1,
|
||||
AddRoleReward = 2,
|
||||
RemoveRoleReward = 3,
|
||||
NiceCatch = 4,
|
||||
// BigWin = 4,
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using LinqToDB.Mapping;
|
||||
using DataType = LinqToDB.DataType;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
@ -9,11 +11,7 @@ public class AntiAltSetting
|
|||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public TimeSpan MinAge { get; set; }
|
||||
public PunishmentAction Action { get; set; }
|
||||
public int ActionDurationMinutes { get; set; }
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace EllieBot.Db.Models;
|
|||
#nullable disable
|
||||
public class AntiSpamSetting : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public PunishmentAction Action { get; set; }
|
||||
|
|
|
@ -9,7 +9,8 @@ public class ClubInfo : DbEntity
|
|||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ImageUrl { get; set; } = string.Empty;
|
||||
|
||||
public string BannerUrl { get; set; } = string.Empty;
|
||||
|
||||
public int Xp { get; set; } = 0;
|
||||
public int? OwnerId { get; set; }
|
||||
public DiscordUser Owner { get; set; }
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class ExcludedItem : DbEntity
|
||||
{
|
||||
public int? XpSettingsId { get; set; }
|
||||
public ulong ItemId { get; set; }
|
||||
public ExcludedItemType ItemType { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
=> ItemId.GetHashCode() ^ ItemType.GetHashCode();
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is ExcludedItem ei && ei.ItemId == ItemId && ei.ItemType == ItemType;
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
namespace EllieBot.Db.Models;
|
||||
|
||||
public enum ExcludedItemType { Channel, Role }
|
||||
public enum XpExcludedItemType
|
||||
{
|
||||
User,
|
||||
Role
|
||||
}
|
31
src/EllieBot/Db/Models/xp/XpExcludedItem.cs
Normal file
31
src/EllieBot/Db/Models/xp/XpExcludedItem.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class XpExcludedItem
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public XpExcludedItemType ItemType { get; set; }
|
||||
public ulong ItemId { get; set; }
|
||||
}
|
||||
|
||||
public sealed class XpExclusionEntityConfig : IEntityTypeConfiguration<XpExcludedItem>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<XpExcludedItem> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId);
|
||||
|
||||
builder.HasAlternateKey(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ItemType,
|
||||
x.ItemId
|
||||
});
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<Version>6.0.2</Version>
|
||||
<Version>6.1.5</Version>
|
||||
|
||||
<!-- Output/build -->
|
||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||
|
@ -25,7 +25,7 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="Discord.Net" Version="3.17.1" />
|
||||
<PackageReference Include="Discord.Net" Version="3.17.2" />
|
||||
<PackageReference Include="CoreCLR-NCalc" Version="3.1.253" />
|
||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.68.0.3653" />
|
||||
|
@ -34,7 +34,7 @@
|
|||
<PackageReference Include="Google.Protobuf" Version="3.29.3" />
|
||||
<PackageReference Include="Grpc" Version="2.46.6" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.67.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.69.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.68.1" PrivateAssets="All" />
|
||||
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
|||
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
|
||||
|
||||
<PackageReference Include="SixLabors.Fonts" Version="2.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" />
|
||||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
|
||||
|
@ -124,6 +124,9 @@
|
|||
<Link>_common\CoordinatorProtos\coordinator.proto</Link>
|
||||
<GrpcServices>Client</GrpcServices>
|
||||
</Protobuf>
|
||||
<Protobuf Include="../EllieBot.VotesApi/Protos/*.proto">
|
||||
<GrpcServices>Server</GrpcServices>
|
||||
</Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'GlobalEllie' ">
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Canti/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cbtnrole/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cclub/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Ccurrency/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cexpr/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cfilter/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cgiveaway/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cncanvas/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cpunish/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Croles/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cslowmode/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Csupport/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Ctodo/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cuntimer/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=db_005Cmodels_005Cxp/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cadministration_005Cnotify_005Cmodels/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,16 @@
|
|||
START TRANSACTION;
|
||||
CREATE TABLE userrole (
|
||||
guildid numeric(20,0) NOT NULL,
|
||||
userid numeric(20,0) NOT NULL,
|
||||
roleid numeric(20,0) NOT NULL,
|
||||
CONSTRAINT pk_userrole PRIMARY KEY (guildid, userid, roleid)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_userrole_guildid ON userrole (guildid);
|
||||
|
||||
CREATE INDEX ix_userrole_guildid_userid ON userrole (guildid, userid);
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250310101121_userroles', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,7 @@
|
|||
START TRANSACTION;
|
||||
ALTER TABLE clubs ADD bannerurl text;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250310143026_club-banners', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,9 @@
|
|||
START TRANSACTION;
|
||||
ALTER TABLE discorduser DROP COLUMN notifyonlevelup;
|
||||
|
||||
ALTER TABLE followedstream ADD prettyname text;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250315193825_fs-prettyname', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,9 @@
|
|||
START TRANSACTION;
|
||||
ALTER TABLE antispamsetting DROP COLUMN guildconfigid;
|
||||
|
||||
ALTER TABLE antialtsetting DROP COLUMN guildconfigid;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250315225518_prot-delete-gcid', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,23 @@
|
|||
START TRANSACTION;
|
||||
CREATE TABLE scheduledcommand (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY,
|
||||
userid numeric(20,0) NOT NULL,
|
||||
channelid numeric(20,0) NOT NULL,
|
||||
guildid numeric(20,0) NOT NULL,
|
||||
messageid numeric(20,0) NOT NULL,
|
||||
text text NOT NULL,
|
||||
"when" timestamp without time zone NOT NULL,
|
||||
CONSTRAINT pk_scheduledcommand PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_scheduledcommand_guildid ON scheduledcommand (guildid);
|
||||
|
||||
CREATE INDEX ix_scheduledcommand_userid ON scheduledcommand (userid);
|
||||
|
||||
CREATE INDEX ix_scheduledcommand_when ON scheduledcommand ("when");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250317063129_scheduled-commands', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
START TRANSACTION;
|
||||
CREATE TABLE xpexcludeditem (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY,
|
||||
guildid numeric(20,0) NOT NULL,
|
||||
itemtype integer NOT NULL,
|
||||
itemid numeric(20,0) NOT NULL,
|
||||
CONSTRAINT pk_xpexcludeditem PRIMARY KEY (id),
|
||||
CONSTRAINT ak_xpexcludeditem_guildid_itemtype_itemid UNIQUE (guildid, itemtype, itemid)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_xpexcludeditem_guildid ON xpexcludeditem (guildid);
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250318221943_xpexclusion', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
START TRANSACTION;
|
||||
CREATE TABLE livechannelconfig (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY,
|
||||
guildid numeric(20,0) NOT NULL,
|
||||
channelid numeric(20,0) NOT NULL,
|
||||
template text NOT NULL,
|
||||
CONSTRAINT pk_livechannelconfig PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_livechannelconfig_guildid ON livechannelconfig (guildid);
|
||||
|
||||
CREATE UNIQUE INDEX ix_livechannelconfig_guildid_channelid ON livechannelconfig (guildid, channelid);
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250319010757_livechannels', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
START TRANSACTION;
|
||||
CREATE TABLE linkfix (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY,
|
||||
guildid numeric(20,0) NOT NULL,
|
||||
olddomain text NOT NULL,
|
||||
newdomain text NOT NULL,
|
||||
CONSTRAINT pk_linkfix PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX ix_linkfix_guildid_olddomain ON linkfix (guildid, olddomain);
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250323021916_linkfixer', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
20
src/EllieBot/Migrations/PostgreSql/20250324230804_quests.sql
Normal file
20
src/EllieBot/Migrations/PostgreSql/20250324230804_quests.sql
Normal file
|
@ -0,0 +1,20 @@
|
|||
START TRANSACTION;
|
||||
CREATE TABLE userquest (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY,
|
||||
questnumber integer NOT NULL,
|
||||
userid numeric(20,0) NOT NULL,
|
||||
questid integer NOT NULL,
|
||||
progress bigint NOT NULL,
|
||||
iscompleted boolean NOT NULL,
|
||||
dateassigned timestamp without time zone NOT NULL,
|
||||
CONSTRAINT pk_userquest PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_userquest_userid ON userquest (userid);
|
||||
|
||||
CREATE UNIQUE INDEX ix_userquest_userid_questnumber_dateassigned ON userquest (userid, questnumber, dateassigned);
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250324230804_quests', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,25 @@
|
|||
START TRANSACTION;
|
||||
ALTER TABLE userfishstats DROP COLUMN bait;
|
||||
|
||||
ALTER TABLE userfishstats DROP COLUMN pole;
|
||||
|
||||
ALTER TABLE userquest ALTER COLUMN progress TYPE integer;
|
||||
|
||||
CREATE TABLE userfishitem (
|
||||
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY,
|
||||
userid numeric(20,0) NOT NULL,
|
||||
itemtype integer NOT NULL,
|
||||
itemid integer NOT NULL,
|
||||
isequipped boolean NOT NULL,
|
||||
usesleft integer,
|
||||
expiresat timestamp without time zone,
|
||||
CONSTRAINT pk_userfishitem PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_userfishitem_userid ON userfishitem (userid);
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" (migrationid, productversion)
|
||||
VALUES ('20250327001838_fishitems', '9.0.1');
|
||||
|
||||
COMMIT;
|
4267
src/EllieBot/Migrations/PostgreSql/20250327001912_init.Designer.cs
generated
Normal file
4267
src/EllieBot/Migrations/PostgreSql/20250327001912_init.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,6 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
guildconfigid = table.Column<int>(type: "integer", nullable: false),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
minage = table.Column<TimeSpan>(type: "interval", nullable: false),
|
||||
action = table.Column<int>(type: "integer", nullable: false),
|
||||
|
@ -54,7 +53,6 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
guildconfigid = table.Column<int>(type: "integer", nullable: false),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
action = table.Column<int>(type: "integer", nullable: false),
|
||||
messagethreshold = table.Column<int>(type: "integer", nullable: false),
|
||||
|
@ -367,6 +365,7 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
username = table.Column<string>(type: "text", nullable: true),
|
||||
prettyname = table.Column<string>(type: "text", nullable: true),
|
||||
type = table.Column<int>(type: "integer", nullable: false),
|
||||
message = table.Column<string>(type: "text", nullable: true)
|
||||
},
|
||||
|
@ -551,6 +550,36 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
table.PrimaryKey("pk_imageonlychannels", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "linkfix",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
olddomain = table.Column<string>(type: "text", nullable: false),
|
||||
newdomain = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_linkfix", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "livechannelconfig",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
template = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_livechannelconfig", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "logsettings",
|
||||
columns: table => new
|
||||
|
@ -856,6 +885,24 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
table.UniqueConstraint("ak_sargroup_guildid_groupnumber", x => new { x.guildid, x.groupnumber });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "scheduledcommand",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
messageid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
text = table.Column<string>(type: "text", nullable: false),
|
||||
when = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_scheduledcommand", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "shopentry",
|
||||
columns: table => new
|
||||
|
@ -1062,6 +1109,24 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
table.PrimaryKey("pk_userbetstats", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "userfishitem",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
itemtype = table.Column<int>(type: "integer", nullable: false),
|
||||
itemid = table.Column<int>(type: "integer", nullable: false),
|
||||
isequipped = table.Column<bool>(type: "boolean", nullable: false),
|
||||
usesleft = table.Column<int>(type: "integer", nullable: true),
|
||||
expiresat = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_userfishitem", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "userfishstats",
|
||||
columns: table => new
|
||||
|
@ -1069,15 +1134,44 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
skill = table.Column<int>(type: "integer", nullable: false),
|
||||
pole = table.Column<int>(type: "integer", nullable: true),
|
||||
bait = table.Column<int>(type: "integer", nullable: true)
|
||||
skill = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_userfishstats", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "userquest",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
questnumber = table.Column<int>(type: "integer", nullable: false),
|
||||
userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
questid = table.Column<int>(type: "integer", nullable: false),
|
||||
progress = table.Column<int>(type: "integer", nullable: false),
|
||||
iscompleted = table.Column<bool>(type: "boolean", nullable: false),
|
||||
dateassigned = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_userquest", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "userrole",
|
||||
columns: table => new
|
||||
{
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
userid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
roleid = table.Column<decimal>(type: "numeric(20,0)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_userrole", x => new { x.guildid, x.userid, x.roleid });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "userxpstats",
|
||||
columns: table => new
|
||||
|
@ -1149,6 +1243,22 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
table.PrimaryKey("pk_warnings", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "xpexcludeditem",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
itemtype = table.Column<int>(type: "integer", nullable: false),
|
||||
itemid = table.Column<decimal>(type: "numeric(20,0)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_xpexcludeditem", x => x.id);
|
||||
table.UniqueConstraint("ak_xpexcludeditem_guildid_itemtype_itemid", x => new { x.guildid, x.itemtype, x.itemid });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "xpsettings",
|
||||
columns: table => new
|
||||
|
@ -1588,6 +1698,7 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
name = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
|
||||
description = table.Column<string>(type: "text", nullable: true),
|
||||
imageurl = table.Column<string>(type: "text", nullable: true),
|
||||
bannerurl = table.Column<string>(type: "text", nullable: true),
|
||||
xp = table.Column<int>(type: "integer", nullable: false),
|
||||
ownerid = table.Column<int>(type: "integer", nullable: true),
|
||||
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
|
@ -1609,7 +1720,6 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
clubid = table.Column<int>(type: "integer", nullable: true),
|
||||
isclubadmin = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
||||
totalxp = table.Column<long>(type: "bigint", nullable: false, defaultValue: 0L),
|
||||
notifyonlevelup = table.Column<int>(type: "integer", nullable: false, defaultValue: 0),
|
||||
currencyamount = table.Column<long>(type: "bigint", nullable: false, defaultValue: 0L),
|
||||
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
},
|
||||
|
@ -1938,6 +2048,23 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
column: "channelid",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_linkfix_guildid_olddomain",
|
||||
table: "linkfix",
|
||||
columns: new[] { "guildid", "olddomain" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_livechannelconfig_guildid",
|
||||
table: "livechannelconfig",
|
||||
column: "guildid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_livechannelconfig_guildid_channelid",
|
||||
table: "livechannelconfig",
|
||||
columns: new[] { "guildid", "channelid" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_logsettings_guildid",
|
||||
table: "logsettings",
|
||||
|
@ -2036,6 +2163,21 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
column: "guildid",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_scheduledcommand_guildid",
|
||||
table: "scheduledcommand",
|
||||
column: "guildid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_scheduledcommand_userid",
|
||||
table: "scheduledcommand",
|
||||
column: "userid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_scheduledcommand_when",
|
||||
table: "scheduledcommand",
|
||||
column: "when");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_shopentry_guildid_index",
|
||||
table: "shopentry",
|
||||
|
@ -2125,12 +2267,38 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
columns: new[] { "userid", "game" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userfishitem_userid",
|
||||
table: "userfishitem",
|
||||
column: "userid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userfishstats_userid",
|
||||
table: "userfishstats",
|
||||
column: "userid",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userquest_userid",
|
||||
table: "userquest",
|
||||
column: "userid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userquest_userid_questnumber_dateassigned",
|
||||
table: "userquest",
|
||||
columns: new[] { "userid", "questnumber", "dateassigned" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userrole_guildid",
|
||||
table: "userrole",
|
||||
column: "guildid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userrole_guildid_userid",
|
||||
table: "userrole",
|
||||
columns: new[] { "guildid", "userid" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_userxpstats_guildid",
|
||||
table: "userxpstats",
|
||||
|
@ -2225,6 +2393,11 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
table: "xpcurrencyreward",
|
||||
column: "xpsettingsid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_xpexcludeditem_guildid",
|
||||
table: "xpexcludeditem",
|
||||
column: "guildid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_xprolereward_xpsettingsid_level",
|
||||
table: "xprolereward",
|
||||
|
@ -2399,6 +2572,12 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
migrationBuilder.DropTable(
|
||||
name: "imageonlychannels");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "linkfix");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "livechannelconfig");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "musicplayersettings");
|
||||
|
||||
|
@ -2450,6 +2629,9 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
migrationBuilder.DropTable(
|
||||
name: "sarautodelete");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "scheduledcommand");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "shopentryitem");
|
||||
|
||||
|
@ -2489,9 +2671,18 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
migrationBuilder.DropTable(
|
||||
name: "userbetstats");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "userfishitem");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "userfishstats");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "userquest");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "userrole");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "userxpstats");
|
||||
|
||||
|
@ -2513,6 +2704,9 @@ namespace EllieBot.Migrations.PostgreSql
|
|||
migrationBuilder.DropTable(
|
||||
name: "xpcurrencyreward");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "xpexcludeditem");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "xprolereward");
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
BEGIN TRANSACTION;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
DROP INDEX "IX_XpSettings_GuildConfigId";
|
||||
|
||||
|
@ -142,7 +142,8 @@ DELETE FROM VcRoleInfo WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELE
|
|||
UPDATE VcRoleInfo
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = VcRoleInfo.GuildConfigId);
|
||||
|
||||
DELETE FROM UnroleTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
|
||||
DELETE FROM UnroleTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs)
|
||||
OR (GuildId, UserId) IN (SELECT GuildId, UserId FROM UnroleTimer GROUP BY GuildId, UserId HAVING COUNT(*) > 1);
|
||||
UPDATE UnroleTimer
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnroleTimer.GuildConfigId);
|
||||
|
||||
|
@ -170,7 +171,8 @@ DELETE FROM Permissions WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SEL
|
|||
UPDATE Permissions
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = Permissions.GuildConfigId);
|
||||
|
||||
DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
|
||||
DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs)
|
||||
OR (GuildId, UserId) IN (SELECT GuildId, UserId FROM MutedUserId GROUP BY GuildId, UserId HAVING COUNT(*) > 1);
|
||||
UPDATE MutedUserId
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = MutedUserId.GuildConfigId);
|
||||
|
||||
|
@ -761,4 +763,3 @@ INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
|||
VALUES ('20250126062816_cleanup', '8.0.8');
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
16
src/EllieBot/Migrations/Sqlite/20250310101118_userroles.sql
Normal file
16
src/EllieBot/Migrations/Sqlite/20250310101118_userroles.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "UserRole" (
|
||||
"GuildId" INTEGER NOT NULL,
|
||||
"UserId" INTEGER NOT NULL,
|
||||
"RoleId" INTEGER NOT NULL,
|
||||
CONSTRAINT "PK_UserRole" PRIMARY KEY ("GuildId", "UserId", "RoleId")
|
||||
);
|
||||
|
||||
CREATE INDEX "IX_UserRole_GuildId" ON "UserRole" ("GuildId");
|
||||
|
||||
CREATE INDEX "IX_UserRole_GuildId_UserId" ON "UserRole" ("GuildId", "UserId");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250310101118_userroles', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,7 @@
|
|||
BEGIN TRANSACTION;
|
||||
ALTER TABLE "Clubs" ADD "BannerUrl" TEXT NULL;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250310143023_club-banners', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,9 @@
|
|||
BEGIN TRANSACTION;
|
||||
ALTER TABLE discorduser DROP COLUMN notifyonlevelup;
|
||||
|
||||
ALTER TABLE "FollowedStream" ADD "PrettyName" TEXT NULL;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250315193822_fs-prettyname', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,9 @@
|
|||
BEGIN TRANSACTION;
|
||||
ALTER TABLE "AntiSpamSetting" DROP COLUMN "GuildConfigId";
|
||||
|
||||
ALTER TABLE "AntiAltSetting" DROP COLUMN "GuildConfigId";
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250315225515_prot-delete-gcid', '9.0.1');
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,22 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "ScheduledCommand" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_ScheduledCommand" PRIMARY KEY AUTOINCREMENT,
|
||||
"UserId" INTEGER NOT NULL,
|
||||
"ChannelId" INTEGER NOT NULL,
|
||||
"GuildId" INTEGER NOT NULL,
|
||||
"MessageId" INTEGER NOT NULL,
|
||||
"Text" TEXT NOT NULL,
|
||||
"When" TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX "IX_ScheduledCommand_GuildId" ON "ScheduledCommand" ("GuildId");
|
||||
|
||||
CREATE INDEX "IX_ScheduledCommand_UserId" ON "ScheduledCommand" ("UserId");
|
||||
|
||||
CREATE INDEX "IX_ScheduledCommand_When" ON "ScheduledCommand" ("When");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250317063119_scheduled-commands', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "XpExcludedItem" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_XpExcludedItem" PRIMARY KEY AUTOINCREMENT,
|
||||
"GuildId" INTEGER NOT NULL,
|
||||
"ItemType" INTEGER NOT NULL,
|
||||
"ItemId" INTEGER NOT NULL,
|
||||
CONSTRAINT "AK_XpExcludedItem_GuildId_ItemType_ItemId" UNIQUE ("GuildId", "ItemType", "ItemId")
|
||||
);
|
||||
|
||||
CREATE INDEX "IX_XpExcludedItem_GuildId" ON "XpExcludedItem" ("GuildId");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250318221922_xpexclusion', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "LiveChannelConfig" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_LiveChannelConfig" PRIMARY KEY AUTOINCREMENT,
|
||||
"GuildId" INTEGER NOT NULL,
|
||||
"ChannelId" INTEGER NOT NULL,
|
||||
"Template" TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX "IX_LiveChannelConfig_GuildId" ON "LiveChannelConfig" ("GuildId");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_LiveChannelConfig_GuildId_ChannelId" ON "LiveChannelConfig" ("GuildId", "ChannelId");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250319010745_livechannels', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
15
src/EllieBot/Migrations/Sqlite/20250323021857_linkfixer.sql
Normal file
15
src/EllieBot/Migrations/Sqlite/20250323021857_linkfixer.sql
Normal file
|
@ -0,0 +1,15 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "LinkFix" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_LinkFix" PRIMARY KEY AUTOINCREMENT,
|
||||
"GuildId" INTEGER NOT NULL,
|
||||
"OldDomain" TEXT NOT NULL,
|
||||
"NewDomain" TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX "IX_LinkFix_GuildId_OldDomain" ON "LinkFix" ("GuildId", "OldDomain");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250323021857_linkfixer', '9.0.1');
|
||||
|
||||
COMMIT;
|
||||
|
19
src/EllieBot/Migrations/Sqlite/20250324230801_quests.sql
Normal file
19
src/EllieBot/Migrations/Sqlite/20250324230801_quests.sql
Normal file
|
@ -0,0 +1,19 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "UserQuest" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_UserQuest" PRIMARY KEY AUTOINCREMENT,
|
||||
"QuestNumber" INTEGER NOT NULL,
|
||||
"UserId" INTEGER NOT NULL,
|
||||
"QuestId" INTEGER NOT NULL,
|
||||
"Progress" INTEGER NOT NULL,
|
||||
"IsCompleted" INTEGER NOT NULL,
|
||||
"DateAssigned" TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX "IX_UserQuest_UserId" ON "UserQuest" ("UserId");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_UserQuest_UserId_QuestNumber_DateAssigned" ON "UserQuest" ("UserId", "QuestNumber", "DateAssigned");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250324230801_quests', '9.0.1');
|
||||
|
||||
COMMIT;
|
43
src/EllieBot/Migrations/Sqlite/20250327001835_fishitems.sql
Normal file
43
src/EllieBot/Migrations/Sqlite/20250327001835_fishitems.sql
Normal file
|
@ -0,0 +1,43 @@
|
|||
BEGIN TRANSACTION;
|
||||
CREATE TABLE "UserFishItem" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_UserFishItem" PRIMARY KEY AUTOINCREMENT,
|
||||
"UserId" INTEGER NOT NULL,
|
||||
"ItemType" INTEGER NOT NULL,
|
||||
"ItemId" INTEGER NOT NULL,
|
||||
"IsEquipped" INTEGER NOT NULL,
|
||||
"UsesLeft" INTEGER NULL,
|
||||
"ExpiresAt" TEXT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX "IX_UserFishItem_UserId" ON "UserFishItem" ("UserId");
|
||||
|
||||
CREATE TABLE "ef_temp_UserFishStats" (
|
||||
"Id" INTEGER NOT NULL CONSTRAINT "PK_UserFishStats" PRIMARY KEY AUTOINCREMENT,
|
||||
"Skill" INTEGER NOT NULL,
|
||||
"UserId" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO "ef_temp_UserFishStats" ("Id", "Skill", "UserId")
|
||||
SELECT "Id", "Skill", "UserId"
|
||||
FROM "UserFishStats";
|
||||
|
||||
COMMIT;
|
||||
|
||||
PRAGMA foreign_keys = 0;
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
DROP TABLE "UserFishStats";
|
||||
|
||||
ALTER TABLE "ef_temp_UserFishStats" RENAME TO "UserFishStats";
|
||||
|
||||
COMMIT;
|
||||
|
||||
PRAGMA foreign_keys = 1;
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
CREATE UNIQUE INDEX "IX_UserFishStats_UserId" ON "UserFishStats" ("UserId");
|
||||
|
||||
COMMIT;
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20250327001835_fishitems', '9.0.1');
|
3243
src/EllieBot/Migrations/Sqlite/20250327001909_init.Designer.cs
generated
Normal file
3243
src/EllieBot/Migrations/Sqlite/20250327001909_init.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,6 @@ namespace EllieBot.Migrations.Sqlite
|
|||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
MinAge = table.Column<TimeSpan>(type: "TEXT", nullable: false),
|
||||
Action = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
|
@ -53,7 +52,6 @@ namespace EllieBot.Migrations.Sqlite
|
|||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
Action = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
MessageThreshold = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
|
@ -366,6 +364,7 @@ namespace EllieBot.Migrations.Sqlite
|
|||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
Username = table.Column<string>(type: "TEXT", nullable: true),
|
||||
PrettyName = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Type = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Message = table.Column<string>(type: "TEXT", nullable: true)
|
||||
},
|
||||
|
@ -551,6 +550,36 @@ namespace EllieBot.Migrations.Sqlite
|
|||
table.PrimaryKey("PK_ImageOnlyChannels", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LinkFix",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
OldDomain = table.Column<string>(type: "TEXT", nullable: false),
|
||||
NewDomain = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LinkFix", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LiveChannelConfig",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
Template = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LiveChannelConfig", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LogSettings",
|
||||
columns: table => new
|
||||
|
@ -858,6 +887,24 @@ namespace EllieBot.Migrations.Sqlite
|
|||
table.UniqueConstraint("AK_SarGroup_GuildId_GroupNumber", x => new { x.GuildId, x.GroupNumber });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ScheduledCommand",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
MessageId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
Text = table.Column<string>(type: "TEXT", nullable: false),
|
||||
When = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ScheduledCommand", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopEntry",
|
||||
columns: table => new
|
||||
|
@ -1064,6 +1111,24 @@ namespace EllieBot.Migrations.Sqlite
|
|||
table.PrimaryKey("PK_UserBetStats", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserFishItem",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
ItemType = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ItemId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
IsEquipped = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
UsesLeft = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
ExpiresAt = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserFishItem", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserFishStats",
|
||||
columns: table => new
|
||||
|
@ -1071,15 +1136,44 @@ namespace EllieBot.Migrations.Sqlite
|
|||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
Skill = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Pole = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
Bait = table.Column<int>(type: "INTEGER", nullable: true)
|
||||
Skill = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserFishStats", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserQuest",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
QuestNumber = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
QuestId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Progress = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
IsCompleted = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
DateAssigned = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserQuest", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserRole",
|
||||
columns: table => new
|
||||
{
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
RoleId = table.Column<ulong>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserRole", x => new { x.GuildId, x.UserId, x.RoleId });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserXpStats",
|
||||
columns: table => new
|
||||
|
@ -1151,6 +1245,22 @@ namespace EllieBot.Migrations.Sqlite
|
|||
table.PrimaryKey("PK_Warnings", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "XpExcludedItem",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
ItemType = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ItemId = table.Column<ulong>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_XpExcludedItem", x => x.Id);
|
||||
table.UniqueConstraint("AK_XpExcludedItem_GuildId_ItemType_ItemId", x => new { x.GuildId, x.ItemType, x.ItemId });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "XpSettings",
|
||||
columns: table => new
|
||||
|
@ -1590,6 +1700,7 @@ namespace EllieBot.Migrations.Sqlite
|
|||
Name = table.Column<string>(type: "TEXT", maxLength: 20, nullable: true),
|
||||
Description = table.Column<string>(type: "TEXT", nullable: true),
|
||||
ImageUrl = table.Column<string>(type: "TEXT", nullable: true),
|
||||
BannerUrl = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Xp = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
OwnerId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||
|
@ -1611,7 +1722,6 @@ namespace EllieBot.Migrations.Sqlite
|
|||
ClubId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
IsClubAdmin = table.Column<bool>(type: "INTEGER", nullable: false, defaultValue: false),
|
||||
TotalXp = table.Column<long>(type: "INTEGER", nullable: false, defaultValue: 0L),
|
||||
NotifyOnLevelUp = table.Column<int>(type: "INTEGER", nullable: false, defaultValue: 0),
|
||||
CurrencyAmount = table.Column<long>(type: "INTEGER", nullable: false, defaultValue: 0L),
|
||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||
},
|
||||
|
@ -1940,6 +2050,23 @@ namespace EllieBot.Migrations.Sqlite
|
|||
column: "ChannelId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LinkFix_GuildId_OldDomain",
|
||||
table: "LinkFix",
|
||||
columns: new[] { "GuildId", "OldDomain" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LiveChannelConfig_GuildId",
|
||||
table: "LiveChannelConfig",
|
||||
column: "GuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LiveChannelConfig_GuildId_ChannelId",
|
||||
table: "LiveChannelConfig",
|
||||
columns: new[] { "GuildId", "ChannelId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LogSettings_GuildId",
|
||||
table: "LogSettings",
|
||||
|
@ -2038,6 +2165,21 @@ namespace EllieBot.Migrations.Sqlite
|
|||
column: "GuildId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScheduledCommand_GuildId",
|
||||
table: "ScheduledCommand",
|
||||
column: "GuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScheduledCommand_UserId",
|
||||
table: "ScheduledCommand",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScheduledCommand_When",
|
||||
table: "ScheduledCommand",
|
||||
column: "When");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopEntry_GuildId_Index",
|
||||
table: "ShopEntry",
|
||||
|
@ -2127,12 +2269,38 @@ namespace EllieBot.Migrations.Sqlite
|
|||
columns: new[] { "UserId", "Game" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserFishItem_UserId",
|
||||
table: "UserFishItem",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserFishStats_UserId",
|
||||
table: "UserFishStats",
|
||||
column: "UserId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserQuest_UserId",
|
||||
table: "UserQuest",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserQuest_UserId_QuestNumber_DateAssigned",
|
||||
table: "UserQuest",
|
||||
columns: new[] { "UserId", "QuestNumber", "DateAssigned" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserRole_GuildId",
|
||||
table: "UserRole",
|
||||
column: "GuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserRole_GuildId_UserId",
|
||||
table: "UserRole",
|
||||
columns: new[] { "GuildId", "UserId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserXpStats_GuildId",
|
||||
table: "UserXpStats",
|
||||
|
@ -2227,6 +2395,11 @@ namespace EllieBot.Migrations.Sqlite
|
|||
table: "XpCurrencyReward",
|
||||
column: "XpSettingsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_XpExcludedItem_GuildId",
|
||||
table: "XpExcludedItem",
|
||||
column: "GuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_XpRoleReward_XpSettingsId_Level",
|
||||
table: "XpRoleReward",
|
||||
|
@ -2401,6 +2574,12 @@ namespace EllieBot.Migrations.Sqlite
|
|||
migrationBuilder.DropTable(
|
||||
name: "ImageOnlyChannels");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LinkFix");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LiveChannelConfig");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MusicPlayerSettings");
|
||||
|
||||
|
@ -2452,6 +2631,9 @@ namespace EllieBot.Migrations.Sqlite
|
|||
migrationBuilder.DropTable(
|
||||
name: "SarAutoDelete");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ScheduledCommand");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopEntryItem");
|
||||
|
||||
|
@ -2491,9 +2673,18 @@ namespace EllieBot.Migrations.Sqlite
|
|||
migrationBuilder.DropTable(
|
||||
name: "UserBetStats");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserFishItem");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserFishStats");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserQuest");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserRole");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserXpStats");
|
||||
|
||||
|
@ -2515,6 +2706,9 @@ namespace EllieBot.Migrations.Sqlite
|
|||
migrationBuilder.DropTable(
|
||||
name: "XpCurrencyReward");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "XpExcludedItem");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "XpRoleReward");
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -124,7 +124,7 @@ public partial class Administration : EllieModule<AdministrationService>
|
|||
[Priority(1)]
|
||||
public async Task Delmsgoncmd(Server _ = Server.Server)
|
||||
{
|
||||
var enabled = await _service.ToggleDeleteMessageOnCommand(ctx.Guild.Id);
|
||||
var enabled = await _service.ToggleDelMsgOnCmd(ctx.Guild.Id);
|
||||
if (enabled)
|
||||
{
|
||||
await Response().Confirm(strs.delmsg_on).SendAsync();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EllieBot.Common.ModuleBehaviors;
|
||||
using EllieBot.Db.Models;
|
||||
using EllieBot.Modules.Administration._common.results;
|
||||
|
@ -10,8 +8,8 @@ namespace EllieBot.Modules.Administration;
|
|||
|
||||
public class AdministrationService : IEService, IReadyExecutor
|
||||
{
|
||||
private ConcurrentHashSet<ulong> deleteMessagesOnCommand;
|
||||
private ConcurrentDictionary<ulong, bool> delMsgOnCmdChannels;
|
||||
private ConcurrentHashSet<ulong> _deleteMessagesOnCommand;
|
||||
private ConcurrentDictionary<ulong, bool> _delMsgOnCmdChannels;
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly IReplacementService _repSvc;
|
||||
|
@ -39,31 +37,32 @@ public class AdministrationService : IEService, IReadyExecutor
|
|||
public async Task OnReadyAsync()
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
deleteMessagesOnCommand = new(await uow.GetTable<GuildConfig>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId) && x.DeleteMessageOnCommand)
|
||||
.Select(x => x.GuildId)
|
||||
.ToListAsyncLinqToDB());
|
||||
_deleteMessagesOnCommand = new(await uow.GetTable<GuildConfig>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId) &&
|
||||
x.DeleteMessageOnCommand)
|
||||
.Select(x => x.GuildId)
|
||||
.ToListAsyncLinqToDB());
|
||||
|
||||
delMsgOnCmdChannels = (await uow.GetTable<DelMsgOnCmdChannel>()
|
||||
.Where(x => deleteMessagesOnCommand.Contains(x.GuildId))
|
||||
.ToDictionaryAsyncLinqToDB(x => x.ChannelId, x => x.State))
|
||||
.ToConcurrent();
|
||||
_delMsgOnCmdChannels = (await uow.GetTable<DelMsgOnCmdChannel>()
|
||||
.Where(x => _deleteMessagesOnCommand.Contains(x.GuildId))
|
||||
.ToDictionaryAsyncLinqToDB(x => x.ChannelId, x => x.State))
|
||||
.ToConcurrent();
|
||||
|
||||
_cmdHandler.CommandExecuted += DelMsgOnCmd_Handler;
|
||||
}
|
||||
|
||||
public async Task<(bool DelMsgOnCmd, IEnumerable<DelMsgOnCmdChannel> channels)> GetDelMsgOnCmdData(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var conf = await uow.GetTable<GuildConfig>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.Select(x => x.DeleteMessageOnCommand)
|
||||
.FirstOrDefaultAsyncLinqToDB();
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.Select(x => x.DeleteMessageOnCommand)
|
||||
.FirstOrDefaultAsyncLinqToDB();
|
||||
|
||||
var channels = await uow.GetTable<DelMsgOnCmdChannel>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
return (conf, channels);
|
||||
}
|
||||
|
@ -76,50 +75,50 @@ public class AdministrationService : IEService, IReadyExecutor
|
|||
_ = Task.Run(async () =>
|
||||
{
|
||||
//wat ?!
|
||||
if (delMsgOnCmdChannels.TryGetValue(channel.Id, out var state))
|
||||
if (_delMsgOnCmdChannels.TryGetValue(channel.Id, out var state))
|
||||
{
|
||||
if (state && cmd.Name != "prune" && cmd.Name != "pick")
|
||||
{
|
||||
_logService.AddDeleteIgnore(msg.Id);
|
||||
try
|
||||
{ await msg.DeleteAsync(); }
|
||||
catch { }
|
||||
{
|
||||
await msg.DeleteAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
//if state is false, that means do not do it
|
||||
}
|
||||
else if (deleteMessagesOnCommand.Contains(channel.Guild.Id) && cmd.Name != "prune" && cmd.Name != "pick")
|
||||
else if (_deleteMessagesOnCommand.Contains(channel.Guild.Id) && cmd.Name != "prune" && cmd.Name != "pick")
|
||||
{
|
||||
_logService.AddDeleteIgnore(msg.Id);
|
||||
try
|
||||
{ await msg.DeleteAsync(); }
|
||||
catch { }
|
||||
{
|
||||
await msg.DeleteAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<bool> ToggleDeleteMessageOnCommand(ulong guildId)
|
||||
public async Task<bool> ToggleDelMsgOnCmd(ulong guildId)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var conf = await uow.GetTable<GuildConfig>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.UpdateWithOutputAsync(x => new()
|
||||
{
|
||||
DeleteMessageOnCommand = !x.DeleteMessageOnCommand
|
||||
});
|
||||
var gc = uow.GuildConfigsForId(guildId);
|
||||
gc.DeleteMessageOnCommand = !gc.DeleteMessageOnCommand;
|
||||
|
||||
if (conf.Length == 0)
|
||||
return false;
|
||||
|
||||
var val = conf[0].Inserted.DeleteMessageOnCommand;
|
||||
|
||||
if (val)
|
||||
deleteMessagesOnCommand.Add(guildId);
|
||||
if (gc.DeleteMessageOnCommand)
|
||||
_deleteMessagesOnCommand.Add(guildId);
|
||||
else
|
||||
deleteMessagesOnCommand.TryRemove(guildId);
|
||||
_deleteMessagesOnCommand.TryRemove(guildId);
|
||||
|
||||
return val;
|
||||
await uow.SaveChangesAsync();
|
||||
return gc.DeleteMessageOnCommand;
|
||||
}
|
||||
|
||||
public async Task SetDelMsgOnCmdState(ulong guildId, ulong chId, Administration.State newState)
|
||||
|
@ -151,7 +150,7 @@ public class AdministrationService : IEService, IReadyExecutor
|
|||
}
|
||||
|
||||
old.State = newState == Administration.State.Enable;
|
||||
delMsgOnCmdChannels[chId] = newState == Administration.State.Enable;
|
||||
_delMsgOnCmdChannels[chId] = newState == Administration.State.Enable;
|
||||
}
|
||||
|
||||
await uow.SaveChangesAsync();
|
||||
|
@ -162,11 +161,11 @@ public class AdministrationService : IEService, IReadyExecutor
|
|||
}
|
||||
else if (newState == Administration.State.Enable)
|
||||
{
|
||||
delMsgOnCmdChannels[chId] = true;
|
||||
_delMsgOnCmdChannels[chId] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
delMsgOnCmdChannels.TryRemove(chId, out _);
|
||||
_delMsgOnCmdChannels.TryRemove(chId, out _);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,5 +248,6 @@ public class AdministrationService : IEService, IReadyExecutor
|
|||
return SetServerIconResult.Success;
|
||||
}
|
||||
|
||||
private bool IsValidUri(string img) => !string.IsNullOrWhiteSpace(img) && Uri.IsWellFormedUriString(img, UriKind.Absolute);
|
||||
private bool IsValidUri(string img)
|
||||
=> !string.IsNullOrWhiteSpace(img) && Uri.IsWellFormedUriString(img, UriKind.Absolute);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable disable
|
||||
using System.Net;
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using EllieBot.Common.ModuleBehaviors;
|
||||
|
@ -15,7 +16,12 @@ public enum MuteType
|
|||
|
||||
public class MuteService : IEService, IReadyExecutor
|
||||
{
|
||||
public enum TimerType { Mute, Ban, AddRole }
|
||||
public enum TimerType
|
||||
{
|
||||
Mute,
|
||||
Ban,
|
||||
AddRole
|
||||
}
|
||||
|
||||
private static readonly OverwritePermissions _denyOverwrite = new(addReactions: PermValue.Deny,
|
||||
sendMessages: PermValue.Deny,
|
||||
|
@ -57,12 +63,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
return;
|
||||
|
||||
_ = Task.Run(() => _sender.Response(user)
|
||||
.Embed(_sender.CreateEmbed(user?.GuildId)
|
||||
.WithDescription($"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
.Embed(_sender.CreateEmbed(user?.GuildId)
|
||||
.WithDescription($"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
}
|
||||
|
||||
private void OnUserUnmuted(
|
||||
|
@ -75,12 +81,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
return;
|
||||
|
||||
_ = Task.Run(() => _sender.Response(user)
|
||||
.Embed(_sender.CreateEmbed(user.GuildId)
|
||||
.WithDescription($"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
.Embed(_sender.CreateEmbed(user.GuildId)
|
||||
.WithDescription($"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
}
|
||||
|
||||
private Task Client_UserJoined(IGuildUser usr)
|
||||
|
@ -105,8 +111,8 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
var config = uow.GetTable<GuildConfig>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
config.MuteRoleName = name;
|
||||
_guildMuteRoles.AddOrUpdate(guildId, name, (_, _) => name);
|
||||
await uow.SaveChangesAsync();
|
||||
|
@ -121,8 +127,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
if (type == MuteType.All)
|
||||
{
|
||||
try
|
||||
{ await usr.ModifyAsync(x => x.Mute = true); }
|
||||
catch { }
|
||||
{
|
||||
await usr.ModifyAsync(x => x.Mute = true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
var muteRole = await GetMuteRole(usr.Guild);
|
||||
if (!usr.RoleIds.Contains(muteRole.Id))
|
||||
|
@ -131,19 +141,19 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
await uow.GetTable<MutedUserId>()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
},
|
||||
(_) => new()
|
||||
{
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
});
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
},
|
||||
(_) => new()
|
||||
{
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
});
|
||||
|
||||
if (_mutedUsers.TryGetValue(usr.Guild.Id, out var muted))
|
||||
muted.Add(usr.Id);
|
||||
|
@ -160,7 +170,9 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await usr.ModifyAsync(x => x.Mute = true);
|
||||
UserMuted(usr, mod, MuteType.Voice, reason);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (type == MuteType.Chat)
|
||||
{
|
||||
|
@ -183,12 +195,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
await uow.GetTable<MutedUserId>()
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
|
||||
await uow.GetTable<UnmuteTimer>()
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
|
||||
if (_mutedUsers.TryGetValue(guildId, out var muted))
|
||||
muted.TryRemove(usrId);
|
||||
|
@ -197,11 +209,17 @@ public class MuteService : IEService, IReadyExecutor
|
|||
if (usr is not null)
|
||||
{
|
||||
try
|
||||
{ await usr.ModifyAsync(x => x.Mute = false); }
|
||||
catch { }
|
||||
{
|
||||
await usr.ModifyAsync(x => x.Mute = false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{ await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild)); }
|
||||
{
|
||||
await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild));
|
||||
}
|
||||
catch
|
||||
{
|
||||
/*ignore*/
|
||||
|
@ -231,26 +249,29 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
ArgumentNullException.ThrowIfNull(guild);
|
||||
|
||||
const string defaultMuteRoleName = "nadeko-mute";
|
||||
const string defaultMuteRoleName = "ellie-mute";
|
||||
|
||||
var muteRoleName = _guildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName);
|
||||
|
||||
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName);
|
||||
if (muteRole is null)
|
||||
//if it doesn't exist, create it
|
||||
{
|
||||
try
|
||||
{ muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false); }
|
||||
catch
|
||||
{
|
||||
//if creations fails, maybe the name is not correct, find default one, if doesn't work, create default one
|
||||
muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName)
|
||||
?? await guild.CreateRoleAsync(defaultMuteRoleName, isMentionable: false);
|
||||
muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Unable to create mute role for guild {GuildId}", guild.Id);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var toOverwrite in await guild.GetTextChannelsAsync())
|
||||
{
|
||||
if (toOverwrite is IThreadChannel)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
if (!toOverwrite.PermissionOverwrites.Any(x => x.TargetId == muteRole.Id
|
||||
|
@ -261,9 +282,10 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await Task.Delay(200);
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions)
|
||||
{
|
||||
// ignored
|
||||
Log.Error(ex, "Error in Initializing mute role in guild {GuildId}: {Message}", guild.Id, ex.Message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,12 +304,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
var unmuteAt = DateTime.UtcNow + after;
|
||||
await uow.GetTable<UnmuteTimer>()
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = user.GuildId,
|
||||
UserId = user.Id,
|
||||
UnmuteAt = unmuteAt
|
||||
});
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = user.GuildId,
|
||||
UserId = user.Id,
|
||||
UnmuteAt = unmuteAt
|
||||
});
|
||||
}
|
||||
|
||||
StartUn_Timer(user.GuildId, user.Id, after, TimerType.Mute); // start the timer
|
||||
|
@ -305,12 +327,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
var unbanAt = DateTime.UtcNow + after;
|
||||
await uow.GetTable<UnbanTimer>()
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = guild.Id,
|
||||
UserId = userId,
|
||||
UnbanAt = unbanAt
|
||||
});
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = guild.Id,
|
||||
UserId = userId,
|
||||
UnbanAt = unbanAt
|
||||
});
|
||||
}
|
||||
|
||||
StartUn_Timer(guild.Id, userId, after, TimerType.Ban); // start the timer
|
||||
|
@ -415,83 +437,80 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
var configs = await uow.Set<GuildConfig>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
_guildMuteRoles = configs.Where(c => !string.IsNullOrWhiteSpace(c.MuteRoleName))
|
||||
.ToDictionary(c => c.GuildId, c => c.MuteRoleName)
|
||||
.ToConcurrent();
|
||||
.ToDictionary(c => c.GuildId, c => c.MuteRoleName)
|
||||
.ToConcurrent();
|
||||
|
||||
_mutedUsers = await uow.GetTable<MutedUserId>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB()
|
||||
.Fmap(x => x.GroupBy(x => x.GuildId)
|
||||
.ToDictionary(g => g.Key, g => new ConcurrentHashSet<ulong>(g.Select(x => x.UserId)))
|
||||
.ToConcurrent());
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB()
|
||||
.Fmap(x => x.GroupBy(x => x.GuildId)
|
||||
.ToDictionary(g => g.Key, g => new ConcurrentHashSet<ulong>(g.Select(x => x.UserId)))
|
||||
.ToConcurrent());
|
||||
|
||||
var max = TimeSpan.FromDays(49);
|
||||
|
||||
var unmuteTimers = await uow.GetTable<UnmuteTimer>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
var unbanTimers = await uow.GetTable<UnbanTimer>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
var unroleTimers = await uow.GetTable<UnroleTimer>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
foreach (var conf in configs)
|
||||
foreach (var x in unmuteTimers)
|
||||
{
|
||||
foreach (var x in unmuteTimers)
|
||||
TimeSpan after;
|
||||
if (x.UnmuteAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnmuteAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unmute = x.UnmuteAt - DateTime.UtcNow;
|
||||
after = unmute > max ? max : unmute;
|
||||
}
|
||||
|
||||
StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Mute);
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unmute = x.UnmuteAt - DateTime.UtcNow;
|
||||
after = unmute > max ? max : unmute;
|
||||
}
|
||||
|
||||
foreach (var x in unbanTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
StartUn_Timer(x.GuildId, x.UserId, after, TimerType.Mute);
|
||||
}
|
||||
|
||||
StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Ban);
|
||||
foreach (var x in unbanTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
|
||||
foreach (var x in unroleTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
StartUn_Timer(x.GuildId, x.UserId, after, TimerType.Ban);
|
||||
}
|
||||
|
||||
StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.AddRole, x.RoleId);
|
||||
foreach (var x in unroleTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
|
||||
StartUn_Timer(x.GuildId, x.UserId, after, TimerType.AddRole, x.RoleId);
|
||||
}
|
||||
|
||||
_client.UserJoined += Client_UserJoined;
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// using System.Globalization;
|
||||
// using EllieBot.Db.Models;
|
||||
// using EllieBot.Modules.Administration;
|
||||
//
|
||||
// namespace EllieBot.Modules.Gambling;
|
||||
//
|
||||
// public readonly record struct BigWinNotifyModel(
|
||||
// string GuildName,
|
||||
// ulong ChannelId,
|
||||
// ulong UserId,
|
||||
// string Amount)
|
||||
// : INotifyModel<BigWinNotifyModel>
|
||||
// {
|
||||
// public const string PH_USER = "user";
|
||||
// public const string PH_GUILD = "server";
|
||||
// public const string PH_AMOUNT = "amount";
|
||||
//
|
||||
// public static string KeyName
|
||||
// => "notify.bigwin";
|
||||
//
|
||||
// public static NotifyType NotifyType
|
||||
// => NotifyType.BigWin;
|
||||
//
|
||||
// public static bool SupportsOriginTarget
|
||||
// => true;
|
||||
//
|
||||
// public static IReadOnlyList<NotifyModelPlaceholderData<BigWinNotifyModel>> GetReplacements()
|
||||
// =>
|
||||
// [
|
||||
// new(PH_USER, static (data, g) => g.GetUser(data.UserId)?.ToString() ?? data.UserId.ToString()),
|
||||
// new(PH_AMOUNT, static (data, g) => data.Amount),
|
||||
// new(PH_GUILD, static (data, g) => data.GuildName)
|
||||
// ];
|
||||
//
|
||||
// public bool TryGetChannelId(out ulong channelId)
|
||||
// {
|
||||
// channelId = ChannelId;
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public bool TryGetUserId(out ulong userId)
|
||||
// {
|
||||
// userId = UserId;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
|
@ -0,0 +1,42 @@
|
|||
#nullable disable
|
||||
using EllieBot.Db.Models;
|
||||
using EllieBot.Modules.Games;
|
||||
|
||||
namespace EllieBot.Modules.Administration.Services;
|
||||
|
||||
public record struct NiceCatchNotifyModel(
|
||||
ulong UserId,
|
||||
FishData Fish,
|
||||
string Stars
|
||||
) : INotifyModel<NiceCatchNotifyModel>
|
||||
{
|
||||
public static string KeyName
|
||||
=> "notify.nicecatch";
|
||||
|
||||
public static NotifyType NotifyType
|
||||
=> NotifyType.NiceCatch;
|
||||
|
||||
public const string PH_EMOJI = "fish.emoji";
|
||||
public const string PH_IMAGE = "fish.image";
|
||||
public const string PH_NAME = "fish.name";
|
||||
public const string PH_STARS = "fish.stars";
|
||||
public const string PH_FLUFF = "fish.fluff";
|
||||
|
||||
public bool TryGetUserId(out ulong userId)
|
||||
{
|
||||
userId = UserId;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IReadOnlyList<NotifyModelPlaceholderData<NiceCatchNotifyModel>> GetReplacements()
|
||||
{
|
||||
return
|
||||
[
|
||||
new(PH_EMOJI, static (data, _) => data.Fish.Emoji),
|
||||
new(PH_IMAGE, static (data, _) => data.Fish.Image),
|
||||
new(PH_NAME, static (data, _) => data.Fish.Name),
|
||||
new(PH_STARS, static (data, _) => data.Stars),
|
||||
new(PH_FLUFF, static (data, _) => data.Fish.Fluff),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ public partial class Administration
|
|||
public class NotifyCommands : EllieModule<NotifyService>
|
||||
{
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task Notify()
|
||||
{
|
||||
await Response()
|
||||
|
@ -38,11 +38,12 @@ public partial class Administration
|
|||
NotifyType.Protection => strs.notify_desc_protection,
|
||||
NotifyType.AddRoleReward => strs.notify_desc_addrolerew,
|
||||
NotifyType.RemoveRoleReward => strs.notify_desc_removerolerew,
|
||||
NotifyType.NiceCatch => strs.notify_desc_nicecatch,
|
||||
_ => strs.notify_desc_not_found
|
||||
};
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task Notify(NotifyType nType)
|
||||
{
|
||||
// show msg
|
||||
|
@ -76,12 +77,12 @@ public partial class Administration
|
|||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task Notify(NotifyType nType, [Leftover] string message)
|
||||
=> await NotifyInternalAsync(nType, null, message);
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task Notify(NotifyType nType, IMessageChannel channel, [Leftover] string message)
|
||||
=> await NotifyInternalAsync(nType, channel, message);
|
||||
|
||||
|
@ -89,6 +90,14 @@ public partial class Administration
|
|||
{
|
||||
var result = await _service.EnableAsync(ctx.Guild.Id, channel?.Id, nType, message);
|
||||
|
||||
if(!result)
|
||||
{
|
||||
await Response()
|
||||
.Error(strs.notify_cant_set)
|
||||
.SendAsync();
|
||||
|
||||
return;
|
||||
}
|
||||
var outChannel = channel is null ? "origin" : $"<#{channel.Id}>";
|
||||
await Response()
|
||||
.Confirm(strs.notify_on(outChannel, Format.Bold(nType.ToString())))
|
||||
|
@ -96,7 +105,7 @@ public partial class Administration
|
|||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task NotifyPhs(NotifyType nType)
|
||||
{
|
||||
var data = _service.GetRegisteredModel(nType);
|
||||
|
@ -111,7 +120,7 @@ public partial class Administration
|
|||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task NotifyList(int page = 1)
|
||||
{
|
||||
if (--page < 0)
|
||||
|
@ -139,7 +148,7 @@ public partial class Administration
|
|||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task NotifyClear(NotifyType nType)
|
||||
{
|
||||
await _service.DisableAsync(ctx.Guild.Id, nType);
|
||||
|
|
|
@ -4,6 +4,7 @@ using EllieBot.Common.ModuleBehaviors;
|
|||
using EllieBot.Db.Models;
|
||||
using EllieBot.Generators;
|
||||
using EllieBot.Modules.Administration.Services;
|
||||
using EllieBot.Modules.Gambling;
|
||||
using EllieBot.Modules.Xp.Services;
|
||||
|
||||
namespace EllieBot.Modules.Administration;
|
||||
|
@ -41,12 +42,11 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService
|
|||
RegisterModel<ProtectionNotifyModel>();
|
||||
RegisterModel<AddRoleRewardNotifyModel>();
|
||||
RegisterModel<RemoveRoleRewardNotifyModel>();
|
||||
RegisterModel<NiceCatchNotifyModel>();
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
RegisterModels();
|
||||
|
||||
await using var uow = _db.GetDbContext();
|
||||
_events = (await uow.GetTable<Notify>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId,
|
||||
|
@ -56,9 +56,8 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService
|
|||
.GroupBy(x => x.Type)
|
||||
.ToDictionary(x => x.Key, x => x.ToDictionary(x => x.GuildId).ToConcurrent())
|
||||
.ToConcurrent();
|
||||
|
||||
|
||||
await SubscribeToEvent<LevelUpNotifyModel>();
|
||||
|
||||
RegisterModels();
|
||||
}
|
||||
|
||||
private async Task SubscribeToEvent<T>()
|
||||
|
@ -74,7 +73,7 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService
|
|||
{
|
||||
if (isShardLocal)
|
||||
{
|
||||
await OnEvent(data);
|
||||
_ = Task.Run(async () => await OnEvent(data));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -159,7 +158,15 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService
|
|||
IUser? user = null;
|
||||
if (model.TryGetUserId(out var userId))
|
||||
{
|
||||
user = guild.GetUser(userId) ?? _client.GetUser(userId);
|
||||
try
|
||||
{
|
||||
user = guild.GetUser(userId)
|
||||
?? await _client.GetUserAsync(userId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
|
||||
var rctx = new ReplacementContext(guild: guild, channel: channel, user: user);
|
||||
|
@ -282,7 +289,10 @@ public sealed class NotifyService : IReadyExecutor, INotifySubscriber, IEService
|
|||
var data = new NotifyModelData(T.NotifyType,
|
||||
T.SupportsOriginTarget,
|
||||
T.GetReplacements().Map(x => x.Name));
|
||||
|
||||
_models[T.NotifyType] = data;
|
||||
|
||||
_pubSub.Sub<T>(new(T.KeyName), async (data) => await OnEvent(data));
|
||||
}
|
||||
|
||||
public NotifyModelData GetRegisteredModel(NotifyType nType)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue