Skip to content

Commit

Permalink
rollback to the messy one
Browse files Browse the repository at this point in the history
  • Loading branch information
raluvy95 committed Oct 5, 2024
1 parent c99fe27 commit 2e42d4e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,23 @@ class Mov extends CommandClient {
let prefixes = this.commandOptions.prefix;
const userPref = (await this.database.user.get<IUserDB>(msg.author.id))?.prefix.toLowerCase();
const server = (await this.database.settings.get<ISettingsDB>(msg.guildID!))?.prefix.toLowerCase();

if (userPref || server) {
prefixes = userPref || server;
}
else if (msg.channel.guild !== undefined && this.guildPrefixes[msg.channel.guild.id] !== undefined) {
} else if (msg.mentions.includes(this.user)) {
prefixes = this.user.id;
msg.prefix = `<@${this.user.id}>`;
} else if (msg.channel.guild !== undefined && this.guildPrefixes[msg.channel.guild.id] !== undefined) {
prefixes = this.guildPrefixes[msg.channel.guild.id];
}

if (typeof prefixes === "string") {
return msg.content.toLowerCase().startsWith(prefixes) && prefixes;
if (!msg.content.replace(/<@!/g, "<@").toLowerCase().startsWith(prefixes) && typeof server === "string") {
prefixes = server;
}
return msg.content.replace(/<@!/g, "<@").toLowerCase().startsWith(prefixes) && prefixes;
} else if (Array.isArray(prefixes)) {
return prefixes.find((prefix) => msg.content.toLowerCase().startsWith(prefix)) && prefixes;
return prefixes.find((prefix) => msg.content.replace(/<@!/g, "<@").toLowerCase().startsWith(prefix));
}

throw new Error(`Unsupported prefix format | ${prefixes}`);
}

Expand Down

0 comments on commit 2e42d4e

Please sign in to comment.