How can I connect my Discord bot to my HTML website?
I don't need a dashboard. I just need to show how many servers my bot is in. On my website, how can I do this and which backend language should I use?
Which is the best backend language for web development?
My HTML content:
<!DOCTYPE html>
<html>
<head>
<div class="topnav">
<a class="active" href="#home">Home</a>
News
Contact
About
</div>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Beast Bot</title>
</head>
<body>
<div class="container">
<div class="title">
<P>Beast Bot :)</P>
<img class="img" src="images/kisspng-portable-network-graphics-computer-icons-transpare-braingoodgames-5c9d9c5093e378.8617067815538330406058.png">
</div>
</div>
</div>
</body>
</html>
I would use client.guilds.size to get the amount of servers it's in. Assuming the web server and the bot are on the same server then, I would write the raw count of the amount of servers it's in to a file that the public can access from a browser.
Using jQuery (by adding <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> to your head) you can do a GET request to the publicly accessible URL that has that number, like this:
$.get("/path/to/data", data => {
// Your code here to display it. The data variable will have the page's content
})
You can use an API to fetch data from your bot's back end. Frameworks like Express.js are great for making a REST API from scratch.
Related
I have a website, norway-yv.epizy.com. I use InfinityFree to host (I just want to use the website for practise and as a fun hobby project). They use filemanager.ai to manage my files. I have a vast system of files and folders (see below), and instead of having to upload every file and every folder I have made it so that everything is in the website folder. This way, I do not need to upload everything every time I change something in my local copy of the website. I want norway-yv.epizy.com to redirect to norway-yv.epizy.com/website/home.html, and have done this trough an index.html file. However, it only gives error 404.
My files
.htaccess
DirectoryIndex index.php index.html index.htm index2.html
ErrorDocument 403 https://infinityfree.net/errors/403/
ErrorDocument 404 https://infinityfree.net/errors/404/
ErrorDocument 500 https://infinityfree.net/errors/500/
I have configured http://norway-yv.epizy.com/website/myerrorpages/[errornum].html as error page path in InfinityFree control panel
htdocs (folder, automatically created)
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>norway-yv</title>
</head>
<body>
<meta http-equiv="refresh" content="0; url=website/home.html">
</body>
</html>
website (folder, manually created)
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>norway-yv</title>
</head>
<body>
<meta http-equiv="refresh" content="0; url=home.html">
</body>
</html>
home.html
<html lang="en">
<head>
<title>norway-yv | home</title>
<link rel="icon" type="image/png" href="../files/icons/favicon.png">
<link rel="stylesheet" href="style/normal.css">
</head>
<body>
<header>
<a href="home.html">
<img class="logoTop" src="files/icons/favicon.png" alt="Logo" />
</a>
</header>
<h1>This is the website of norway-yv</h1>
<p>I'm sorry for the horrible look of my website, but it is the best I can do</p>
<h2>About me</h2>
<p>I am a hobby developer who likes programming in Python. I am a student in Norwegian upper secondary school, year 1.<br>
Some of my best projects can be found <a href="projects.html" >here.</a><br>
Feel free to contact me trough GitHub.</p>
<h2>Contact</h2>
<p>
<a href="https://stackoverflow.com/users/17496608/norway-yv" >StackOverflow</a><br>
GitHub (via GitHub e-mail)<br>
</p>
</body>
</html>
projects.html
<html lang="en">
<head>
<title>norway-yv | projects</title>
<link rel="icon" type="image/png" href="../files/icons/favicon.png">
<link rel="stylesheet" href="style/normal.css">
</head>
<body>
<header>
<a href="home.html">
<img class="logoTop" src="files/icons/favicon.png" alt="Logo" />
</a>
</header>
<h1>My projects</h1>
<p>I have made tons more than this, mainly for scientific and mathematic purposes, but these are some of the projects I am most proud of:</p>
<h2>kode24-calculator</h2>
<p>An ongoing project, where I try to calculate expected wage for Norwegian developers using many different parametres.<br>
For more information, see here. </p>
<h2>binary-calculator</h2>
<p>A project that sort of is finished, but still has a long way to go. Currently, it can calculate the sum of two binary numbers up to 32 bit size and output it.<br>
For more information, see here. </p>
</body>
</html>
My comments in the end
I have much more than this in my website, with several other folders. I can add them to the question if that is necessary. But I hope not.The same problems do occur when previewing (using edge showing the local version). So it's more of a problem with my files than InfinityFree.
Maybe it's not working because you are missing the <base> tag in your <head>.
The base tag defines the base URL, from where relative URLS are redirected.
For more
I am currently at a dead end on one of the projects I am working on.
I'm working on the translation of an application in Xamarin Ios, at the moment
the entire application can be translated and the language of the application can be changed directly via the app.
But this application also has Tutorials pages that explain in a few words what is the purpose of this feature.
These pages are in html and have a relatively simplistic content that looks like this:
<!DOCTYPE html>
<html>
<head>
<title>Tutorial 1</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div class="content-block">
<p>Use this page to add a new friend</p>
<p>It could be a good idea to give him a pseudo</p>
</div>
</body>
</html>
These pages should be translated on the fly when the user
decides to change the language of the application.
Currently the entire application could be translated into several languages except these html pages, simply because I have no idea what's the best way to do it.
I didn't find any information or documentation about this (I'm pretty sure that's because I'm using Xamarin Ios).
I am looking for a way to fill my html file with the contents of my resx files in which I would put the content html pages.
1 - I will have to save Html tags in my resx files if I decide to write <strong> this word </ strong>, which does not seem to me very practical and will oblige me to record every sentence and / or word that stands between specific tag ?
2 - How can I do this binding between my html file and my resx file? To get something like this
<!DOCTYPE html>
<html>
<head>
<title>Tutorial 1</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div class="content-block">
<p> [contentFromMyResxFile] </p>
<p> [AnotherContentFromMyResxFile] </p>
</div>
</body>
</html>
content being loaded directly from my resx file and so could adapt to the language of the application.
I am having trouble linking my HTML pages together. My code is below.
I have anchored the links the best way I know how to, but when I put them in HTML format and click on the hyperlink, it tells me the file cannot be found.
I have three pages I need to link together, and before I test it out, I put them all in one folder on my desktop and try to pull them up and I run into that error.
Here is my code. For ease of access, they are divided by headers of INDEX, SERVICES, and CONTACT. However, they are three separate html files.
<!DOCTYPE html>
<html lang=“en”>
<head>
<title>Trillium Media Design</title>
<meta charset=“utf-8”>
</head>
<body>
<header>
<h1>Trillium Media Design</h1>
</header>
<nav>
<b> <a href=“index.html”>Home</a>
<a href=“services.html”>Services</a>
<a href=“contact.html”>Contact</a>
</b>
</nav>
<main>
<h2>New Media and Web Design</h2>
<p>Trillium Media Design offers a comprehensive range of services to take your company's Web presence to the next level.</p>
<h3>Meeting Your Business Needs</h3>
<p>Our expert designers will listen to you as they create a website that helps to promote and grow your business.</p>
<footer>
<small><i>Copyright © 2018 Michael Vitucci</i></small></footer>
</body>
</html>
SERVICES
<!DOCTYPE html>
<html lang=“en”>
<head>
<title>Trillium Media Design-Services</title>
<meta charset=“utf-8”>
</head>
<body>
<header>
<h1>Trillium Media Design</h1>
</header>
<nav>
<b> <a href=“index.html”>Home</a>
<a href=“services.html”>Services</a>
<a href=“contact.html”>Contact</a>
</b>
</nav>
<main>
<h2>Our Services Meet Your Business Needs</h2>
<dl>
<dt><strong>Website Design></strong></dt>
<dd>Whether your needs are large or small, Trillium can get you on the Web!</dd>
<dt>strong>E-Commerce Solutions</strong></dt>
<dd>Trillium offers quick entry into the e-commerce marketplace.</dd>
<dt><strong>Search Engine Optimization</strong></dt>
<dd>Most people find new sites using search engines. Trillium can get your website noticed.</dd>
</dl>
<footer>
<small><i>Copyright © 2018 Michael Vitucci</i></small></footer>
</body>
</html>
CONTACT
<!DOCTYPE html>
<html lang=“en”>
<head>
<title>Trillium Media Design-Contact</title>
<meta charset=“utf-8”>
</head>
<body>
<header>
<h1>Trillium Media Design</h1>
</header>
<nav>
<b><a href=“index”>Home</a>
<a href=“services”>Services</a>
<a href=“contact”>Contact</a>
</b>
</nav>
<main>
<h2>Contact Trillium Media Design Today</h2>
<ul>
<li>E-Mail:
<a href=“mailto:contact#trilliummediadesign.com”>contact#trilliummediadesign.com</a>
</li>
<li>Phone: 555-555-5555</li>
</ul>
<footer>
<small><i>Copyright © 2018 Michael Vitucci</i></small></footer>
</body>
</html>
NEW CODE taken from browser source of Index page.
<!DOCTYPE html>
<html lang=“en”>
<head>
<title>Trillium Media Design</title>
<meta charset=“utf-8”>
</head>
<body>
<header>
<h1>Trillium Media Design</h1>
</header>
<nav>
<b> Home
Services
Contact
</b>
</nav>
<main>
<h2>New Media and Web Design</h2>
<p>Trillium Media Design offers a comprehensive range of services to take your company's Web presence to the next level.</p>
<h3>Meeting Your Business Needs</h3>
<p>Our expert designers will listen to you as they create a website that helps to promote and grow your business.</p>
<footer>
<small><i>Copyright © 2018 Hannah Markel</i></small></footer>
</body>
</html>
This is the browser URL I get from the Index page.
file:///C:/Users/Michael%20Vitucci/Desktop/michaeltest/michaelindex.html
This is the browser URL I get from the error page.
file:///C:/Users/Michael%20Vitucci/Desktop/michaeltest/index.html
You are using typographic quotation marks, while you should use double quotes (and this applies to all attributes). For example, instead of: Home.
check all these files are in the same directory as index.html?, else you have to mention relative path from the directory where these files are kept and if they are in same directory still issue try like "./services.html"
<b> Home
Services
Contact
</b>
Have you tried adding the whole address?
Home
Are these files are on the same level, i.e is index.html and about.html placed in same folder if they are placed in the same folder you can directly access that file via "./about.html" from index.html file, if the files are placed in different folders at the same level, then you need to go up one level i.e "../about/about.html";
p.s to avoid any typos you can use tools like emmet for HTML, and to avoid path mismatch issues you can use extensions like path Intellisense.
(Emmet and path Intellisense are extensions available in vs code).
I’m just trying to insert an html absolute link to my texteditor on Mac and I get this on the browser url:
file:///Users/yasser/Desktop/211Website/Labs/https://delicious.com/jodi.reed/browsers...
and file not found in Firefox or Chrome or Safari. When I delete the path before the http the page opens fine...
The code is below-
<!DOCTYPE html>
<html>
<!-- Lab2 Yasser Abdelhalim -->
<head> <meta charset="UTF-8">
<title> Lab2 Yasser Abdelhalim </title>
</head>
<body>
<h1> Yasser’s Web Development resources </h1> this is description for heading number one
<div>
<h2> Background </h2>
<ul>
<li><a href=“delicious.com/jodi.reed/browsers”>link</a></li>
<li><a href=“delicious.com/jodi.reed/browsers”>link</a></li>
<li><a href=“delicious.com/jodi.reed/browsers”>link</a></li>
</ul>
<h2> Web programing </h2>
<ul>
</div>
</body>
</html>
I think (without seeing anything else) you just need to add the initial part of your URLs, as your ocmputer is thinking they're local, relative files (in the same directory as the file with this code in).
Try using this code:
<!DOCTYPE html>
<html> <!-- Lab2 Yasser Abdelhalim -->
<head>
<meta charset="UTF-8">
<title>Lab2 Yasser Abdelhalim</title>
</head>
<body>
<h1>Yasser’s Web Development resources</h1> this is description for heading number one
<div>
<h2>Background</h2>
<ul>
<li>
link
</li>
<li>
link
</li>
<li>
link
</li>
</ul>
</div>
</body>
</html>
Try typing the full address in here, including speech marks (double quotes).. sometimes when copying and pasting URLs it copies the formatted speech marks from some fontstyles.
Apache is the webserver that runs on Linux, it pretty much is a foundation or base of every website around (with some exceptions).
Are you using Windows or Mac? You would be better to be working in a proper web server environment (I can explain)
I have following code in index.html:
<a data-ajax="false" rel="external" href="../Info/BasicDefinition.pdf"
data-theme="c" data-iconpos="top" data-icon="arrow-d" data-role="button">Structure</a>
But i get 404 error - file not found after click on structure link. What i must change? I want to open .pdf file from browser.
My file structure (MPSR - root folder of my web site)
-MPSR
-----index.html
-Info
-----BasicDefinition.pdf
Linking without Ajax
Links that point to other domains or that have rel="external", data-ajax="false" or target attributes will not be loaded with Ajax. Instead, these links will cause a full page refresh with no animated transition. Both attributes (rel="external" and data-ajax="false") have the same effect, but a different semantic meaning: rel="external" should be used when linking to another site or domain, while data-ajax="false" is useful for simply opting a page within your domain from being loaded via Ajax. Because of security restrictions, the framework always opts links to external domains out of the Ajax behavior.
Source: http://jquerymobile.com/demos/1.0.1/docs/pages/page-links.html
So, you can remove the rel="external" from your tag and it should work.
I can't post this on jsFiddle, as it wouldn't work, but I've tested here and it worked fine:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div>
<div data-role="content">
<p>
<a data-ajax="false" href="../info/test.txt" data-iconpos="top" data-icon="arrow-d" data-role="button">Link</a>
</p>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
</body>
</html>
Folder structure:
\test
\info
\test.txt
\root
\index.html