@nesanya/ntr-discord
Advanced tools
Comparing version
30
index.js
@@ -1,2 +0,2 @@ | ||
class Msg { | ||
class MsgDS { | ||
constructor(client ,prefix) { | ||
@@ -7,5 +7,8 @@ this.client = client | ||
MsgReply(ImportMessage, ExportMessage) { | ||
MsgReply(ImportMessage, ExportMessage, botCheker) { | ||
this.client.on("message", msg => { | ||
if(msg.content === this.prefix + ImportMessage) { | ||
if(botCheker){ | ||
if(msg.author.bot) return | ||
} | ||
msg.reply(ExportMessage) | ||
@@ -15,5 +18,8 @@ } | ||
} | ||
MsgCallback(ImportMessage, callback) { | ||
MsgCallback(ImportMessage, callback, botCheker) { | ||
this.client.on("message", message => { | ||
if(message.content === this.prefix + ImportMessage) { | ||
if(botCheker){ | ||
if(message.author.bot) return | ||
} | ||
callback(message) | ||
@@ -37,4 +43,20 @@ } | ||
} | ||
CallbackWelcomer(callback){ | ||
this.client.on("guildMemberAdd", member => { | ||
callback(member) | ||
}) | ||
} | ||
SimpleWelcomer(textChat, ExportText){ | ||
this.client.on("guildMemberAdd", member => { | ||
const channel = member.guild.channels.cache.find(ch => ch.name === textChat) | ||
if(!channel) { | ||
throw new Error("NTR-Discord: channel not find (SimpleWeclomer)") | ||
} | ||
channel.send(`${member}, ${ExportText}`) | ||
}) | ||
} | ||
} | ||
module.exports = { Msg, MainDS } | ||
module.exports = { MsgDS , MainDS } |
{ | ||
"name": "@nesanya/ntr-discord", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Easier work with discord API", | ||
@@ -10,2 +10,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@discordjs/opus": "^0.1.0", | ||
"discord.js": "^12.0.2" | ||
@@ -12,0 +13,0 @@ }, |
@@ -8,2 +8,4 @@ # NTR-discord | ||
GITHUB - [Click here](https://github.com/NEsanya/NTR-discord.git) | ||
--- | ||
@@ -35,3 +37,68 @@ | ||
msg.MsgReply("ping", "pong") | ||
msg.MsgReply("ping", "pong!") | ||
msg.MsgCallback("pong", message => { | ||
message.reply("ping!") | ||
}) | ||
``` | ||
*** | ||
> MainDS Class | ||
> Method start | ||
Method start calling function client.login ([Explanation here](https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=login)) and calling fucntion client.on("ready") ([Explanation here](https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-ready)) | ||
###### Code example: | ||
```js | ||
/** *@example start */ | ||
const Discord = require("discord.js") | ||
const client = new Discord.Client() | ||
const { MainDS } = require("@nesanya/ntr-discord") | ||
const main = new MainDS(client, TOKEN_HERE) | ||
main.start(() => { | ||
console.log(`Logged in as ${client.user.tag}!`) | ||
}) | ||
``` | ||
*** | ||
> Msg Class | ||
> Method MsgReply | ||
The MsgReply method calls fucntion client.on ("message") ([Explanation here](https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-message)) , and it works like question/asnwer | ||
###### Code example: | ||
```js | ||
/** *@example MsgReply */ | ||
const Discord = require("discord.js") | ||
const client = new Discord.Client() | ||
const { Msg } = require("@nesanya/ntr-discord") | ||
const msg = new Msg(client, "YOUR PREFIX") | ||
msg.MsgReply("ping (question)", "pong (answer)") | ||
// To call, enter the channel "YOUR_PREFIX" + ping into your discord | ||
``` | ||
> Method MsgCallback | ||
MsgCallback works like MsgReply, but instead of answering you call your function (function parameters: message ([Explanation here](https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-message))) | ||
###### Code example: | ||
```js | ||
/** *@example MsgCallback */ | ||
const Discord = require("discord.js") | ||
const client = new Discord.Client() | ||
const { Msg } = require("@nesanya/ntr-discord") | ||
const msg = new Msg(client, "YOUR PREFIX") | ||
msg.MsgCallback("pong", message => { | ||
message.reply("ping!") | ||
}) | ||
// Returned: ping! | ||
``` |
6056
81.1%52
62.5%103
186.11%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added