Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality of life update #61

Merged
merged 26 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1030655
Add questions
mezotv Feb 9, 2023
6eba6c2
Rather.js update
mezotv Feb 11, 2023
38e1dee
Add images and canvas command
mezotv Feb 13, 2023
310cb47
Fix bug + language support
mezotv Feb 13, 2023
d4f2e8d
Add more questions
mezotv Feb 15, 2023
0aebea1
Added text resize
mezotv Feb 15, 2023
4854293
Add custom strings
mezotv Feb 15, 2023
70b08fc
Finish new rather command
mezotv Feb 21, 2023
4b2a278
Created settings.js
forgetfulskybro Feb 23, 2023
091d2a9
Fix settings command and translation
mezotv Feb 23, 2023
c764547
Fixed emojis
forgetfulskybro Feb 23, 2023
6750bec
Merge branch 'quality-of-life-update' of https://github.com/Would-You…
forgetfulskybro Feb 23, 2023
c5fe522
Adds never have I ever mode
mezotv Feb 23, 2023
8b951c5
Deleted translations for welcome and dailyMsgs
forgetfulskybro Feb 23, 2023
f77ded4
Merge branch 'quality-of-life-update' of https://github.com/Would-You…
forgetfulskybro Feb 23, 2023
4efeace
More settings (unfinished)
mezotv Feb 23, 2023
4fc9435
Fixed embed
forgetfulskybro Feb 24, 2023
7e74dd3
Feat: emit command, user ping
mezotv Feb 24, 2023
12fc5c6
Add more wwyd questions
mezotv Mar 1, 2023
22ed1cb
Improve either.js
mezotv Mar 4, 2023
c0a8c74
Merge branch 'main' of https://github.com/Would-You-Bot/Would-You int…
mezotv Mar 4, 2023
fa9630a
Resolve conflicts
mezotv Mar 4, 2023
f45ec24
Add either.js class
mezotv Mar 10, 2023
f0fc19f
Add replay and vote cooldown
mezotv Mar 11, 2023
0102b49
String + Either update
mezotv Mar 11, 2023
2e7d843
Update info.js
mezotv Mar 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' of https://github.com/Would-You-Bot/Would-You int…
…o quality-of-life-update
  • Loading branch information
mezotv committed Mar 4, 2023
commit c0a8c74bd7c2d2205b01e3443a16be2dff6d3925
36 changes: 0 additions & 36 deletions PRIVACY-POLICY

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cron": "^2.1.0",
"discord-api-types": "^0.37.11",
"discord-hybrid-sharding": "^2.1.0",
"discord.js": "14.7.0",
"discord.js": "^14.7.1",
"dotenv": "^16.0.3",
"dungeon-api": "^1.0.5",
"express": "^4.18.1",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {

/**
* @param {CommandInteraction} interaction
* @param {Client} client
* @param {WouldYou} client
* @param {guildModel} guildDb
*/

Expand Down
274 changes: 274 additions & 0 deletions src/commands/dailymsg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
const {
EmbedBuilder,
ChannelType,
SlashCommandBuilder,
PermissionFlagsBits,
} = require('discord.js');
const guildModel = require('../util/Models/guildModel');

function isValid(tz) {
if (!Intl || !Intl.DateTimeFormat().resolvedOptions().timeZone) {
return false;
}

try {
Intl.DateTimeFormat(undefined, {timeZone: tz});
return true;
} catch (ex) {
return false;
}
}

function dateType(tz) {
if (!tz.includes("/")) return false;
let text = tz.split("/");

if (text.length === 2) return true
else return false;
}

module.exports = {
requireGuild: true,
data: new SlashCommandBuilder()
.setName('dailymsg')
.setDescription('Daily Would You messages')
.setDMPermission(false)
.setDescriptionLocalizations({
de: 'Tägliche Würdest du Nachrichten',
"es-ES": 'Mensajes Would You diarios'
})
.addSubcommand((subcommand) =>
subcommand
.setName("channel")
.setDescription("Sets a channel for daily Would You messages.")
.addChannelOption(option =>
option
.setName('channel')
.setRequired(true)
.addChannelTypes(ChannelType.GuildText)
.setDescription('Choose which channel you want to use for daily Would You messages.')
)
)
.addSubcommand((subcommand) =>
subcommand
.setName("role")
.setDescription("Sets a role for daily Would You messages mentions.")
.addRoleOption(option => option.setName('role').setRequired(true).setDescription('Choose which role you want to use for daily Would You mentions.')
)
)
.addSubcommand((subcommand) =>
subcommand
.setName("timezone")
.setDescription("Pick a timezone for your server for when messages should be sent.")
.addStringOption((option) =>
option
.setName("timezone")
.setDescription("Pick a timezone for your server for when messages should be sent.")
.setRequired(true)
)
)
.addSubcommand((subcommand) =>
subcommand
.setName("message")
.setDescription("Enable/disable daily Would You messages.")
.addStringOption((option) =>
option
.setName("message")
.setDescription("Enable/disable daily Would You messages.")
.setRequired(true)
.addChoices(
{name: 'true', value: 'true'},
{name: 'false', value: 'false'},
)
)
)
.addSubcommand((subcommand) =>
subcommand
.setName("types")
.setDescription("Enable/disable to change the message to a rather message.")
.addStringOption((option) =>
option
.setName("types")
.setDescription("Change Daily Messages to rather messages.")
.setRequired(true)
.addChoices(
{name: 'true', value: 'true'},
{name: 'false', value: 'false'},
)
)
),
/**
* @param {CommandInteraction} interaction
* @param {WouldYou} client
* @param {guildModel} guildDb
*/
async execute(interaction, client, guildDb) {
let daily;
const {Daily} = require(`../languages/${guildDb.language}.json`);
if (
interaction.member.permissions.has(PermissionFlagsBits.ManageGuild)
|| global.checkDebug(guildDb, interaction?.user?.id)
) {
switch (interaction.options.getSubcommand()) {
case 'message': {
if (guildDb.dailyMsg && interaction.options.getString("message") === "true") return interaction.reply({
ephemeral: true,
content: `${Daily.embed.alreadytrue}`
})
if (!guildDb.dailyMsg && interaction.options.getString("message") === "false") return interaction.reply({
ephemeral: true,
content: `${Daily.embed.alreadyfalse}`
})
await client.database.updateGuild(interaction.guildId, {
dailyMsg: interaction.options.getString("message") === "true" ? true : false,
}, true)

daily = new EmbedBuilder()
.setTitle(`${Daily.successEmbed.title} Would You`)
.setColor('#0598F6')
.setDescription(`${Daily.successEmbed.desc} ${interaction.options.getString("message") === "true" ? Daily.successEmbed.options : Daily.successEmbed.options2} ${Daily.successEmbed.desc2}${!guildDb.dailyChannel ? `\n${Daily.successEmbed.desc3} ${interaction.options.getString("message") === "true" ? Daily.successEmbed.options : Daily.successEmbed.options2} ${Daily.successEmbed.desc4}` : ""}`)
.setFooter({
text: 'Would You',
iconURL: client.user.avatarURL(),
});
break;
}
case 'types': {
const types = interaction.options.getString("types") === "true" ? true : false;

if (guildDb.dailyRather && types) return interaction.reply({
ephemeral: true,
content: `${Daily.embed.alreadytrue}`
})
if (!guildDb.dailyRather && !types) return interaction.reply({
ephemeral: true,
content: `${Daily.embed.alreadyfalse}`
})

await client.database.updateGuild(interaction.guildId, {
dailyRather: types,
}, true);

daily = new EmbedBuilder()
.setTitle(`${Daily.successEmbed.title} Would You`)
.setColor('#0598F6')
.setDescription(`${Daily.successEmbed.desc} ${interaction.options.getString("types") === "true" ? Daily.successEmbed.options : Daily.successEmbed.options2} ${Daily.successEmbed.desc22}`)
.setFooter({
text: 'Would You',
iconURL: client.user.avatarURL(),
});
break;
}
case 'channel': {
const channel = interaction.options.getChannel("channel");

if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.ViewChannel])) return interaction.reply({
ephemeral: true,
content: Daily.errorChannel.viewChannel
})
if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.SendMessages])) return interaction.reply({
ephemeral: true,
content: Daily.errorChannel.sendMessages
})
if (!channel?.permissionsFor(client?.user?.id)?.has([PermissionFlagsBits.ManageWebhooks])) return interaction.reply({
ephemeral: true,
content: Daily.errorChannel.manageWebhooks
})
if (guildDb.dailyChannel && guildDb.dailyChannel === channel.id) return interaction.reply({
ephemeral: true,
content: Daily.errorChannel.alreadySet
})

await client.webhookHandler.sendWebhook(channel, channel.id, {
content: '<:roundyou:1009964111045607525> This channel will be used to send daily Would You messages.'
})

await client.database.updateGuild(interaction.guildId, {
dailyChannel: channel.id,
}, true)

daily = new EmbedBuilder()
.setTitle(Daily.success.title)
.setColor('#0598F6')
.setDescription(`${Daily.success.desc} <#${channel.id}> ${Daily.success.desc2}`)
.setFooter({
text: 'Would You',
iconURL: client.user.avatarURL(),
});
break;
}
case 'role': {
const role = interaction.options.getRole("role");

if (guildDb.dailyRole && guildDb.dailyRole === role.id) return interaction.reply({
ephemeral: true,
content: Daily.errorRole
})

await client.database.updateGuild(interaction.guildId, {
dailyRole: role.id,
}, true)

daily = new EmbedBuilder()
.setTitle(Daily.success.title)
.setColor('#0598F6')
.setDescription(`${Daily.success.desc} \`${role.name}\` ${Daily.success.desc3}`)
.setFooter({
text: 'Would You',
iconURL: client.user.avatarURL(),
});
break;
}

case 'timezone': {
const userInput = interaction.options.getString("timezone");
const lowerCaseUserInput = userInput.toLowerCase();

if (guildDb.dailyTimezone.toLowerCase() === lowerCaseUserInput) return interaction.reply({
ephemeral: true,
content: Daily.timezone.errorSame
})
if (!isValid(lowerCaseUserInput)) return interaction.reply({
ephemeral: true,
content: Daily.timezone.errorInvalid
})
if (!dateType(lowerCaseUserInput)) return interaction.reply({
ephemeral: true,
content: Daily.timezone.errorInvalid
})

await client.database.updateGuild(interaction.guildId, {
dailyTimezone: userInput,
}, true)

daily = new EmbedBuilder()
.setTitle(Daily.success.title)
.setColor('#0598F6')
.setDescription(`${Daily.timezone.desc} \`${userInput}\` ${Daily.timezone.desc2}`)
.setFooter({
text: 'Would You',
iconURL: client.user.avatarURL(),
});
break;
}
}
await interaction.reply({
embeds: [daily],
ephemeral: true,
}).catch((err) => {
return;
});
} else {
const errorembed = new EmbedBuilder()
.setColor('#F00505')
.setTitle('Error!')
.setDescription(Daily.embed.error);
return interaction.reply({
embeds: [errorembed],
ephemeral: true,
}).catch((err) => {
return;
});
}
},
};
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.