about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--index.js49
1 files changed, 47 insertions, 2 deletions
diff --git a/index.js b/index.js
index 0d13674..c03ab78 100644
--- a/index.js
+++ b/index.js
@@ -1,11 +1,56 @@
 import { config } from 'dotenv'
-config()
-
 import { Client } from 'discord.js'
+import DisConf from './config.json'
+config()
 const client = new Client()
 
 client.once('ready', () => {
   console.log('ByTheWay, your bot is ready')
 })
 
+client.on('message', message => {
+  if (!message.content.startsWith(DisConf.prefix) | message.author.bot) return
+
+  const args = message.content.slice(DisConf.prefix.length).trim().split(/ +/)
+  const command = args.shift().toLowerCase()
+
+  if (command === 'interject') {
+    message.channel.send('I\'d just like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called “Linux”, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine’s resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called “Linux” distributions are really distributions of GNU/Linux.')
+  } else if (command === 'btw') {
+    const roles = message.member.roles.cache.array().map(x => x.name)
+    for (const distro of DisConf.distros) {
+      if (roles.includes(distro)) {
+        message.channel.send(`I use ${distro} Linux, btw`)
+        break
+      }
+    }
+  } else if (command === 'assign') {
+    if (!args.length) {
+      return message.channel.send(`You didn't provide a distro! Tux the penguin is very sad.`)
+    } else if (args.length > 1) {
+      return message.channel.send(`You can use more than one distro when you dual boot, but not with this bot`)
+    }
+
+    const toRemove = message.member.roles.cache.filter(x => DisConf.distros.includes(x.name))
+    const toAdd = message.guild.roles.cache.filter(x => x.name === args[0])
+    console.log(toRemove)
+    console.log(toAdd)
+    message.member.roles.remove(toRemove)
+      .then(() => message.channel.send('Role reset'))
+      .catch(err => {
+        message.channel.send('Oops something happened while resetting your role')
+        console.log(err)
+      })
+
+    message.member.roles.add(toAdd)
+      .then(() => message.channel.send(`You're now a proud user of ${args[0]} Linux!`))
+      .catch(err => {
+        message.channel.send('Oops something happened while adding your role')
+        console.log(err)
+      })
+  }
+})
+
+
+
 client.login(process.env.TOKEN)
9 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328