Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-dark.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Discord StorageBot by deoliveg</title>
</head>
<body>
<div id="container">
<div class="inner">
<header>
<h1>Discord StorageBot</h1>
<h2></h2>
</header>
<section id="downloads" class="clearfix">
<a href="https://github.coventry.ac.uk/deoliveg/StorageBot-Discord" id="view-on-github" class="button"><span>View on GitHub</span></a>
</section>
<hr>
<section id="main_content">
<p>An introduction to a new project isn't always easy, this was another one of those regular project cases where we start with one idea and the end result is something completely different than what we were expecting.</p>
<p>The first idea was to make a Coventry Friendly Bot, it would give you helpful information about living in Coventry, like restaurants or bus times, but after doing that for a while we started to feel like the project was not going anywhere, people were making code that others needed and were struggling with so the communication was poor between us. That was when the Storage Bot idea gained form.</p>
<p>In our experience as Discord users (at least most of us) there was nothing related to file storage and sharing that could be used within Discord, we could send files to friends or groups but we were not able to save an image or a simple pdf file. So our idea was to <strong>build a "safe haven" where we could let our light files to rest</strong>.</p>
<p>My part of the build was the <strong>download</strong> but I have also made a function to allow the user to <strong>check the files stored</strong> in the bot, the project consists of a file that is uploaded, saved in <a href="https://codio.co.uk/">Codio</a>, registered in our database and then be accessed again by the user via download. This means that there is an inbuilt register system with password encryption and databases managing all the users and files information. Since I only had to focus on the download, my job was to search the database containing the files name and path so I could send the user the file they asked for via Discord messaging. For all this to happen I needed to understand how the Discord's API for python worked, how to create and manipulate a table in a database with python (in this case we used the sqlite3 library), and how the basis of a file transfer system work.<br>
The trickiest part was definitely the database, to someone that had just scrapped the shell of python and programming in general, having to learn something completely new is always a hard time. But I managed to learn something new and something that is useful, I created the table "files" where the name, code, and path of the file are stored as well as the Discord ID of the user from whom the files are. This part of the file code was just a way to make file selection easier for the user and to me as a developer, if I asked for the full name of the file every time people would probably get the name wrong most of the times, so with a simple numeric code that job is way easier.<br>
Having to work with Discord's API was not easy too, the documentation for it is vast but at the same time it is not that explicit so, in order to understand it truly, you have to dig a bit deeper and sometimes search the web for other developers who encountered the same issues as you did.</p>
<p>Laying all this to the side, how do my functions actually work?<br>
First of all the bot must be called, you can do that in two ways, with the command !myfiles or the command !download.</p>
<p>The command !myfiles will show the user the files he/she has stored in the bot with the respectively assigned code, so that function will start by searching the database for the users Discord ID and registering the columns file name and file code that have the column Discord ID equal to the users personal ID from the platform. With this done the next step is to prepare the data to be sent to the user, so the data is stored in a list and this list will consist of tuples and each tuple contains a file name and an assigned numeric code. To finish this function the bot sends the user a private message with the name of the file and the file code.</p>
<p>After knowing the code of the file you want to download the next thing the user can do is call the !download command.<br>
It starts by asking what is the code of the file the user wants to download via Discord message. With an answer given the bot has now the job to search the database for the file path, so it uses the code the user provided and selects the row in the database where the Discord ID is equal to the users and the file code is the same as the one the user provides. Now the bot as the users file path and it just have to send it to the user via Discord message again. He also asks if the user wants to do another download which will basically call the function all over again.</p>
<p>The project itself was not easy to build, although in terms of code I have written a small number of lines it still took a lot of time to understand every bit of code I was writing and making sure that I was going on the right path.<br>
I can say that all the work was for a greater good and that I feel that I have accomplished a lot of skills which I wasn't expecting to achieve. I can now work on other team projects or solo projects with a more efficient perspective and I have learned how to manipulate data in some form and to mess around with API's which opened a lot of other project opportunities for the future.<br>
Overall, I still have a whole new world to discover and a lot of code to learn, but this project helped to go a step further and to teach me to push myself to the limits, always expecting that every bug or every problem can be fixed.</p>
</section>
<footer>
Discord StorageBot is maintained by <a href="https://github.coventry.ac.uk/deoliveg">deoliveg</a><br>
This page was generated by <a href="https://pages.github.com">GitHub Pages</a>. Tactile theme by <a href="https://twitter.com/jasonlong">Jason Long</a>.
</footer>
</div>
</div>
</body>
</html>