generated from Baipyrus/DiscordJS-Template
relative imports to properly type model instances
This commit is contained in:
parent
663f1313e9
commit
08567747c7
@ -57,6 +57,7 @@ export async function execute(interaction) {
|
|||||||
switch (options.getSubcommand()) {
|
switch (options.getSubcommand()) {
|
||||||
case 'add': {
|
case 'add': {
|
||||||
// Search for role in database
|
// Search for role in database
|
||||||
|
/** @type {import('../../../models/roles.js').Role|null} */
|
||||||
const found = await Roles.findOne({
|
const found = await Roles.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: role.id
|
id: role.id
|
||||||
|
@ -48,6 +48,7 @@ const registerSelfRoles = async (interaction) => {
|
|||||||
await channel.messages.fetch(id);
|
await channel.messages.fetch(id);
|
||||||
|
|
||||||
// Check if message is already registered
|
// Check if message is already registered
|
||||||
|
/** @type {import('../../../models/messages.js').Message|null} */
|
||||||
const found = await Messages.findOne({
|
const found = await Messages.findOne({
|
||||||
where: { id }
|
where: { id }
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,7 @@ import { VoiceChannels } from '../../database.js';
|
|||||||
*/
|
*/
|
||||||
const getChannel = async (member, guildChs, channel) => {
|
const getChannel = async (member, guildChs, channel) => {
|
||||||
// Check database for existing channel
|
// Check database for existing channel
|
||||||
|
/** @type {import('../../models/voiceChannels.js').VoiceChannel|null} */
|
||||||
const ownCh = await VoiceChannels.findOne({
|
const ownCh = await VoiceChannels.findOne({
|
||||||
where: {
|
where: {
|
||||||
owner: member.id
|
owner: member.id
|
||||||
@ -58,6 +59,7 @@ const leftVoiceChat = async (state) => {
|
|||||||
if (members.length > 0) return;
|
if (members.length > 0) return;
|
||||||
|
|
||||||
// Find channel by id, return if not registered as custom
|
// Find channel by id, return if not registered as custom
|
||||||
|
/** @type {import('../../models/voiceChannels.js').VoiceChannel|null} */
|
||||||
const custom = await VoiceChannels.findOne({
|
const custom = await VoiceChannels.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: channel.id,
|
id: channel.id,
|
||||||
@ -84,6 +86,7 @@ export async function execute(oldState, newState) {
|
|||||||
if (!channel) return;
|
if (!channel) return;
|
||||||
|
|
||||||
// Find channel by id, return if not registered for customs
|
// Find channel by id, return if not registered for customs
|
||||||
|
/** @type {import('../../models/voiceChannels.js').VoiceChannel|null} */
|
||||||
const createCh = await VoiceChannels.findOne({
|
const createCh = await VoiceChannels.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: channel.id,
|
id: channel.id,
|
||||||
|
@ -5,6 +5,7 @@ export const name = Events.GuildMemberAdd;
|
|||||||
/** @param {GuildMember} member */
|
/** @param {GuildMember} member */
|
||||||
export async function execute(member) {
|
export async function execute(member) {
|
||||||
// Find roles to be assigned in guild from database
|
// Find roles to be assigned in guild from database
|
||||||
|
/** @type {import('../../models/roles.js').Role[]} */
|
||||||
const roles = await Roles.findAll({
|
const roles = await Roles.findAll({
|
||||||
where: {
|
where: {
|
||||||
guild: member.guild.id,
|
guild: member.guild.id,
|
||||||
|
@ -14,6 +14,7 @@ export async function execute(reaction, user) {
|
|||||||
|
|
||||||
// Get message
|
// Get message
|
||||||
const msgID = reaction.message.id;
|
const msgID = reaction.message.id;
|
||||||
|
/** @type {import('../../models/messages.js').Message|null} */
|
||||||
const message = await Messages.findOne({
|
const message = await Messages.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: msgID
|
id: msgID
|
||||||
@ -24,6 +25,7 @@ export async function execute(reaction, user) {
|
|||||||
|
|
||||||
// Get emoji
|
// Get emoji
|
||||||
const emoji = reaction.emoji.toString();
|
const emoji = reaction.emoji.toString();
|
||||||
|
/** @type {import('../../models/roleEmojiPairs.js').RoleEmojiPair|null} */
|
||||||
const rep = await RoleEmojiPairs.findOne({
|
const rep = await RoleEmojiPairs.findOne({
|
||||||
where: {
|
where: {
|
||||||
message: msgID,
|
message: msgID,
|
||||||
|
@ -14,6 +14,7 @@ export async function execute(reaction, user) {
|
|||||||
|
|
||||||
// Get message
|
// Get message
|
||||||
const msgID = reaction.message.id;
|
const msgID = reaction.message.id;
|
||||||
|
/** @type {import('../../models/messages.js').Message|null} */
|
||||||
const message = await Messages.findOne({
|
const message = await Messages.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: msgID
|
id: msgID
|
||||||
@ -24,6 +25,7 @@ export async function execute(reaction, user) {
|
|||||||
|
|
||||||
// Get emoji
|
// Get emoji
|
||||||
const emoji = reaction.emoji.toString();
|
const emoji = reaction.emoji.toString();
|
||||||
|
/** @type {import('../../models/roleEmojiPairs.js').RoleEmojiPair|null} */
|
||||||
const rep = await RoleEmojiPairs.findOne({
|
const rep = await RoleEmojiPairs.findOne({
|
||||||
where: {
|
where: {
|
||||||
message: msgID,
|
message: msgID,
|
||||||
|
@ -42,10 +42,12 @@ export const removeSelfRoles = async (interaction, id) => {
|
|||||||
*/
|
*/
|
||||||
const saveMessageData = async (id, role, emoji) => {
|
const saveMessageData = async (id, role, emoji) => {
|
||||||
// Try finding message
|
// Try finding message
|
||||||
|
/** @type {import('./models/messages.js').Message|null} */
|
||||||
const msg = await Messages.findOne({ where: { id } });
|
const msg = await Messages.findOne({ where: { id } });
|
||||||
if (msg === null) throw new Error(`No message with ID '${id}' could be found!`);
|
if (msg === null) throw new Error(`No message with ID '${id}' could be found!`);
|
||||||
|
|
||||||
// Try finding existing entry
|
// Try finding existing entry
|
||||||
|
/** @type {import('./models/roleEmojiPairs.js').RoleEmojiPair|null} */
|
||||||
const rep = await RoleEmojiPairs.findOne({
|
const rep = await RoleEmojiPairs.findOne({
|
||||||
where: {
|
where: {
|
||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
@ -92,6 +94,7 @@ const editMessage = async (message, role, emoji) => {
|
|||||||
|
|
||||||
// Find out whether to pad message or already present
|
// Find out whether to pad message or already present
|
||||||
let padding = '\n';
|
let padding = '\n';
|
||||||
|
/** @type {import('./models/roleEmojiPairs.js').RoleEmojiPair[]} */
|
||||||
const reps = await RoleEmojiPairs.findAll({ where: { message: message.id } });
|
const reps = await RoleEmojiPairs.findAll({ where: { message: message.id } });
|
||||||
if (reps.length === 0) padding += '\n';
|
if (reps.length === 0) padding += '\n';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user