Skip to content
paige edited this page Oct 20, 2023 · 40 revisions

a hub for noscord.JS development information, most things will appear here.. eventually

Installation

npm i noscord.js
npm i paigeroid/noscord.js

🛈 Client 🛈 Events

const { Client } = require('noscord.js');
const client = new Client(/* stuff */);



// runs when the bot logs in
client.on("ready", (ctx) => {
    console.log(`logged in as ${ctx.user.username}`);
});



// imports stuff
client.import(
    { com: "commands", comp: "components", att: "attachments" },
    [ "channels", "users", "events", "app" ]
);



// creates a new event called pingCmd
let event = events.create();
client.events.push("pingCmd", event);



// creates a listener for the pingCmd event
client.on("pingCmd", async (ctx, cmd) => {
    let channel = await channels.get("channel id");
    channel.send(`${cmd.name} command ran by ${ctx.author} in guild ${ctx.guild.name} (${ctx.guild.id})`);
});



// creates a ping command
com.create("ping", "replies with pong", (ctx, cmd) => {
    let timestamp = new app.Timestamp();


    let embed = new comp.Embed({
        description: "# Pong!",
        timestamp: timestamp.embed,
        color: app.colors.blurple,
        footer: `latency: ${Date.now() - ctx.timestamps.created}ms`
    });

    
    ctx.reply({ embeds: [embed] });
    event.fire(ctx, cmd);
});



// options for the avatar command
let options = [{
    name: "user",
    description: "user to get the avatar of",
    type: "user",
    required: false
}];



// avatar command
com.create("avatar", "sends a users' avatar", options, async (ctx, cmd) => {
    let user;


    if (cmd.args[0]) user = await users.get(cmd.args[0].value);
    else user = ctx.author;


    let { png } = await users.avatar(user, { width: 100, height: 100 });
    let circle = await att.circlify(png);


    ctx.reply({ files: [circle] });
});



// logs into the bot
client.login(token);

🛈 Client

🛈 AddonService

🛈 AttachmentService

🛈 ChannelService

🛈 CommandService

🛈 ComponentService

🛈 ErrorService

🛈 EventService

🛈 ExpressionService

🛈 GuildService

🛈 LogService

🛈 MessageService

🛈 PermissionService

🛈 RoleService

🛈 StorageService

🛈 TypeService

🛈 UserService

🛈 UtilService

🛈 VoiceService


Clone this wiki locally