Skip to content

Commit

Permalink
Merge branch 'gabber235:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
DevMunky authored Jan 14, 2025
2 parents c6140bd + 0b043af commit 6108832
Show file tree
Hide file tree
Showing 129 changed files with 2,121 additions and 780 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-development-jars-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
modrinth-featured: false
files: |
engine/engine-paper/build/libs/Typewriter.jar
extensions/**/build/libs/*.jar
extensions/**/build/libs/*Extension.jar
name: "Typewriter v${{ steps.vars.outputs.version }} Build"
version: "${{ steps.vars.outputs.version }}"
version-type: "beta"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ plugin/qodana.yaml
code_generator/EntityEyeHeightProperty.kt
code_generator/EntityHeightProperty.kt
code_generator/EntityWidthProperty.kt

# For the moment
/marketplace
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For detailed setup instructions, visit the [Installation Guide](https://docs.typ

### Sponsors

<!-- sponsors --><a href="https://github.com/myiume"><img src="https:&#x2F;&#x2F;github.com&#x2F;myiume.png" width="60px" alt="User avatar: Myiume" /></a><a href="https://github.com/blue-dev00"><img src="https:&#x2F;&#x2F;github.com&#x2F;blue-dev00.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/JesusRuescas"><img src="https:&#x2F;&#x2F;github.com&#x2F;JesusRuescas.png" width="60px" alt="User avatar: Jesus Ruescas Junior" /></a><a href="https://github.com/AllayRPG"><img src="https:&#x2F;&#x2F;github.com&#x2F;AllayRPG.png" width="60px" alt="User avatar: Farkaaas" /></a><a href="https://github.com/Provant15"><img src="https:&#x2F;&#x2F;github.com&#x2F;Provant15.png" width="60px" alt="User avatar: Provant" /></a><a href="https://github.com/yumio7"><img src="https:&#x2F;&#x2F;github.com&#x2F;yumio7.png" width="60px" alt="User avatar: Connor Saila" /></a><a href="https://github.com/FaultyFunctions"><img src="https:&#x2F;&#x2F;github.com&#x2F;FaultyFunctions.png" width="60px" alt="User avatar: Faulty" /></a><a href="https://github.com/GigaPlayz108"><img src="https:&#x2F;&#x2F;github.com&#x2F;GigaPlayz108.png" width="60px" alt="User avatar: " /></a><!-- sponsors -->
<!-- sponsors --><a href="https://github.com/myiume"><img src="https:&#x2F;&#x2F;github.com&#x2F;myiume.png" width="60px" alt="User avatar: Myiume" /></a><a href="https://github.com/blue-dev00"><img src="https:&#x2F;&#x2F;github.com&#x2F;blue-dev00.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/AllayRPG"><img src="https:&#x2F;&#x2F;github.com&#x2F;AllayRPG.png" width="60px" alt="User avatar: Farkaaas" /></a><a href="https://github.com/Provant15"><img src="https:&#x2F;&#x2F;github.com&#x2F;Provant15.png" width="60px" alt="User avatar: Provant" /></a><a href="https://github.com/yumio7"><img src="https:&#x2F;&#x2F;github.com&#x2F;yumio7.png" width="60px" alt="User avatar: Connor Saila" /></a><a href="https://github.com/FaultyFunctions"><img src="https:&#x2F;&#x2F;github.com&#x2F;FaultyFunctions.png" width="60px" alt="User avatar: Faulty" /></a><a href="https://github.com/GigaPlayz108"><img src="https:&#x2F;&#x2F;github.com&#x2F;GigaPlayz108.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/iamyellowhead"><img src="https:&#x2F;&#x2F;github.com&#x2F;iamyellowhead.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/5LUMLORD"><img src="https:&#x2F;&#x2F;github.com&#x2F;5LUMLORD.png" width="60px" alt="User avatar: " /></a><!-- sponsors -->

Thanks to the following sponsors for supporting this project. Without their support, this project would not be possible. If you are using Typewriter for your server, and are making money from it, please consider [sponsoring](https://github.com/sponsors/gabber235) the project.

Expand Down
4 changes: 3 additions & 1 deletion app/lib/pages/page_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import "package:typewriter/widgets/components/app/staging.dart";
import "package:typewriter/widgets/components/app/static_entries_list.dart";
import "package:typewriter/widgets/components/app/writers.dart";
import "package:typewriter/widgets/components/general/iconify.dart";
import "package:typewriter/widgets/components/general/identifier.dart";
import "package:typewriter/widgets/components/general/shortcut_label.dart";
import "package:typewriter/widgets/inspector/inspector.dart";

Expand Down Expand Up @@ -105,7 +106,8 @@ class _AppBar extends HookConsumerWidget {
Iconify(pageType?.icon, size: 16),
const SizedBox(width: 8),
Text(ref.watch(currentPageLabelProvider)),
const SizedBox(width: 5),
const SizedBox(width: 20),
Identifier(id: ref.watch(currentPageIdProvider) ?? ""),
const Spacer(),
Writers(writers: ref.watch(_writersProvider)),
const SizedBox(width: 20),
Expand Down
4 changes: 4 additions & 0 deletions app/lib/widgets/components/app/entries_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ List<Entry> graphableEntries(Ref ref) {

return page.entries.where((entry) {
final tags = ref.watch(entryBlueprintTagsProvider(entry.blueprintId));
if (tags.isEmpty) {
// Entries without a blueprint are always shown. So that the user can delete them.
return true;
}
return tags.contains("trigger");
}).toList();
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/widgets/components/app/entry_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ class AddEntrySearchElement extends SearchElement {
// This page can't have the entry, so we need to select/create a new page where we can.

ref.read(searchProvider.notifier).asBuilder()
..pageType(PageType.fromBlueprint(blueprint), canRemove: false)
..pageType(PageType.fromBlueprint(blueprint))
..fetchPage(onSelect: (page) => _createAndNavigate(ref, page, blueprint))
..fetchAddPage(
onAdded: (page) => _createAndNavigate(ref, page, blueprint),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/widgets/components/app/page_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class AddPageFetcher extends SearchFetcher {
}

extension SearchBuilderX on SearchBuilder {
void pageType(PageType type, {bool canRemove = true}) {
void pageType(PageType type, {bool canRemove = false}) {
filter(PageTypeFiler(type, canRemove: canRemove));
}

Expand Down
18 changes: 18 additions & 0 deletions app/lib/widgets/components/general/identifier.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import "package:flutter/material.dart";

class Identifier extends StatelessWidget {
const Identifier({
required this.id,
super.key,
});
final String id;

@override
Widget build(BuildContext context) {
return SelectableText(
id,
style:
Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey),
);
}
}
2 changes: 1 addition & 1 deletion app/lib/widgets/inspector/editors/page_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class PageSelectorEditor extends HookConsumerWidget {

void _select(PassingRef ref, PageType type) {
ref.read(searchProvider.notifier).asBuilder()
..pageType(type, canRemove: false)
..pageType(type)
..fetchPage(onSelect: (page) => _update(ref, page))
..fetchAddPage(onAdded: (page) => _update(ref, page))
..open();
Expand Down
20 changes: 2 additions & 18 deletions app/lib/widgets/inspector/heading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "package:typewriter/models/entry.dart";
import "package:typewriter/models/entry_blueprint.dart";
import "package:typewriter/utils/extensions.dart";
import "package:typewriter/widgets/components/general/admonition.dart";
import "package:typewriter/widgets/components/general/identifier.dart";
import "package:typewriter/widgets/inspector/inspector.dart";
import "package:url_launcher/url_launcher_string.dart";

Expand Down Expand Up @@ -71,7 +72,7 @@ class Heading extends HookConsumerWidget {
alignment: WrapAlignment.start,
children: [
EntryBlueprintDisplay(blueprintId: type, url: url, color: color),
EntryIdentifier(id: id),
Identifier(id: id),
],
),
if (deprecation != null) ...[
Expand Down Expand Up @@ -112,23 +113,6 @@ class Title extends StatelessWidget {
}
}

class EntryIdentifier extends StatelessWidget {
const EntryIdentifier({
required this.id,
super.key,
});
final String id;

@override
Widget build(BuildContext context) {
return SelectableText(
id,
style:
Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey),
);
}
}

class EntryBlueprintDisplay extends HookConsumerWidget {
const EntryBlueprintDisplay({
required this.blueprintId,
Expand Down
3 changes: 2 additions & 1 deletion app/lib/widgets/inspector/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "package:typewriter/utils/extensions.dart";
import "package:typewriter/utils/passing_reference.dart";
import "package:typewriter/widgets/components/app/cinematic_view.dart";
import "package:typewriter/widgets/components/general/context_menu_region.dart";
import "package:typewriter/widgets/components/general/identifier.dart";
import "package:typewriter/widgets/inspector/editors/name.dart";
import "package:typewriter/widgets/inspector/editors/object.dart";
import "package:typewriter/widgets/inspector/heading.dart";
Expand Down Expand Up @@ -188,7 +189,7 @@ class NoBlueprintEntryInspector extends HookConsumerWidget {
url: "",
color: Colors.redAccent,
),
EntryIdentifier(id: entry.id),
Identifier(id: entry.id),
],
),
const SizedBox(height: 12),
Expand Down
1 change: 1 addition & 0 deletions discord_bot/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions discord_bot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hex-literal = "0.4.1"
hmac = "0.12.1"
indoc = "2.0.4"
itertools = "0.12.0"
log = "0.4.22"
once_cell = "1.19.0"
poise = "0.6.1"
rand = "0.8.5"
Expand Down
1 change: 1 addition & 0 deletions discord_bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
RUN /usr/sbin/update-ca-certificates
COPY --from=builder /usr/local/cargo/bin/discord_bot /usr/local/bin/discord_bot
ENV RUST_LOG="discord_bot=debug"
CMD ["discord_bot"]
5 changes: 3 additions & 2 deletions discord_bot/src/clickup/get_task.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{webhook::TaskTag, WinstonError, CLIENT};
use log::warn;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use strum::IntoEnumIterator;
Expand All @@ -23,8 +24,8 @@ pub async fn get_task_from_clickup(task_id: &str) -> Result<Task, WinstonError>
match serde_json::from_str::<Task>(&text) {
Ok(task) => Ok(task),
Err(e) => {
eprintln!("failed to deserialize task: {}", e);
eprintln!("response: {}", text);
warn!("failed to deserialize task: {}", e);
warn!("response: {}", text);
Err(WinstonError::ParseJson(e))
}
}
Expand Down
5 changes: 3 additions & 2 deletions discord_bot/src/clickup/get_tasks.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use log::warn;
use url::Url;

use crate::{WinstonError, CLICKUP_LIST_ID, CLIENT};
Expand Down Expand Up @@ -47,8 +48,8 @@ pub async fn get_tasks(query: TasksQuery) -> Result<TaskListings, WinstonError>
match serde_json::from_str::<TaskListings>(&text) {
Ok(tasks) => Ok(tasks),
Err(e) => {
eprintln!("failed to deserialize task: {}", e);
eprintln!("response: {}", text);
warn!("failed to deserialize task: {}", e);
warn!("response: {}", text);
Err(WinstonError::ParseJson(e))
}
}
Expand Down
4 changes: 3 additions & 1 deletion discord_bot/src/clickup/move_done.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use log::info;

use crate::WinstonError;

use super::{get_tasks, update_task, TaskStatus, TasksQuery, UpdateTask};
Expand All @@ -8,7 +10,7 @@ pub async fn move_done_to_beta() -> Result<(), WinstonError> {
})
.await?;

println!(
info!(
"Moving tasks to beta: {}",
tasks
.tasks
Expand Down
45 changes: 42 additions & 3 deletions discord_bot/src/discord/close_ticket.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use std::fmt::{self, Display, Formatter};

use indoc::formatdoc;
use log::{debug, warn};
use poise::{
serenity_prelude::{
ButtonStyle, CreateButton, CreateEmbed, CreateEmbedFooter, CreateMessage, EditThread,
ForumTag, Mentionable, ReactionType, Timestamp,
ButtonStyle, CacheHttp, ChannelId, CreateButton, CreateEmbed, CreateEmbedFooter,
CreateMessage, EditThread, ForumTag, Http, Mentionable, ReactionType, Timestamp,
},
CreateReply, ReplyHandle,
};

use crate::{check_is_support, webhooks::GetTagId, Context, WinstonError};
use crate::{check_is_support, webhooks::GetTagId, Context, WinstonError, SUPPORT_ROLE_ID};

#[derive(Debug, poise::ChoiceParameter)]
pub enum CloseReason {
Expand Down Expand Up @@ -139,6 +140,10 @@ pub async fn close_ticket(

channel.send_message(&ctx, message).await?;

if let Err(e) = remove_support_members_from_thread(&ctx, channel.id).await {
warn!("Could not remove members from thread: {e}");
}

channel
.edit_thread(
ctx,
Expand All @@ -162,3 +167,37 @@ async fn update_responds(

Ok(())
}

pub async fn remove_support_members_from_thread<C>(
ctx: &C,
channel_id: ChannelId,
) -> Result<(), WinstonError>
where
C: CacheHttp + AsRef<Http>,
{
let channel = channel_id.to_channel(&ctx).await?;
let guild_channel = channel.guild().ok_or(WinstonError::NotAGuildChannel)?;
let guild_id = guild_channel.guild_id;

for thread_member in channel_id.get_thread_members(&ctx).await? {
let member = guild_id.member(&ctx, thread_member.user_id).await?;
if !member
.roles
.iter()
.any(|role_id| *role_id == SUPPORT_ROLE_ID)
{
continue;
}

debug!("Removing member from thread: {}", member);

if let Err(e) = channel_id
.remove_thread_member(&ctx, thread_member.user_id)
.await
{
warn!("Could not remove member from thread: {e}");
}
}

Ok(())
}
7 changes: 6 additions & 1 deletion discord_bot/src/discord/create_task.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
check_is_support,
clickup::{create_task_in_clickup, TaskPriority, TaskSize, TaskType},
Context, WinstonError,
remove_support_members_from_thread, Context, WinstonError,
};
use log::warn;
use poise::{
serenity_prelude::{CreateEmbed, CreateMessage},
CreateReply,
Expand Down Expand Up @@ -79,6 +80,10 @@ pub async fn create_task(
)
.await?;

if let Err(e) = remove_support_members_from_thread(&ctx, channel).await {
warn!("Could not remove members from thread: {e}");
}

Ok(())
}

Expand Down
17 changes: 9 additions & 8 deletions discord_bot/src/discord/task_fixed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_trait::async_trait;
use indoc::formatdoc;
use itertools::Itertools;
use log::warn;
use poise::serenity_prelude::{
ComponentInteraction, Context, EditInteractionResponse, EditMessage, EventHandler,
GuildChannel, Interaction, UserId,
Expand Down Expand Up @@ -29,7 +30,7 @@ impl EventHandler for TaskFixedHandler {
}

if let Err(err) = component.defer_ephemeral(&ctx).await {
eprintln!("Failed to defer ephemeral: {}", err);
warn!("Failed to defer ephemeral: {}", err);
return;
}

Expand All @@ -41,7 +42,7 @@ impl EventHandler for TaskFixedHandler {
"Something whent wrong with the button. It seems to be outdated.",
)
.await;
eprintln!("Invalid custom_id: {}", custom_id);
warn!("Invalid custom_id: {}", custom_id);
return;
}
let task_status = split[1].to_string();
Expand Down Expand Up @@ -71,7 +72,7 @@ impl EventHandler for TaskFixedHandler {
"Something whent wrong with the button. It seems to be outdated.",
)
.await;
eprintln!("Invalid task status: {}", task_status);
warn!("Invalid task status: {}", task_status);
return;
}
};
Expand All @@ -83,7 +84,7 @@ impl EventHandler for TaskFixedHandler {
format!("Failed to mark task as {}: {}", task_status, e),
)
.await;
eprintln!("Failed to mark task as {}: {}", task_status, e);
warn!("Failed to mark task as {}: {}", task_status, e);
return;
}
}
Expand Down Expand Up @@ -197,7 +198,7 @@ pub async fn update_response(
.await;

if let Err(e) = result {
eprintln!("Failed to update response: {}", e);
warn!("Failed to update response: {}", e);
}
}

Expand All @@ -212,7 +213,7 @@ pub async fn check_permissions(
"Something whent wrong with the button. It seems to be outdated.",
)
.await;
eprintln!("No channel found");
warn!("No channel found");
return None;
};

Expand All @@ -223,7 +224,7 @@ pub async fn check_permissions(
"Something whent wrong with the button. It seems to be outdated.",
)
.await;
eprintln!("No guild channel found");
warn!("No guild channel found");
return None;
};

Expand All @@ -234,7 +235,7 @@ pub async fn check_permissions(
"Something whent wrong with the button. It seems to be outdated.",
)
.await;
eprintln!("No owner found for channel: {}", guild_channel.name());
warn!("No owner found for channel: {}", guild_channel.name());
return None;
};

Expand Down
Loading

0 comments on commit 6108832

Please sign in to comment.