Ugolin Ollé
Ugolin Ollé
DIAdiscord.js - Imagine an app
Created by Ugolin Ollé on 10/29/2023 in #djs-questions
Anyone can help me to fix old code ?
Hi there! Actually i'm stuck on an old code.
const fullPermissions = commandsCol.reduce<
GuildApplicationCommandPermissionData[]
>((a, b) => {
const roles = getRoles(b.name);
if (!roles) return a;

const command = this.commands.get(b.name)!;

if (command.onlyDev)
return [
...a,
{
id: b.id,
permissions: devArr
}
];

const permissions = roles.reduce<
ApplicationCommandPermissionData[]
>((x, y) => {
return [
...x,
{
id: y.id,
type: 'ROLE',
permission: true
}
];
}, devArr);

return [
...a,
{
id: b.id,
permissions
}
];
}, []);

await guild.commands.permissions.set({ fullPermissions });
const fullPermissions = commandsCol.reduce<
GuildApplicationCommandPermissionData[]
>((a, b) => {
const roles = getRoles(b.name);
if (!roles) return a;

const command = this.commands.get(b.name)!;

if (command.onlyDev)
return [
...a,
{
id: b.id,
permissions: devArr
}
];

const permissions = roles.reduce<
ApplicationCommandPermissionData[]
>((x, y) => {
return [
...x,
{
id: y.id,
type: 'ROLE',
permission: true
}
];
}, devArr);

return [
...a,
{
id: b.id,
permissions
}
];
}, []);

await guild.commands.permissions.set({ fullPermissions });
Actually i try to fixed but i don't find alternative because ApplicationCommandPermissionData and GuildApplicationCommandPermissionData doesn't exist anymore. How fix this ?
6 replies
DIAdiscord.js - Imagine an app
Created by Ugolin Ollé on 10/25/2022 in #djs-questions
Clear embed
Hello again! Just a simple question how can i clear all fields of a embed builder ?
3 replies
DIAdiscord.js - Imagine an app
Created by Ugolin Ollé on 10/25/2022 in #djs-questions
Prefix not detected
Hello again! I try to add prefix but when i use !help nothin appear. I think this comes from my config:
export default class DiscordClient extends Client {
/**
* Registry of the client.
*/
readonly registry: Registry;

/**
* Config of the client.
*/
readonly config: IConfig;

constructor(intents: GatewayIntentBits[]) {
super({ intents });

/**
* Setting up client's config.
*/
this.config = {
token: process.env.TOKEN as string,
prefix: '!', // process.env.PREFIX as string
developers: JSON.parse(process.env.DEVELOPERS as string) as string[],
unknownErrorMessage: JSON.parse(
process.env.UNKNOWN_COMMAND_ERROR as string
)
};

/**
* Creating new registry class.
*/
this.registry = new Registry(this);

/**
* Registering events and commands.
*/
this.registry.registerAll();
}
}
export default class DiscordClient extends Client {
/**
* Registry of the client.
*/
readonly registry: Registry;

/**
* Config of the client.
*/
readonly config: IConfig;

constructor(intents: GatewayIntentBits[]) {
super({ intents });

/**
* Setting up client's config.
*/
this.config = {
token: process.env.TOKEN as string,
prefix: '!', // process.env.PREFIX as string
developers: JSON.parse(process.env.DEVELOPERS as string) as string[],
unknownErrorMessage: JSON.parse(
process.env.UNKNOWN_COMMAND_ERROR as string
)
};

/**
* Creating new registry class.
*/
this.registry = new Registry(this);

/**
* Registering events and commands.
*/
this.registry.registerAll();
}
}
Could you help me again lol ?
3 replies
DIAdiscord.js - Imagine an app
Created by Ugolin Ollé on 10/25/2022 in #djs-questions
Try to detect member
Hello their! I try to detect if user is in guild with this code:
const self = (message.guild as Guild).me as GuildMember;
const self = (message.guild as Guild).me as GuildMember;
But it return this error Property 'me' does not exist on type 'Guild' Could you help me ?
5 replies