-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
81 lines (64 loc) · 2.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const Discord = require('discord.js');
const bot = new Discord.Client();
const client = new Discord.Client()
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on('ready', () => {
console.log('Bot: Hosting ' + `${client.users.size}` + ' users, in ' + `${client.channels.size}` + ' channels of ' + `${client.guilds.size}` + ' guilds.');
client.user.setStatus('online')
client.user.setPresence({
game: {
name: '!oumae',
type: "Playing",
url: "https://discordapp.com/"
}
});
});
client.on('message', (receivedMessage) => {
if (receivedMessage.author == client.user) { // Prevent bot from responding to its own messages
return
}
if (receivedMessage.content.startsWith("!")) {
processCommand(receivedMessage)
}
})
function processCommand(receivedMessage) {
let fullCommand = receivedMessage.content.substr(1) // Remove the leading exclamation mark
let splitCommand = fullCommand.split(" ") // Split the message up in to pieces for each space
let primaryCommand = splitCommand[0] // The first word directly after the exclamation is the command
let arguments = splitCommand.slice(1) // All other words are arguments/parameters/options for the command
console.log("Command received: " + primaryCommand)
console.log("Arguments: " + arguments) // There may not be any arguments
if (primaryCommand == "oumae") {
helpCommand(arguments, receivedMessage)
} else if (primaryCommand == "multiply") {
multiplyCommand(arguments, receivedMessage)
} else {
receivedMessage.channel.send("Try `!oumae`")
}
}
function helpCommand(arguments, receivedMessage) {
if (arguments.length > 0) {
receivedMessage.channel.send({embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: ":white_check_mark: Click here: " + arguments,
url: "https://oumae.kireisubs.org/?n0=" + arguments,
description: "Click link above,feel free to correct these Lyrics, or wrong object, sorry for disappointing!",
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© oumae"
}
}
});
receivedMessage.channel.send("I found some results from your query\n:mag: **" + arguments+"**",{ files: ["https://i.imgur.com/3bE3UPT.png"] })
} else {
receivedMessage.channel.send("usage [prefix] query instead, ie\n```!oumae bokuben ending```")
}
}
client.login('owo')