Compare commits
2 Commits
b46dc8d3ae
...
edacc747b3
Author | SHA1 | Date | |
---|---|---|---|
edacc747b3 | |||
2592aea260 |
0
src/actions/activity/activity.components.ts
Normal file
0
src/actions/activity/activity.components.ts
Normal file
13
src/actions/activity/activity.service.ts
Normal file
13
src/actions/activity/activity.service.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import type { CacheType, Client, Interaction } from "discord.js";
|
||||||
|
import client from "lib/client";
|
||||||
|
|
||||||
|
export class ActivityService {
|
||||||
|
|
||||||
|
async setActivity(client: Client<boolean>, description: string, activity: string) {
|
||||||
|
client.user?.setActivity(":3", { type: 4 });
|
||||||
|
console.log("set activity");
|
||||||
|
client.user?.setPresence({
|
||||||
|
status: "online",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,5 @@
|
|||||||
|
import config from "config";
|
||||||
|
|
||||||
export const greetContent = ["HALLOOOO", "guten morgen! ich hoffe es geht euch gut <3"];
|
export const greetContent = ["HALLOOOO", "guten morgen! ich hoffe es geht euch gut <3"];
|
||||||
export const sleepContent = ["gute nacht! ich muss jetzt schlafen gehen :c", "zzzzZZ..", "*schnarch*"];
|
export const sleepContent = ["gute nacht! ich muss jetzt schlafen gehen :c", "zzzzZZ..", "*schnarch*"];
|
||||||
|
export const customContent = `hey <@&${config.discord.mentionStudy}>! meine [eigene website](https://avocadi.unom.io) ist endlich on :3\ngebe mir gerne rueckmeldung unter <#${config.discord.channelIdFeedback}>! <3`;
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import config from "config";
|
import config from "config";
|
||||||
import client from "lib/client";
|
import client from "lib/client";
|
||||||
import { getRandomInt } from "lib/utils";
|
import { getRandomInt } from "lib/utils";
|
||||||
import { greetContent, sleepContent } from "./greeting.components.ts";
|
import {
|
||||||
|
customContent,
|
||||||
|
greetContent,
|
||||||
|
sleepContent,
|
||||||
|
} from "./greeting.components.ts";
|
||||||
|
import { Client, EmbedBuilder, type GuildMember } from "discord.js";
|
||||||
|
|
||||||
export class GreetingService {
|
export class GreetingService {
|
||||||
async customMessage() {
|
async customMessage() {
|
||||||
@ -9,10 +14,59 @@ export class GreetingService {
|
|||||||
|
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
|
|
||||||
const channel = channels.cache.get(config.discord.channelId);
|
const channel = channels.cache.get(config.discord.channelIdBot);
|
||||||
|
|
||||||
if (channel?.isTextBased && channel?.isSendable()) {
|
if (channel?.isTextBased && channel?.isSendable()) {
|
||||||
await channel.send({ content: " " });
|
await channel.send({ embeds: [this.createEmbed()] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createEmbed() {
|
||||||
|
// ({ embeds: [exampleEmbed] })
|
||||||
|
console.log("createEmbed()");
|
||||||
|
|
||||||
|
const exampleEmbed = new EmbedBuilder()
|
||||||
|
.setColor(0x004400)
|
||||||
|
.setAuthor({
|
||||||
|
name: "avocadi - neuigkeiten",
|
||||||
|
iconURL:
|
||||||
|
"https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524",
|
||||||
|
url: "https://avocadi.unom.io",
|
||||||
|
})
|
||||||
|
.setDescription(customContent)
|
||||||
|
.setTimestamp();
|
||||||
|
//.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
|
||||||
|
return exampleEmbed;
|
||||||
|
}
|
||||||
|
|
||||||
|
async welcome(member: GuildMember) {
|
||||||
|
const welcomeMessages = [
|
||||||
|
`willkommen auf dem server, ${member}! 💕`,
|
||||||
|
`hey ${member}! schoen, dass du hier bist! 😊`,
|
||||||
|
`hi ${member}, willkommen! viel spass hier! 💖`,
|
||||||
|
`willkommen, ${member}! schoen, dass du da bist! 🥳`,
|
||||||
|
`moin ${member}! viel spass im server! c:`,
|
||||||
|
`hey ${member}! herzlich willkommen! fühl dich wie zu hause! 🏡`,
|
||||||
|
`hi ${member}! cool, dass du da bist! 👏`,
|
||||||
|
`willkommen, ${member}! wir freuen uns, dass du hier bist! 💕`,
|
||||||
|
`hey ${member}! schoen, dass du bei uns bist! :3`,
|
||||||
|
`willkommen auf dem server, ${member}! viel spass hier! ✨`
|
||||||
|
];
|
||||||
|
const randomMessage = `${welcomeMessages[Math.floor(Math.random() * welcomeMessages.length)]} bitte stelle dich kurz in <#${config.discord.channelIdIntro}> vor. sobald wir deine nachricht gelesen haben, vergeben wir dir die rolle *lernende:r*, damit du alle kanaele nutzen kannst viel spass und bis bald! :) `;
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log("welcome msg");
|
||||||
|
|
||||||
|
const channels = client.channels;
|
||||||
|
const channel = channels.cache.get(
|
||||||
|
config.discord.channelIdWelcome,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (channel?.isTextBased() && channel?.isSendable()) {
|
||||||
|
await channel.send(randomMessage);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("error while senden a welcome msg:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +79,7 @@ export class GreetingService {
|
|||||||
|
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
|
|
||||||
const channel = channels.cache.get(config.discord.channelId);
|
const channel = channels.cache.get(config.discord.testChannel);
|
||||||
|
|
||||||
if (channel?.isTextBased && channel?.isSendable()) {
|
if (channel?.isTextBased && channel?.isSendable()) {
|
||||||
await channel.send({ content: this.getContent(false) });
|
await channel.send({ content: this.getContent(false) });
|
||||||
@ -41,7 +95,7 @@ export class GreetingService {
|
|||||||
|
|
||||||
const channels = client.channels;
|
const channels = client.channels;
|
||||||
|
|
||||||
const channel = channels.cache.get(config.discord.channelId);
|
const channel = channels.cache.get(config.discord.testChannel);
|
||||||
|
|
||||||
if (channel?.isTextBased && channel?.isSendable()) {
|
if (channel?.isTextBased && channel?.isSendable()) {
|
||||||
await channel.send({ content: this.getContent(true) });
|
await channel.send({ content: this.getContent(true) });
|
||||||
|
@ -11,9 +11,9 @@ export default function createEmbed() { // ({ embeds: [exampleEmbed] })
|
|||||||
.setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/moriese/avocadi-bot' })
|
.setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/moriese/avocadi-bot' })
|
||||||
.setDescription(" ")
|
.setDescription(" ")
|
||||||
.addFields(
|
.addFields(
|
||||||
{ name: "/" + Commands.Enum.giessen, value: CommandsMeta.giessen.description },
|
{ name: `/${Commands.Enum.giessen}`, value: CommandsMeta.giessen.description },
|
||||||
{ name: "/" + Commands.Enum.medikamente, value: CommandsMeta.medikamente.description },
|
{ name: `/${Commands.Enum.medikamente}`, value: CommandsMeta.medikamente.description },
|
||||||
{ name: "/" + Commands.Enum.hilfe, value: CommandsMeta.hilfe.description },
|
{ name: `/${Commands.Enum.hilfe}`, value: CommandsMeta.hilfe.description },
|
||||||
)
|
)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
//.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
|
//.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
|
||||||
|
@ -2,6 +2,7 @@ import type { CacheType, Interaction } from "discord.js";
|
|||||||
import createEmbed from "./help.components";
|
import createEmbed from "./help.components";
|
||||||
|
|
||||||
export class HelpService {
|
export class HelpService {
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||||
exampleEmbed: any;
|
exampleEmbed: any;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { SlashCommandBuilder } from "discord.js";
|
import { SlashCommandBuilder, userMention } from "discord.js";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const Commands = z.enum(["giessen", "medikamente", "hilfe"]);
|
export const Commands = z.enum(["giessen", "medikamente", "hilfe"]);
|
||||||
@ -12,7 +12,7 @@ export const CommandsMeta: Record<z.output<typeof Commands>, { description: stri
|
|||||||
},
|
},
|
||||||
hilfe: {
|
hilfe: {
|
||||||
description: "ich schreibe dir auf, was du alles mit mir machen kannst :)"
|
description: "ich schreibe dir auf, was du alles mit mir machen kannst :)"
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommandsType = z.output<typeof Commands>;
|
export type CommandsType = z.output<typeof Commands>;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
const test = false;
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
discord: {
|
discord: {
|
||||||
channelId:
|
testChannel: process.env.DISCORD_TEST_CHANNEL_ID || "",
|
||||||
(test
|
channelIdBot: process.env.DISCORD_CHANNEL_ID_BOT || "",
|
||||||
? process.env.DISCORD_TEST_CHANNEL_ID
|
channelIdNews: process.env.DISCORD_CHANNEL_ID_NEWS || "",
|
||||||
: process.env.DISCORD_CHANNEL_ID_BOT) || "",
|
channelIdFeedback: process.env.DISCORD_CHANNEL_ID_FEEDBACK || "",
|
||||||
|
channelIdIntro: process.env.DISCORD_CHANNEL_ID_INTRO || "",
|
||||||
|
channelIdWelcome: process.env.DISCORD_CHANNEL_ID_WELCOME || "",
|
||||||
|
mentionStudy: process.env.PEOPLE || "",
|
||||||
applicationId: process.env.DISCORD_APPLICATION_ID || "",
|
applicationId: process.env.DISCORD_APPLICATION_ID || "",
|
||||||
token: process.env.DISCORD_TOKEN || "",
|
token: process.env.DISCORD_TOKEN || "",
|
||||||
},
|
},
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { Commands, type CommandsType } from "commands";
|
import { Commands, type CommandsType } from "commands";
|
||||||
import type {
|
import {
|
||||||
ButtonInteraction,
|
Client,
|
||||||
CacheType,
|
IntentsBitField,
|
||||||
ChatInputCommandInteraction,
|
type ButtonInteraction,
|
||||||
Interaction,
|
type CacheType,
|
||||||
ModalSubmitInteraction,
|
type ChatInputCommandInteraction,
|
||||||
|
type Interaction,
|
||||||
|
type ModalSubmitInteraction,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import client from "lib/client";
|
import client from "lib/client";
|
||||||
import EventEmitter from "node:events";
|
import EventEmitter from "node:events";
|
||||||
@ -14,39 +16,41 @@ import { WaterMeService } from "actions/waterMe/waterMe.service";
|
|||||||
import { MedicationService } from "actions/medication/medication.service";
|
import { MedicationService } from "actions/medication/medication.service";
|
||||||
import { HelpService } from "actions/help/help.service";
|
import { HelpService } from "actions/help/help.service";
|
||||||
import { custom } from "zod";
|
import { custom } from "zod";
|
||||||
|
import { GreetingService } from "actions/greeting/greeting.service";
|
||||||
|
import { ActivityService } from "actions/activity/activity.service";
|
||||||
|
|
||||||
export default class DiscordController extends EventEmitter {
|
export default class DiscordController extends EventEmitter {
|
||||||
private discordService!: DiscordService;
|
private discordService!: DiscordService;
|
||||||
waterMeService: WaterMeService;
|
waterMeService: WaterMeService;
|
||||||
|
greetingService: GreetingService;
|
||||||
medicationService: MedicationService;
|
medicationService: MedicationService;
|
||||||
helpService: HelpService;
|
helpService: HelpService;
|
||||||
|
activityService: ActivityService;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.discordService = new DiscordService();
|
this.discordService = new DiscordService();
|
||||||
this.waterMeService = new WaterMeService();
|
this.waterMeService = new WaterMeService();
|
||||||
|
this.greetingService = new GreetingService();
|
||||||
this.medicationService = new MedicationService();
|
this.medicationService = new MedicationService();
|
||||||
this.helpService = new HelpService();
|
this.helpService = new HelpService();
|
||||||
|
this.activityService = new ActivityService();
|
||||||
// log when running
|
// log when running
|
||||||
client.once("ready", async () => {
|
client.once("ready", async () => {
|
||||||
this.setActivity();
|
this.setActivity();
|
||||||
|
this.greetingService.customMessage();
|
||||||
/*const channels = client.channels;
|
|
||||||
const channel = channels.cache.get(config.discord.channelId);
|
|
||||||
|
|
||||||
if (channel?.isTextBased && channel?.isSendable()) {
|
|
||||||
await channel.send({
|
|
||||||
content: "bin wieder da :o war kurz weg :3",
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// listen for interactions
|
// listen for interactions
|
||||||
client.on("interactionCreate", this.handleInteraction.bind(this));
|
client.on("interactionCreate", this.handleInteraction.bind(this));
|
||||||
|
client.on("guildMemberAdd", async (member) => {
|
||||||
|
console.log("client on guildMemberAdd");
|
||||||
|
await this.greetingService.welcome(member);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async setActivity() {
|
async setActivity() {
|
||||||
client.user?.setActivity("frohes neues :3", { type: 4 });
|
client.user?.setActivity(":3", { type: 4 });
|
||||||
console.log("set activity");
|
console.log("set activity");
|
||||||
client.user?.setPresence({
|
client.user?.setPresence({
|
||||||
status: "online",
|
status: "online",
|
||||||
|
42
src/index.ts
42
src/index.ts
@ -5,48 +5,6 @@ import "actions/drink/drink.task";
|
|||||||
import DiscordController from "controllers/discord.controller";
|
import DiscordController from "controllers/discord.controller";
|
||||||
|
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
/*import { drizzle } from 'drizzle-orm/bun-sqlite';
|
|
||||||
import { eq } from 'drizzle-orm';
|
|
||||||
import { usersTable } from './db/schema';
|
|
||||||
import { db } from "./db" // from index
|
|
||||||
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const user: typeof usersTable.$inferInsert = {
|
|
||||||
name: 'John',
|
|
||||||
age: 30,
|
|
||||||
email: 'john@example.com',
|
|
||||||
};
|
|
||||||
|
|
||||||
await db.insert(usersTable).values(user);
|
|
||||||
console.log('New user created!')
|
|
||||||
|
|
||||||
const users = await db.select().from(usersTable);
|
|
||||||
console.log('Getting all users from the database: ', users)
|
|
||||||
/*
|
|
||||||
const users: {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
age: number;
|
|
||||||
email: string;
|
|
||||||
}[]
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
await db
|
|
||||||
.update(usersTable)
|
|
||||||
.set({
|
|
||||||
age: 31,
|
|
||||||
})
|
|
||||||
.where(eq(usersTable.email, user.email));
|
|
||||||
console.log('User info updated!')
|
|
||||||
|
|
||||||
await db.delete(usersTable).where(eq(usersTable.email, user.email));
|
|
||||||
console.log('User deleted!')
|
|
||||||
}
|
|
||||||
|
|
||||||
main();*/
|
|
||||||
|
|
||||||
// = main file
|
|
||||||
|
|
||||||
// bootstrap application
|
// bootstrap application
|
||||||
const discordController = new DiscordController();
|
const discordController = new DiscordController();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import config from "config";
|
import config from "config";
|
||||||
import { Client, IntentsBitField } from "discord.js";
|
import { Client, IntentsBitField } from "discord.js";
|
||||||
|
|
||||||
const client = new Client({ intents: [IntentsBitField.Flags.Guilds] });
|
const client = new Client({ intents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.GuildMembers] });
|
||||||
|
|
||||||
await client.login(config.discord.token);
|
await client.login(config.discord.token);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user