style(src/prettier): updating with the prettier
This commit is contained in:
parent
b36925546c
commit
bb46ad3996
17 changed files with 1909 additions and 1717 deletions
|
|
@ -1,55 +1,57 @@
|
|||
import { Events, MessageFlags } from 'discord.js'
|
||||
import { prisma } from '../../lib/prisma.ts';
|
||||
import { Events, MessageFlags } from "discord.js";
|
||||
import { prisma } from "../../lib/prisma.ts";
|
||||
|
||||
export default {
|
||||
name: Events.GuildCreate,
|
||||
async execute(guild, client) {
|
||||
const botData = await prisma.bot.findUnique({
|
||||
where: {
|
||||
id: 1
|
||||
},
|
||||
include: {
|
||||
buyers: true
|
||||
}
|
||||
});
|
||||
await prisma.guild.upsert({
|
||||
where: {
|
||||
id: guild.id
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: guild.id
|
||||
}
|
||||
});
|
||||
name: Events.GuildCreate,
|
||||
async execute(guild, client) {
|
||||
const botData = await prisma.bot.findUnique({
|
||||
where: {
|
||||
id: 1,
|
||||
},
|
||||
include: {
|
||||
buyers: true,
|
||||
},
|
||||
});
|
||||
await prisma.guild.upsert({
|
||||
where: {
|
||||
id: guild.id,
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: guild.id,
|
||||
},
|
||||
});
|
||||
|
||||
const members = await guild.members.fetch();
|
||||
let i = 0;
|
||||
for (const [memberId, member] of members) {
|
||||
await prisma.user.upsert({
|
||||
where: {
|
||||
id: memberId
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: memberId
|
||||
}
|
||||
});
|
||||
const members = await guild.members.fetch();
|
||||
let i = 0;
|
||||
for (const [memberId, member] of members) {
|
||||
await prisma.user.upsert({
|
||||
where: {
|
||||
id: memberId,
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: memberId,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.guildUser.upsert({
|
||||
where: {
|
||||
userId_guildId: {
|
||||
userId: memberId,
|
||||
guildId: guild.id
|
||||
}
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
userId: memberId,
|
||||
guildId: guild.id
|
||||
}
|
||||
});
|
||||
i++;
|
||||
}
|
||||
console.log(`✅ | Guild ${guild.name} synchronisée avec ${members.size} membres.`);
|
||||
}
|
||||
}
|
||||
await prisma.guildUser.upsert({
|
||||
where: {
|
||||
userId_guildId: {
|
||||
userId: memberId,
|
||||
guildId: guild.id,
|
||||
},
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
userId: memberId,
|
||||
guildId: guild.id,
|
||||
},
|
||||
});
|
||||
i++;
|
||||
}
|
||||
console.log(
|
||||
`✅ | Guild ${guild.name} synchronisée avec ${members.size} membres.`,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,75 +1,81 @@
|
|||
import { ActivityType, PresenceUpdateStatus, Events } from 'discord.js'
|
||||
import { prisma } from '../../lib/prisma.ts';
|
||||
import { ActivityType, PresenceUpdateStatus, Events } from "discord.js";
|
||||
import { prisma } from "../../lib/prisma.ts";
|
||||
|
||||
export default {
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
async execute(client) {
|
||||
try {
|
||||
let botData: Bot;
|
||||
botData = await prisma.bot.findUnique({
|
||||
where: {
|
||||
id: 1
|
||||
}
|
||||
});
|
||||
const newStatus: string = botData.status;
|
||||
const tmpType: string = botData.type;
|
||||
let newType: ActivityType;
|
||||
switch (tmpType) {
|
||||
case 'play':
|
||||
newType = ActivityType.Playing;
|
||||
break;
|
||||
case 'listen':
|
||||
newType = ActivityType.Listening;
|
||||
break;
|
||||
case 'watch':
|
||||
newType = ActivityType.Watching;
|
||||
break;
|
||||
case 'stream':
|
||||
newType = ActivityType.Streaming;
|
||||
break;
|
||||
case 'comptet':
|
||||
newType = ActivityType.Competing;
|
||||
break;
|
||||
}
|
||||
const tmpPresence: string = botData.presence
|
||||
let newPresence: PresenceUpdateStatus;
|
||||
switch (tmpPresence) {
|
||||
case 'online':
|
||||
newPresence = PresenceUpdateStatus.Online;
|
||||
break;
|
||||
case 'idle':
|
||||
newPresence = PresenceUpdateStatus.Idle;
|
||||
break;
|
||||
case 'dnd':
|
||||
newPresence = PresenceUpdateStatus.DoNotDisturb;
|
||||
break;
|
||||
case 'invisible':
|
||||
newPresence = PresenceUpdateStatus.Invisible;
|
||||
break;
|
||||
}
|
||||
if (botData.type === 'steam') {
|
||||
client.user.setPresence({
|
||||
status: newPresence,
|
||||
activities: [{
|
||||
name: newStatus,
|
||||
type: newType,
|
||||
url: 'https://twich.tv/EniumRaphael'
|
||||
}]
|
||||
});
|
||||
} else {
|
||||
client.user.setPresence({
|
||||
status: newPresence,
|
||||
activities: [{
|
||||
name: newStatus,
|
||||
type: newType,
|
||||
}]
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`\t⚠️ | Cannot get the database connection!\n\t\t(${err}).`);
|
||||
return;
|
||||
}
|
||||
console.log(`✅ | ${client.user.username} is now running under TTS bot`);
|
||||
},
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
async execute(client) {
|
||||
try {
|
||||
let botData: Bot;
|
||||
botData = await prisma.bot.findUnique({
|
||||
where: {
|
||||
id: 1,
|
||||
},
|
||||
});
|
||||
const newStatus: string = botData.status;
|
||||
const tmpType: string = botData.type;
|
||||
let newType: ActivityType;
|
||||
switch (tmpType) {
|
||||
case "play":
|
||||
newType = ActivityType.Playing;
|
||||
break;
|
||||
case "listen":
|
||||
newType = ActivityType.Listening;
|
||||
break;
|
||||
case "watch":
|
||||
newType = ActivityType.Watching;
|
||||
break;
|
||||
case "stream":
|
||||
newType = ActivityType.Streaming;
|
||||
break;
|
||||
case "comptet":
|
||||
newType = ActivityType.Competing;
|
||||
break;
|
||||
}
|
||||
const tmpPresence: string = botData.presence;
|
||||
let newPresence: PresenceUpdateStatus;
|
||||
switch (tmpPresence) {
|
||||
case "online":
|
||||
newPresence = PresenceUpdateStatus.Online;
|
||||
break;
|
||||
case "idle":
|
||||
newPresence = PresenceUpdateStatus.Idle;
|
||||
break;
|
||||
case "dnd":
|
||||
newPresence = PresenceUpdateStatus.DoNotDisturb;
|
||||
break;
|
||||
case "invisible":
|
||||
newPresence = PresenceUpdateStatus.Invisible;
|
||||
break;
|
||||
}
|
||||
if (botData.type === "steam") {
|
||||
client.user.setPresence({
|
||||
status: newPresence,
|
||||
activities: [
|
||||
{
|
||||
name: newStatus,
|
||||
type: newType,
|
||||
url: "https://twich.tv/EniumRaphael",
|
||||
},
|
||||
],
|
||||
});
|
||||
} else {
|
||||
client.user.setPresence({
|
||||
status: newPresence,
|
||||
activities: [
|
||||
{
|
||||
name: newStatus,
|
||||
type: newType,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`\t⚠️ | Cannot get the database connection!\n\t\t(${err}).`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
console.log(`✅ | ${client.user.username} is now running under TTS bot`);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,35 +1,36 @@
|
|||
import { Events, MessageFlags } from 'discord.js'
|
||||
import emoji from '../../../assets/emoji.json' assert { type: "json" };
|
||||
import { Events, MessageFlags } from "discord.js";
|
||||
import emoji from "../../../assets/emoji.json" assert { type: "json" };
|
||||
|
||||
export default {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand())
|
||||
return;
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
if (!command) {
|
||||
console.error(`⚠️ | Can't execute ${interaction.commandName}`);
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.error} | Cannot execute the command ${interaction.commandName}`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(`⚠️ | Error when occured this command ${interaction.commandName}\n\t${error}`);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({
|
||||
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (After Print)`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
} else {
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (Before Print)`,
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
if (!command) {
|
||||
console.error(`⚠️ | Can't execute ${interaction.commandName}`);
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.error} | Cannot execute the command ${interaction.commandName}`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`⚠️ | Error when occured this command ${interaction.commandName}\n\t${error}`,
|
||||
);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({
|
||||
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (After Print)`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
} else {
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (Before Print)`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue