mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-01 08:39:31 +01:00
Rename Shutdown Behaviour to Channel Locking
This commit is contained in:
parent
97a2b5edbe
commit
5ccf8f7cb7
@ -27,7 +27,7 @@ import com.discordsrv.api.module.type.Module;
|
||||
import com.discordsrv.common.api.util.ApiInstanceUtil;
|
||||
import com.discordsrv.common.bootstrap.IBootstrap;
|
||||
import com.discordsrv.common.channel.ChannelConfigHelper;
|
||||
import com.discordsrv.common.channel.ChannelShutdownBehaviourModule;
|
||||
import com.discordsrv.common.channel.ChannelLockingModule;
|
||||
import com.discordsrv.common.channel.ChannelUpdaterModule;
|
||||
import com.discordsrv.common.channel.GlobalChannelLookupModule;
|
||||
import com.discordsrv.common.command.game.GameCommandModule;
|
||||
@ -493,7 +493,7 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
||||
placeholderService().addGlobalContext(new GlobalTextHandlingContext(this));
|
||||
|
||||
// Modules
|
||||
registerModule(ChannelShutdownBehaviourModule::new);
|
||||
registerModule(ChannelLockingModule::new);
|
||||
registerModule(ChannelUpdaterModule::new);
|
||||
registerModule(GameCommandModule::new);
|
||||
registerModule(GlobalChannelLookupModule::new);
|
||||
|
@ -20,7 +20,7 @@ package com.discordsrv.common.channel;
|
||||
|
||||
import com.discordsrv.api.discord.api.entity.channel.DiscordThreadChannel;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.config.main.channels.ShutdownBehaviourConfig;
|
||||
import com.discordsrv.common.config.main.channels.ChannelLockingConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||
import com.discordsrv.common.config.main.channels.base.IChannelConfig;
|
||||
import com.discordsrv.common.function.OrDefault;
|
||||
@ -35,9 +35,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class ChannelShutdownBehaviourModule extends AbstractModule<DiscordSRV> {
|
||||
public class ChannelLockingModule extends AbstractModule<DiscordSRV> {
|
||||
|
||||
public ChannelShutdownBehaviourModule(DiscordSRV discordSRV) {
|
||||
public ChannelLockingModule(DiscordSRV discordSRV) {
|
||||
super(discordSRV);
|
||||
}
|
||||
|
||||
@ -49,9 +49,9 @@ public class ChannelShutdownBehaviourModule extends AbstractModule<DiscordSRV> {
|
||||
@Override
|
||||
public void enable() {
|
||||
doForAllChannels((config, channelConfig) -> {
|
||||
OrDefault<ShutdownBehaviourConfig> shutdownConfig = config.map(cfg -> cfg.shutdownBehaviour);
|
||||
OrDefault<ShutdownBehaviourConfig.Channels> channels = shutdownConfig.map(cfg -> cfg.channels);
|
||||
OrDefault<ShutdownBehaviourConfig.Threads> threads = shutdownConfig.map(cfg -> cfg.threads);
|
||||
OrDefault<ChannelLockingConfig> shutdownConfig = config.map(cfg -> cfg.channelLocking);
|
||||
OrDefault<ChannelLockingConfig.Channels> channels = shutdownConfig.map(cfg -> cfg.channels);
|
||||
OrDefault<ChannelLockingConfig.Threads> threads = shutdownConfig.map(cfg -> cfg.threads);
|
||||
|
||||
if (threads.get(cfg -> cfg.unarchive, true)) {
|
||||
discordSRV.discordAPI().findOrCreateThreads(config, channelConfig, __ -> {}, new ArrayList<>(), false);
|
||||
@ -63,9 +63,9 @@ public class ChannelShutdownBehaviourModule extends AbstractModule<DiscordSRV> {
|
||||
@Override
|
||||
public void disable() {
|
||||
doForAllChannels((config, channelConfig) -> {
|
||||
OrDefault<ShutdownBehaviourConfig> shutdownConfig = config.map(cfg -> cfg.shutdownBehaviour);
|
||||
OrDefault<ShutdownBehaviourConfig.Channels> channels = shutdownConfig.map(cfg -> cfg.channels);
|
||||
OrDefault<ShutdownBehaviourConfig.Threads> threads = shutdownConfig.map(cfg -> cfg.threads);
|
||||
OrDefault<ChannelLockingConfig> shutdownConfig = config.map(cfg -> cfg.channelLocking);
|
||||
OrDefault<ChannelLockingConfig.Channels> channels = shutdownConfig.map(cfg -> cfg.channels);
|
||||
OrDefault<ChannelLockingConfig.Threads> threads = shutdownConfig.map(cfg -> cfg.threads);
|
||||
|
||||
if (threads.get(cfg -> cfg.archive, true)) {
|
||||
for (DiscordThreadChannel thread : discordSRV.discordAPI().findThreads(config, channelConfig)) {
|
||||
@ -81,7 +81,7 @@ public class ChannelShutdownBehaviourModule extends AbstractModule<DiscordSRV> {
|
||||
|
||||
private void channelPermissions(
|
||||
IChannelConfig channelConfig,
|
||||
OrDefault<ShutdownBehaviourConfig.Channels> shutdownConfig,
|
||||
OrDefault<ChannelLockingConfig.Channels> shutdownConfig,
|
||||
boolean state
|
||||
) {
|
||||
JDA jda = discordSRV.jda().orElse(null);
|
@ -25,7 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ShutdownBehaviourConfig {
|
||||
public class ChannelLockingConfig {
|
||||
|
||||
public Channels channels = new Channels();
|
||||
public Threads threads = new Threads();
|
@ -53,5 +53,5 @@ public class BaseChannelConfig {
|
||||
public MirroringConfig mirroring = new MirroringConfig();
|
||||
|
||||
@Order(50)
|
||||
public ShutdownBehaviourConfig shutdownBehaviour = new ShutdownBehaviourConfig();
|
||||
public ChannelLockingConfig channelLocking = new ChannelLockingConfig();
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
ThreadConfig threadConfig,
|
||||
DiscordTextChannel textChannel
|
||||
) {
|
||||
if (!config.map(cfg -> cfg.shutdownBehaviour).map(cfg -> cfg.threads).get(cfg -> cfg.unarchive, true)) {
|
||||
if (!config.map(cfg -> cfg.channelLocking).map(cfg -> cfg.threads).get(cfg -> cfg.unarchive, true)) {
|
||||
return textChannel.createThread(threadConfig.threadName, threadConfig.privateThread);
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,19 @@
|
||||
/*
|
||||
* This file is part of the DiscordSRV API, licensed under the MIT License
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.discord.api;
|
||||
|
Loading…
Reference in New Issue
Block a user