3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Fix various bugs, update djs

This commit is contained in:
Dark 2021-07-04 23:14:12 +02:00
parent 4d1924b1ec
commit dda19de6e6
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
31 changed files with 96 additions and 72 deletions

View file

@ -35,6 +35,7 @@ import { SourceCmd } from "./commands/SourceCmd";
import { UserInfoCmd } from "./commands/UserInfoCmd";
import { VcdisconnectCmd } from "./commands/VcdisconnectCmd";
import { VcmoveAllCmd, VcmoveCmd } from "./commands/VcmoveCmd";
import { AutoJoinThreadEvt } from "./events/AutoJoinThreadEvt";
import { activeReloads } from "./guildReloads";
import { refreshMembersIfNeeded } from "./refreshMembers";
import { ConfigSchema, UtilityPluginType } from "./types";
@ -67,6 +68,7 @@ const defaultOptions: PluginOptions<UtilityPluginType> = {
jumbo_size: 128,
can_avatar: false,
info_on_single_result: true,
autojoin_threads: true,
},
overrides: [
{
@ -148,6 +150,11 @@ export const UtilityPlugin = zeppelinGuildPlugin<UtilityPluginType>()({
EmojiInfoCmd,
],
// prettier-ignore
events: [
AutoJoinThreadEvt,
],
beforeLoad(pluginData) {
const { state, guild } = pluginData;

View file

@ -98,7 +98,7 @@ export const CleanCmd = utilityCmd({
userId: msg.author.id,
member: msg.member,
channelId: targetChannel.id,
categoryId: targetChannel.parentID,
categoryId: targetChannel.parentId,
});
if (configForTargetChannel.can_clean !== true) {
sendErrorMessage(pluginData, msg.channel, `Missing permissions to use clean on that channel`);

View file

@ -21,11 +21,11 @@ export const VcdisconnectCmd = utilityCmd({
return;
}
if (!args.member.voice || !args.member.voice.channelID) {
if (!args.member.voice || !args.member.voice.channelId) {
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
return;
}
const channel = pluginData.guild.channels.cache.get(args.member.voice.channelID) as VoiceChannel;
const channel = pluginData.guild.channels.cache.get(args.member.voice.channelId) as VoiceChannel;
try {
await args.member.voice.kick();

View file

@ -52,17 +52,17 @@ export const VcmoveCmd = utilityCmd({
channel = closestMatch;
}
if (!args.member.voice || !args.member.voice.channelID) {
if (!args.member.voice || !args.member.voice.channelId) {
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
return;
}
if (args.member.voice.channelID === channel.id) {
if (args.member.voice.channelId === channel.id) {
sendErrorMessage(pluginData, msg.channel, "Member is already on that channel!");
return;
}
const oldVoiceChannel = pluginData.guild.channels.cache.get(args.member.voice.channelID);
const oldVoiceChannel = pluginData.guild.channels.cache.get(args.member.voice.channelId);
try {
await args.member.edit({

View file

@ -0,0 +1,12 @@
import { utilityEvt } from "../types";
export const AutoJoinThreadEvt = utilityEvt({
event: "threadCreate",
async listener(meta) {
const config = meta.pluginData.config.get();
if (config.autojoin_threads && meta.args.thread.joinable && !meta.args.thread.joined) {
await meta.args.thread.join();
}
},
});

View file

@ -105,11 +105,11 @@ export async function getChannelInfoEmbed(
if (channel.type === ChannelTypeStrings.CATEGORY) {
const textChannels = pluginData.guild.channels.cache.filter(
ch => ch.parentID === channel.id && ch.type !== ChannelTypeStrings.VOICE,
ch => ch.parentId === channel.id && ch.type !== ChannelTypeStrings.VOICE,
);
const voiceChannels = pluginData.guild.channels.cache.filter(
ch =>
ch.parentID === channel.id && (ch.type === ChannelTypeStrings.VOICE || ch.type === ChannelTypeStrings.STAGE),
ch.parentId === channel.id && (ch.type === ChannelTypeStrings.VOICE || ch.type === ChannelTypeStrings.STAGE),
);
embed.fields.push({

View file

@ -64,10 +64,10 @@ export async function getServerInfoEmbed(
basicInformation.push(`Created: **${serverAge} ago** (\`${prettyCreatedAt}\`)`);
if (thisServer) {
const owner = await resolveUser(pluginData.client, thisServer.ownerID);
const owner = await resolveUser(pluginData.client, thisServer.ownerId);
const ownerName = `${owner.username}#${owner.discriminator}`;
basicInformation.push(`Owner: **${ownerName}** (\`${thisServer.ownerID}\`)`);
basicInformation.push(`Owner: **${ownerName}** (\`${thisServer.ownerId}\`)`);
// basicInformation.push(`Voice region: **${thisServer.region}**`); Outdated, as automatic voice regions are fully live
}
@ -81,10 +81,10 @@ export async function getServerInfoEmbed(
});
// IMAGE LINKS
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL})`;
const bannerUrl = restGuild?.bannerURL ? `[Link](${restGuild.bannerURL})` : "None";
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL()})`;
const bannerUrl = restGuild?.bannerURL() ? `[Link](${restGuild.bannerURL()})` : "None";
const splashUrl =
(restGuild || guildPreview)!.splashURL != null
(restGuild || guildPreview)!.splashURL() != null
? `[Link](${(restGuild || guildPreview)!.splashURL()?.replace("size=128", "size=2048")})`
: "None";

View file

@ -114,7 +114,7 @@ export async function getUserInfoEmbed(
`),
});
const voiceChannel = member.voice.channelID ? pluginData.guild.channels.cache.get(member.voice.channelID) : null;
const voiceChannel = member.voice.channelId ? pluginData.guild.channels.cache.get(member.voice.channelId) : null;
if (voiceChannel || member.voice.mute || member.voice.deaf) {
embed.fields.push({
name: preEmbedPadding + "Voice information",

View file

@ -175,7 +175,7 @@ export async function displaySearch(
new MessageButton()
.setStyle("SECONDARY")
.setEmoji("⬅")
.setCustomID(`previousButton:${idMod}`)
.setCustomId(`previousButton:${idMod}`)
.setDisabled(currentPage === 1),
);
@ -183,7 +183,7 @@ export async function displaySearch(
new MessageButton()
.setStyle("SECONDARY")
.setEmoji("➡")
.setCustomID(`nextButton:${idMod}`)
.setCustomId(`nextButton:${idMod}`)
.setDisabled(currentPage === searchResult.lastPage),
);
@ -191,7 +191,7 @@ export async function displaySearch(
new MessageButton()
.setStyle("SECONDARY")
.setEmoji("🔄")
.setCustomID(`reloadButton:${idMod}`),
.setCustomId(`reloadButton:${idMod}`),
);
const row = new MessageActionRow().addComponents(buttons);
@ -204,15 +204,15 @@ export async function displaySearch(
if (msg.author.id !== interaction.user.id) {
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
} else {
if (interaction.customID === `previousButton:${idMod}` && currentPage > 1) {
if (interaction.customId === `previousButton:${idMod}` && currentPage > 1) {
collector.stop();
await interaction.deferUpdate();
await loadSearchPage(currentPage - 1);
} else if (interaction.customID === `nextButton:${idMod}` && currentPage < searchResult.lastPage) {
} else if (interaction.customId === `nextButton:${idMod}` && currentPage < searchResult.lastPage) {
collector.stop();
await interaction.deferUpdate();
await loadSearchPage(currentPage + 1);
} else if (interaction.customID === `reloadButton:${idMod}`) {
} else if (interaction.customId === `reloadButton:${idMod}`) {
collector.stop();
await interaction.deferUpdate();
await loadSearchPage(currentPage);
@ -325,7 +325,7 @@ async function performMemberSearch(
}
if (args.voice) {
matchingMembers = matchingMembers.filter(m => m.voice.channelID != null);
matchingMembers = matchingMembers.filter(m => m.voice.channelId != null);
}
if (args.bot) {

View file

@ -34,6 +34,7 @@ export const ConfigSchema = t.type({
jumbo_size: t.Integer,
can_avatar: t.boolean,
info_on_single_result: t.boolean,
autojoin_threads: t.boolean,
});
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;