<commit_before>// Credit goes to that cutie ;//w//; https://github.com/kurisubrooks/midori

const Canvas = require('canvas');
const { Command } = require('discord.js-commando');
const fs = global.Promise.promisifyAll(require('fs'));
const path = require('path');
const request = require('request-promise');

const config = require('../../settings');
const version = require('../../package').version;

module.exports = class WeatherCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'weather',
			aliases: ['w', '☁', '⛅', '⛈', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪'],
			group: 'weather',
			memberName: 'weather',
			description: 'Get the weather.',
			throttling: {
				usages: 1,
				duration: 30
			},

			args: [
				{
					key: 'location',
					prompt: 'what location would you like to have information on?\n',
					type: 'string'
				}
			]
		});
	}

	async run(msg, args) {
		const location = args.location;
		const Image = Canvas.Image;

		Canvas.registerFont(path.join(__dirname, '../../assets/weather/fonts/Roboto-Regular.ttf'), { family: 'Roboto' });
		Canvas.registerFont(path.join(__dirname, '../../assets/weather/fonts/RobotoCondensed-Regular.ttf'), { family: 'Roboto Condensed' });
		Canvas.registerFont(path.join(__dirname, '../../assets/weather/fonts/RobotoMono-Light.ttf'), { family: 'Roboto Mono' });

		if (!config.GoogleAPIKey) return msg.reply('my Commander has not set the Google API Key. Go yell at him.');
		if (!config.WeatherAPIKey) return msg.reply('my Commander has not set the Weather API Key. Go yell at him.');

		const locationURI = encodeURIComponent(location.replace(/ /g, '+'));

		const response = await request({
			uri: `https://maps.googleapis.com/maps/api/geocode/json?address=${locationURI}&key=${config.GoogleAPIKey}`,
			headers: { 'User-Agent': `Commando v${version} (https://github.com/WeebDev/Commando/)` },
			json: true
		});

		if (response.status !== 'OK') return msg.reply(this.handleNotOK(msg, response.status));
		if (response.results.length === 0) return msg.reply('your request returned no results.');

		let city;
		let state;

		const geocodelocation = response.results[0].formatted_address;
		const wAPIKey = config.WeatherAPIKey;
		const params = `${response.results[0].geometry.location.lat},${response.results[0].geometry.location.lng}`;

		const locality = response.results[0].address_components.find(loc => loc.types.includes('locality'));
		const governing = response.results[0].address_components.find(gov => gov.types.includes('administrative_area_level_1'));
		const country = response.results[0].address_components.find(cou => cou.types.includes('country'));

		if (locality && governing) {
			city = locality;
			state = governing;
		} else if (!locality && governing && country) {
			city = governing;
			state = country;
		} else if (locality && !governing && country) {
			city = locality;
			state = country;
		} else if (!locality && !governing && country) {
			city = country;
			state = {};
		} else {
			city = {};
			state = {};
		}

		const res = await request({
			uri: `https://api.darksky.net/forecast/${wAPIKey}/${params}?exclude=minutely,hourly,flags&units=auto`,
			headers: { 'User-Agent': `Commando v${version} (https://github.com/WeebDev/Commando/)` },
			json: true
		});

		const condition = res.currently.summary;
		const icon = res.currently.icon;
		const chanceofrain = Math.round((res.currently.precipProbability * 100) / 5) * 5;
		const temperature = Math.round(res.currently.temperature * 10) / 10;
		const humidity = Math.round(res.currently.humidity * 100);
		/* const windBearing = res.currently.windBearing;*/

		const canvas = new Canvas(400, 180);
		/* const pointerCanvas = new Canvas(16, 16);*/
		const ctx = canvas.getContext('2d');
		/* const pntr = pointerCanvas.getContext('2d');*/
		const base = new Image();
		const cond = new Image();
		const humid = new Image();
		const precip = new Image();
		/* const pointer = new Image();*/

		let theme = 'light';
		let fontColor = '#FFFFFF';

		if (icon === 'snow') {
			theme = 'dark';
			fontColor = '#444444';
		}

		const generate = () => {
			// Environment Variables
			ctx.drawImage(base, 0, 0);
			ctx.scale(1, 1);
			ctx.patternQuality = 'billinear';
			ctx.filter = 'bilinear';
			ctx.antialias = 'subpixel';

			// City Name
			ctx.font = '20px Roboto';
			ctx.fillStyle = fontColor;
			ctx.fillText(city.long_name ? city.long_name : 'Unknown', 35, 50);

			// Prefecture Name
			ctx.font = '26px Roboto';
			ctx.fillStyle = theme === 'light' ? 'rgba(255, 255, 255, 0.8)' : 'rgba(0, 0, 0, 0.8)';
			ctx.fillText(state.long_name ? state.long_name : '', 35, 70);

			// Temperature
			ctx.font = "48px 'Roboto Mono'";
			ctx.fillStyle = fontColor;
			ctx.fillText(`${temperature}°`, 35, 140);

			// Condition
			ctx.font = '16px Roboto';
			ctx.textAlign = 'right';
			ctx.fillText(condition, 370, 142);

			// Condition Image
			ctx.drawImage(cond, 325, 31);

			// Humidity Image
			ctx.drawImage(humid, 315, 88);
<commit_msg>Fix font size<commit_after>// Credit goes to that cutie ;//w//; https://github.com/kurisubrooks/midori

const Canvas = require('canvas');
const { Command } = require('discord.js-commando');
const fs = global.Promise.promisifyAll(require('fs'));
const path = require('path');
const request = require('request-promise');

const config = require('../../settings');
const version = require('../../package').version;

module.exports = class WeatherCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'weather',
			aliases: ['w', '☁', '⛅', '⛈', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪'],
			group: 'weather',
			memberName: 'weather',
			description: 'Get the weather.',
			throttling: {
				usages: 1,
				duration: 30
			},

			args: [
				{
					key: 'location',
					prompt: 'what location would you like to have information on?\n',
					type: 'string'
				}
			]
		});
	}

	async run(msg, args) {
		const location = args.location;
		const Image = Canvas.Image;

		Canvas.registerFont(path.join(__dirname, '../../assets/weather/fonts/Roboto-Regular.ttf'), { family: 'Roboto' });
		Canvas.registerFont(path.join(__dirname, '../../assets/weather/fonts/RobotoCondensed-Regular.ttf'), { family: 'Roboto Condensed' });
		Canvas.registerFont(path.join(__dirname, '../../assets/weather/fonts/RobotoMono-Light.ttf'), { family: 'Roboto Mono' });

		if (!config.GoogleAPIKey) return msg.reply('my Commander has not set the Google API Key. Go yell at him.');
		if (!config.WeatherAPIKey) return msg.reply('my Commander has not set the Weather API Key. Go yell at him.');

		const locationURI = encodeURIComponent(location.replace(/ /g, '+'));

		const response = await request({
			uri: `https://maps.googleapis.com/maps/api/geocode/json?address=${locationURI}&key=${config.GoogleAPIKey}`,
			headers: { 'User-Agent': `Commando v${version} (https://github.com/WeebDev/Commando/)` },
			json: true
		});

		if (response.status !== 'OK') return msg.reply(this.handleNotOK(msg, response.status));
		if (response.results.length === 0) return msg.reply('your request returned no results.');

		let city;
		let state;

		const geocodelocation = response.results[0].formatted_address;
		const wAPIKey = config.WeatherAPIKey;
		const params = `${response.results[0].geometry.location.lat},${response.results[0].geometry.location.lng}`;

		const locality = response.results[0].address_components.find(loc => loc.types.includes('locality'));
		const governing = response.results[0].address_components.find(gov => gov.types.includes('administrative_area_level_1'));
		const country = response.results[0].address_components.find(cou => cou.types.includes('country'));

		if (locality && governing) {
			city = locality;
			state = governing;
		} else if (!locality && governing && country) {
			city = governing;
			state = country;
		} else if (locality && !governing && country) {
			city = locality;
			state = country;
		} else if (!locality && !governing && country) {
			city = country;
			state = {};
		} else {
			city = {};
			state = {};
		}

		const res = await request({
			uri: `https://api.darksky.net/forecast/${wAPIKey}/${params}?exclude=minutely,hourly,flags&units=auto`,
			headers: { 'User-Agent': `Commando v${version} (https://github.com/WeebDev/Commando/)` },
			json: true
		});

		const condition = res.currently.summary;
		const icon = res.currently.icon;
		const chanceofrain = Math.round((res.currently.precipProbability * 100) / 5) * 5;
		const temperature = Math.round(res.currently.temperature * 10) / 10;
		const humidity = Math.round(res.currently.humidity * 100);
		/* const windBearing = res.currently.windBearing;*/

		const canvas = new Canvas(400, 180);
		/* const pointerCanvas = new Canvas(16, 16);*/
		const ctx = canvas.getContext('2d');
		/* const pntr = pointerCanvas.getContext('2d');*/
		const base = new Image();
		const cond = new Image();
		const humid = new Image();
		const precip = new Image();
		/* const pointer = new Image();*/

		let theme = 'light';
		let fontColor = '#FFFFFF';

		if (icon === 'snow') {
			theme = 'dark';
			fontColor = '#444444';
		}

		const generate = () => {
			// Environment Variables
			ctx.drawImage(base, 0, 0);
			ctx.scale(1, 1);
			ctx.patternQuality = 'billinear';
			ctx.filter = 'bilinear';
			ctx.antialias = 'subpixel';

			// City Name
			ctx.font = '20px Roboto';
			ctx.fillStyle = fontColor;
			ctx.fillText(city.long_name ? city.long_name : 'Unknown', 35, 50);

			// Prefecture Name
			ctx.font = '16px Roboto';
			ctx.fillStyle = theme === 'light' ? 'rgba(255, 255, 255, 0.8)' : 'rgba(0, 0, 0, 0.8)';
			ctx.fillText(state.long_name ? state.long_name : '', 35, 70);

			// Temperature
			ctx.font = "48px 'Roboto Mono'";
			ctx.fillStyle = fontColor;
			ctx.fillText(`${temperature}°`, 35, 140);

			// Condition
			ctx.font = '16px Roboto';
			ctx.textAlign = 'right';
			ctx.fillText(condition, 370, 142);

			// Condition Image
			ctx.drawImage(cond, 325, 31);

			// Humidity Image
			ctx.drawImage(humid, 315, 88);

{'fraction_non_alphanumeric': 0.17581321093594093, 'fraction_numerical': 0.019556974655757335, 'mean_word_length': 3.7034256217738153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2731588', 'n_tokens_mistral': 3921, 'n_tokens_neox': 3282, 'n_words': 778}