0.0.4 • Published 5 years ago

discord.useful v0.0.4

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

discord.useful

A easy and useful discord library.

Getting Started

Installation

Run: npm install discord.useful

Examples

Basic Example

const Discord = require('discord.useful')
const client = new Discord('YOUR_TOKEN') //Put your token here.

client.on('messageSend', function(message) { // Detect when a message is written.
  if(message.content === 'ping') { // If content is "ping".
    message.channel.send('Pong!') // Output => Pong!
  
  }
  
  if(message.author.tag === 'Tolga1452#2762') { // If author's tag is "Tolga1452#2762".
    message.channel.send('Hello!') // Output => Hello!
  
  }

})

client.login()

Medium Example

const Discord = require('discord.useful')
const client = new Discord('YOUR_TOKEN') //Put your token here.

const prefix = '!'

client.on('ready' function() {
  client.setActivity('idle', 'play', 'This code is working...')

})

client.on('messageSend', function(message) { // Detect when a message is written.
  if(message.content === prefix + 'hello') { // If content is "!" + "hello" = "!hello".
    message.channel.send('Hi!') // Output => Hi!
  
  }
  
  if(message.content === prefix + 'code') { // If content is "!" + "code" = "!code".
    message.channel.sendCode('js', 'const List = ["1", "2", "3", "4", "5"]') Output => (Code Type)
  
  }

})

client.login()

Professional Example

const Discord = require('discord.useful')
const client = new Discord('YOUR_TOKEN') //Put your token here.

const prefix = '!'

client.on('ready' function() {
  client.setActivity('dnd', 'watching', 'I am a bot..')

})

client.on('messageCreate', function(message) { // Detect when a message is written.
  if(message.content === `${prefix}testing`) { // If content is "!" + "testing" = "!testing".
    if(message.author.bot) { // If author is a bot.
      client.createMessage(message.channelID, 'You are a bot!') // Output => "You are a bot!"
    
    } else { // Else (If author is not a bot.).
      client.createMessage(message.channelID, 'You are not a bot!') // Output => "You are not a bot!"
    
    }
  
  }
  
  if(message.content === `${prefix}myCode`) { // If content is "!" + "myCode" = "!myCode".
    client.createCode(message.channelID, 'diff', 'It is a code.') // Output => (Code Type)
  
  }

})

client.connect()

If you need more examples you can see our other examples.

Links

Github

Support Server (SOON!)

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago