-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Discord.PS is built off of Discord.JS so for it to work you need Discord.JS.
const { Client } = require('discord.js');
const discordClient = new Client({
// your stuff here
});
once you have your Discord.JS client you can add in Discord.PS.
(prefix is optional)
const { PSClient } = require('discord.ps');
const client = new PSClient({
client: discordClient,
prefix: "!"
});
once you have your ps client set up and working you can run it using this:
client.login(token);
Discord.PS is a combination of Discord.JS and Discord.PY so both work for the most part.
// Discord.JS
client.on("ready", (ctx) => {
console.log(`Logged in as ${ctx.user.tag}.`);
});
// Discord.PS
client.event("ready", (ctx) => {
console.log(`Logged in as ${ctx.user.tag}.`);
});
Discord.PS expands mostly on event names as there are a lot more names for events
for a full list of all event names either go to here or do this:
console.log(client.eventList);
same as events all Discord.JS commands will still function the same even if you use things from Discord.PS client
// Discord.JS
client.on("messageCreate", async (ctx) => {
if (!ctx.content.startsWith(prefix) || ctx.content.endsWith(prefix) && ctx.content.startsWith(prefix)) return;
if (ctx.content == `${prefix}test`) {
console.log(ctx.content);
}
});
however, Discord.PS has an entirely different command system that's similar to Discord.PY
keep in mind that command names, aliases, and prefixes are automatically made to be lowercase so do not use capital letters.
// Discord.PS
client.command( {name: "test"}, async (ctx) => {
console.log(ctx.content);
});
Command Info:
-
name: the name of the command
String
-
aliases: secondary names for the command
Array
-
cooldown: how long until a user can run a command again (uses seconds)
Number
Command Function:
- ctx: command context (ctx.content)
- cmd: command info (cmd.name, cmd.args, cmd.cooldown)
Command Info (CMD):
-
cmd.name: name of the command
String
-
cmd.args: array of the command's arguments
Array
-
cmd.onCooldown: if the command is on cooldown
Boolean
-
cmd.cooldownType: type of cooldown (command or global)
String
-
cmd.cooldown: cooldown info
Object
// message: !test a b c
client.command( {name: "test", aliases: ["testcommand", "commandtest"], cooldown: 5 }, async (ctx, cmd) => {
console.log(ctx.content); // "!test a b c"
console.log(cmd.name); // "test"
console.log(cmd.args); // ["a", "b", "c"]
console.log(cmd.onCooldown); // false
console.log(cmd.cooldownType); // null
console.log(cmd.cooldown); // null
});
unfortunately due to JavaScript limitations I wasn't really able to add a real countdown until when the cooldown is up
client.command( {name: "test", cooldown: 5 }, async (ctx, cmd) => {
if (cmd.onCooldown) {
return client.reply("command is on cooldown!");
}
});
if you want a full list of the bot's commands you can do this:
console.log(client.commandList);
login with a token
takes a token as a string
client.login(token);
creates a new command
client.command( {name: "name", alises: ["aliases"], cooldown: 5}, async (ctx, cmd) => {
// do stuff
});
to fetch a command you can use this
takes a command name and a function (optional)
let command = client.fetchCommand("test");
console.log(command.name);
or
client.fetchCommand("test", (command) => {
console.log(command.name);
});
to check if a command exists you can use this
takes a command name
let exists = client.commandExists("test");
mostly used for parts of the api but you can use it if you want
used to execute commands with script instead of with messages
client.executeCommand(name, ctx, cmd);
to format a command you can use this
takes a string
// message: "!test a b c"
let format = client.commandFormat(message);
console.log(format.name); // "test"
console.log(format.args); // ["a", "b", "c"]
mostly used for parts of the api but you can use it if you want
used to handle commands from messages
discordClient.on("messageCreate", async (ctx) => {
Holder = [client, discordClient, ctx];
client.commandHandler(ctx);
});
returns an array of all the commands for the bot
console.log(client.commandList);
returns an array of all the events
console.log(client.eventList);
does something when an event happens
client.event("join", async (ctx) => {
console.log("user joined!");
});
for a full list of colors you can either go to here or do this:
console.log(client.colors);
let embed = client.Embed({
description: "a",
color: client.colors.blurple
});
converts a hex color into an 0x int color for use in embeds
client.colorFormat(client.colors.blurple); // 0x7289da
edited version of the normal message embeds for more simplicity
for all of the ones that have url removed you can still use it especially for things like footer
let embed = client.Embed({
name: "name",
description: "description",
color: client.colors.blurple,
image: "url",
thumbnail: "url",
// the normal {url: "url"} for image and thumbnail still work if you want to use them
fields: [
{name: "test", value: "a b c", inline: true},
{name: "test2", value: "d e f", inline: false}
],
footer: "a"
// footer: {name: "a"}
// footer: {text: "a", icon: "url"}
// footer: {text: "a", iconURL: "url"}
timestamp: client.time.now.embed
});
client.channel.send({embeds: [embed]});
edited version of the normal message buttons for way more simplicity
for more info on buttons and button styles go here
let button = client.Button({
id: "id",
label: "label",
emoji: "emoji", // even tho pretty sure emoji and label can't be in the same button but eh
style: "primary"
});
takes a string and converts it into the cooresponding number
console.log(client.buttonStyle("primary")); // 1
edited version of the normal message select menus for way more simplicity
for more info on select menus go here
let select = client.Selection({
id: "id",
label: "label",
min: 1,
max: 4,
options: [
{ label: "A", value: "A", description: "Option A" },
{ label: "B", value: "B", description: "Option B" },
{ label: "C", value: "C", description: "Option C" },
{ label: "D", value: "D", description: "Option D" },
]
});
takes an array and returns a new action row
used for buttons and stuff
let button1 = client.Button({ /* button stuff */});
let button2 = client.Button({ /* button stuff */});
let row = client.ActionRow([button1, button2]);
client.channel.send({ components: [row] });
takes an id or @mention and gets user info from the bot's user cache
let user = client.fetchUser("id");
console.log(user.tag);
takes an id or @mention and gets user info from a guild's users
let user = client.fetchGuildUser("id");
console.log(user.tag);
takes an id or #channel mention and gets channel info from the bot's channel cache
let channel = client.fetchChannel("id");
console.log(channel.name);
takes an id or #channel mention and gets channel info from a guild's channels
let channel = client.fetchGuildChannel("id");
console.log(channel.name);
takes an id or @role mention and gets role info from a guild's roles
let role = client.fetchGuildRole("id");
console.log(role.name);
outputs a string with a timestamp that can be used by discord
for more info on how timestamps work go here
let embed = client.Embed({
description: "a",
timestamp: client.time.now.embed
});
client.channel.send(client.time.now.relative, {embeds: [embed]});
- Set: takes a given time and turns it into a usable time for discord (ex: client.time.set.default("28 November 2018 09:01"))
- Now: uses the current time and turns it into a usable time for discord (ex: client.time.set.relative)
- embed: time for embeds
- default: default time
- shortTime: shorter version of the time
- longTime: longer version of the time
- shortDate: shorter version of the date
- longDate: longer version of the date
- shortDT: shorter version of the date and time
- longDT: longer version of the date and time
- relative: time relative to the current time
sends a message to a channel
takes message content and an extras object
let message = await client.channel.send("abc", {embeds: [embed], components: [row]});
replies to a message
takes message content and an extras object
let message = await client.reply("abc", {embeds: [embed], components: [row]});
purges a channel for a given amount of messages
channel is optional and defaults to the ctx channel if not given
client.channel.purge(5, channel);
locks a channel making it so the @everyone role can't speak
channel is optional and defaults to the ctx channel if not given
client.channel.lock(channel);
unlocks a channel making it so the @everyone role can speak again
channel is optional and defaults to the ctx channel if not given
client.channel.unlock(channel);
sets the slowmode of a channel
takes a number (time) and an optional channel (defaults to ctx.channel)
client.channel.setSlowmode(time, channel);
removes the slowmode for a channel
takes an optional channel (defaults to ctx.channel)
client.channel.removeSlowmode(channel);
mutes and deafens everyone in a voice channel
takes a channel
client.voice.lock(channel)
unmutes and undeafens everyone in a voice channel
takes a channel
client.voice.unlock(channel)
makes the bot join a voice channel
takes a channel
client.voice.join(channel)
makes the bot leave a voice channel
takes a channel
client.voice.leave(channel)
returns the amount of members a guild has
client.guild.memberCount
returns the amount of roles a guild has
client.guild.roleCount
returns the amount of channels a guild has
client.guild.channelCount
returns the amount of emojis a guild has
client.guild.emojisCount
returns the amount of stickers a guild has
client.guild.stickerCount
lets you get every member in a server
client.guild.members( (members) => {
members.forEach( (member) => {
// do stuff
});
});
lets you get every role in a server
client.guild.roles( (roles) => {
roles.forEach( (role) => {
// do stuff
});
});
lets you get every channel in a server
client.guild.channels( (channels) => {
channels.forEach( (channel) => {
// do stuff
});
});
lets you get every emoji in a server
client.guild.emojis( (emojis) => {
emojis.forEach( (emoji) => {
// do stuff
});
});
lets you get every sticker in a server
client.guild.stickers( (stickers) => {
stickers.forEach( (sticker) => {
// do stuff
});
});
For a look at some examples check out the examples folder
If anything with the mod is updated you can look to the releases for info on it
For a look into the development check out the index.js file
This mod is not associated with the creators of Discord, Discord.JS, or Discord.PY this was created out of love for Discord bot development because I wanted to make things easier for people. I do not condone harassment of the original developers and or anyone else involved in the creation of them.
I am not responsible for anything made with this mod and be sure to follow Discord's terms of service and their community guildlines while developing.
Basics
wc.command()
wc.slashCommand()
wc.commandList
wc.slashCommandList
Basics
wc.event()
wc.eventList
wc.commandAction()
wc.buttonAction()
wc.selectionAction()
wc.rowAction()
wc.fetchMessage()
wc.fetchReply()
wc.fetchUser()
wc.fetchGuildUser()
wc.fetchChannel()
wc.fetchGuildChannel()
wc.fetchRole()
wc.fetchGuildRole()
wc.fetchGuild()
wc.parseEmoji()
wc.parseSticker()